Skip to content

Commit

Permalink
fix: Final touches implemented to the app.
Browse files Browse the repository at this point in the history
  • Loading branch information
AritraBiswas9788 committed Aug 19, 2024
1 parent 43b387c commit 5926e56
Show file tree
Hide file tree
Showing 19 changed files with 621 additions and 129 deletions.
Binary file added assets/icons/tutorial.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
33 changes: 33 additions & 0 deletions lib/components/MapKmlElement.dart
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,9 @@ class _MapkmlelementState extends State<Mapkmlelement> {
elementIndex: widget.elementIndex,
submitData: widget.submitData));
widget.submitData(kmlElement);
if(kmlElement != null) {
setMapdata(kmlElement);
}
},
icon: const Icon(
Icons.fullscreen_rounded,
Expand Down Expand Up @@ -308,6 +311,36 @@ class _MapkmlelementState extends State<Mapkmlelement> {
}
return list;
}

void setMapdata(KmlElement kmlElement) {
points.clear();
if(kmlElement.index==0)
{
Placemark mark = kmlElement.elementData;
points.add(mark.coordinate.toLatLngMap(mark.coordinate));
}
else
if(kmlElement.index==1)
{
LineString line = kmlElement.elementData;
points.addAll(line.coordinates.map((coord)=>coord.toLatLngMap(coord)));
}
else
if(kmlElement.index==2)
{
PolyGon line = kmlElement.elementData;
points.addAll(line.coordinates.map((coord)=>coord.toLatLngMap(coord)));
}
calculateMarkers();
polyline.clear();
polygon.clear();
polyline.add(calculatePolyLine());
polygon.add(calculatePolygon());
setState(() {
reloadMap();
print(points);
});
}
}

class CallbackHandler {
Expand Down
164 changes: 118 additions & 46 deletions lib/components/apimanager_block.dart
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
import 'dart:ui';

import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:lottie/lottie.dart';
import 'package:shared_preferences/shared_preferences.dart';
import 'package:super_liquid_galaxy_controller/controllers/api_manager.dart';

import '../generated/assets.dart';
import '../utils/galaxy_colors.dart';
import 'custom_dialog.dart';
import 'galaxytextfield.dart';
import 'package:lottie/lottie.dart';
import 'package:get/get.dart';
import 'package:shared_preferences/shared_preferences.dart';

class ApiManagerBlock extends StatefulWidget {
ApiManagerBlock(
Expand All @@ -18,7 +21,7 @@ class ApiManagerBlock extends StatefulWidget {
this.urlLauncher1,
this.urlLauncher2,
required this.keyController,
required this.width});
required this.width});

String title;
String description;
Expand All @@ -33,10 +36,7 @@ class ApiManagerBlock extends StatefulWidget {
State<ApiManagerBlock> createState() => _ApiManagerBlockState();
}



class _ApiManagerBlockState extends State<ApiManagerBlock> {

@override
void initState() {
loadSetValues();
Expand All @@ -52,8 +52,7 @@ class _ApiManagerBlockState extends State<ApiManagerBlock> {
child: Container(
width: widget.width,
decoration: BoxDecoration(
border:
Border.all(color: Colors.white.withOpacity(0.1)),
border: Border.all(color: Colors.white.withOpacity(0.1)),
borderRadius: BorderRadius.circular(5),
gradient: LinearGradient(colors: [
Colors.white.withOpacity(0.1),
Expand All @@ -73,7 +72,7 @@ class _ApiManagerBlockState extends State<ApiManagerBlock> {
children: [
Text(
widget.title,
style:const TextStyle(
style: const TextStyle(
color: Colors.white,
fontSize: 35,
fontWeight: FontWeight.w400,
Expand Down Expand Up @@ -142,7 +141,9 @@ class _ApiManagerBlockState extends State<ApiManagerBlock> {
),
),
),
const SizedBox(width: 20.0,),
const SizedBox(
width: 20.0,
),
Expanded(
child: Material(
color: Colors.transparent,
Expand All @@ -153,7 +154,6 @@ class _ApiManagerBlockState extends State<ApiManagerBlock> {
Colors.blue.withOpacity(0.3),
onTap: widget.urlLauncher2,
child: Container(

child: FittedBox(
fit: BoxFit.fitHeight,
child: Text(
Expand Down Expand Up @@ -183,25 +183,72 @@ class _ApiManagerBlockState extends State<ApiManagerBlock> {
iconData: Icons.code,
textInputType: TextInputType.text,
controller: widget.keyController,
isPassword: false,
buttonAction: () {
isPassword: true,
/*buttonAction: () {
if (widget.keyController.text.isNotEmpty) {
saveApiKey('places_apikey');
} else {
if (!Get.isSnackbarOpen) {
Get.showSnackbar(GetSnackBar(
backgroundColor: Colors.red.shade300,
title: "EMPTY FIELD",
message: "API Key Field is Empty!",
isDismissible: true,
duration: 3.seconds,
));
}
}
else
{
if (!Get.isSnackbarOpen) {
Get.showSnackbar(GetSnackBar(
backgroundColor: Colors.red.shade300,
title: "EMPTY FIELD",
message: "API Key Field is Empty!",
isDismissible: true,
duration: 3.seconds,
));
}
},
endIcon: Icons.save_alt_outlined,*/
),
const SizedBox(
height: 10.0,
),
MaterialButton(
color: GalaxyColors.blue,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(30.0),
),
onPressed: () async {
//await formSubmitted();
if (widget.keyController.text.isNotEmpty) {
saveApiKey('places_apikey');
} else {
if (!Get.isSnackbarOpen) {
Get.showSnackbar(GetSnackBar(
backgroundColor: Colors.red.shade300,
title: "EMPTY FIELD",
message: "API Key Field is Empty!",
isDismissible: true,
duration: 3.seconds,
));
}
}
},
endIcon: Icons.save_alt_outlined,
child: const Padding(
padding: EdgeInsets.symmetric(
vertical: 10.0,
horizontal: 20.0
),
child: Row(
mainAxisSize: MainAxisSize.min,
children: [
Icon(
Icons.key,
size: 30,
color: Colors.white,
),
SizedBox(width: 10.0),
Text(
"CONNECT TO API",
style: TextStyle(
fontSize: 20,
color: Colors.white,
fontWeight: FontWeight.bold),
)
],
),
),
),
const SizedBox(
height: 10.0,
Expand All @@ -210,55 +257,80 @@ class _ApiManagerBlockState extends State<ApiManagerBlock> {
)))
]))));
}
void loadSetValues() async {

void loadSetValues() async {
try {
SharedPreferences preferences = await SharedPreferences.getInstance();
var key = preferences.getString("places_apikey") ?? "";
key = key.trim();
widget.keyController.text = key;
}
catch(e)
{
} catch (e) {
print(e);
}

}


void saveApiKey(String prefKey) async {
SharedPreferences preferences = await SharedPreferences.getInstance();
await preferences.setString(prefKey, widget.keyController.text);
ApiManager apiClient = Get.find();
await apiClient.testApiKey();
var dialog = apiClient.isConnected.value
? CustomDialog(
content: Text("All Api Services now available!"),
title: Text("API KEY VALIDATED",style: TextStyle(color: Colors.green.shade500,fontSize: 25.0,fontWeight: FontWeight.bold),),
firstColor: Colors.green,
secondColor: Colors.white,
headerIcon: Lottie.asset(Assets.lottieConnected,
decoder: customDecoder, repeat: false,width: 200.0,height: 200.0))
content: Padding(
padding: const EdgeInsets.symmetric(horizontal: 25.0),
child: Text("All Api Services now available!"),
),
title: Padding(
padding: const EdgeInsets.symmetric(horizontal: 16.0),
child: Text(
"API KEY VALIDATED",
style: TextStyle(
color: Colors.green.shade500,
fontSize: 25.0,
fontWeight: FontWeight.bold),
),
),
firstColor: Colors.green,
secondColor: Colors.white,
headerIcon: Lottie.asset(Assets.lottieConnected,
decoder: customDecoder,
repeat: false,
width: 200.0,
height: 200.0))
: CustomDialog(
content: Text("Api services unavailable"),
title: Text("API KEY INVALID",style: TextStyle(color: Colors.red.shade500,fontSize: 25.0,fontWeight: FontWeight.bold),),
firstColor: Colors.red.shade400,
secondColor: Colors.white,
headerIcon: Lottie.asset(Assets.lottieConnectionfailed,
decoder: customDecoder, repeat: false,width: 200.0,height: 200.0));
content: Padding(
padding: const EdgeInsets.symmetric(horizontal: 25.0),
child: Text("Api services unavailable"),
),
title: Padding(
padding: const EdgeInsets.symmetric(horizontal: 16.0),
child: Text(
"API KEY INVALID",
style: TextStyle(
color: Colors.red.shade500,
fontSize: 25.0,
fontWeight: FontWeight.bold),
),
),
firstColor: Colors.red.shade400,
secondColor: Colors.white,
headerIcon: Lottie.asset(Assets.lottieConnectionfailed,
decoder: customDecoder,
repeat: false,
width: 200.0,
height: 200.0));
showDialog(
context: context,
builder: (BuildContext context) {
return dialog;
},
);

}

Future<LottieComposition?> customDecoder(List<int> bytes) {
return LottieComposition.decodeZip(bytes, filePicker: (files) {
return files.firstWhere(
(f) => f.name.startsWith('animations/') && f.name.endsWith('.json'),
(f) => f.name.startsWith('animations/') && f.name.endsWith('.json'),
);
});
}
Expand Down
17 changes: 10 additions & 7 deletions lib/components/custom_dialog.dart
Original file line number Diff line number Diff line change
Expand Up @@ -64,13 +64,16 @@ class CustomDialog extends StatelessWidget {
bottomLeft: Radius.circular(20.0),
bottomRight: Radius.circular(20.0),
)),
child: Column(
mainAxisSize: MainAxisSize.min,
mainAxisAlignment: MainAxisAlignment.center,
children: [
title,
content,
],
child: FittedBox(
fit: BoxFit.contain,
child: Column(
mainAxisSize: MainAxisSize.min,
mainAxisAlignment: MainAxisAlignment.center,
children: [
title,
content,
],
),
),
),
)
Expand Down
11 changes: 11 additions & 0 deletions lib/controllers/showcase_controller.dart
Original file line number Diff line number Diff line change
Expand Up @@ -148,5 +148,16 @@ class ShowcaseController extends GetxController {
print("set-poi-done");
}

clearTutorialNeeds()
{
setPOICompleted();
setToursCompleted();
setMapsCompleted();
setSettingsCompleted();
setDashboardCompleted();
setGeoQuestCompleted();
setKmlBuilderCompleted();
}


}
Loading

0 comments on commit 5926e56

Please sign in to comment.