diff --git a/.fvm/flutter_sdk b/.fvm/flutter_sdk deleted file mode 120000 index c77c100b..00000000 --- a/.fvm/flutter_sdk +++ /dev/null @@ -1 +0,0 @@ -/Users/abhishek/fvm/versions/stable \ No newline at end of file diff --git a/.fvmrc b/.fvmrc deleted file mode 100644 index c300356c..00000000 --- a/.fvmrc +++ /dev/null @@ -1,3 +0,0 @@ -{ - "flutter": "stable" -} \ No newline at end of file diff --git a/.vscode/settings.json b/.vscode/settings.json deleted file mode 100644 index 43bac5cd..00000000 --- a/.vscode/settings.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "java.configuration.updateBuildConfiguration": "automatic", - "dart.flutterSdkPath": ".fvm/versions/stable" -} \ No newline at end of file diff --git a/android/.settings/org.eclipse.buildship.core.prefs b/android/.settings/org.eclipse.buildship.core.prefs index fcbe6842..a50efddb 100644 --- a/android/.settings/org.eclipse.buildship.core.prefs +++ b/android/.settings/org.eclipse.buildship.core.prefs @@ -1,11 +1,11 @@ arguments=--init-script /var/folders/87/sjnhgg2s1dn1b0l2r0jrgxx80000gn/T/d146c9752a26f79b52047fb6dc6ed385d064e120494f96f08ca63a317c41f94c.gradle --init-script /var/folders/87/sjnhgg2s1dn1b0l2r0jrgxx80000gn/T/52cde0cfcf3e28b8b7510e992210d9614505e0911af0c190bd590d7158574963.gradle -auto.sync=true +auto.sync=false build.scans.enabled=false connection.gradle.distribution=GRADLE_DISTRIBUTION(WRAPPER) connection.project.dir= eclipse.preferences.version=1 gradle.user.home= -java.home=/opt/homebrew/Cellar/openjdk/21.0.1/libexec/openjdk.jdk/Contents/Home +java.home=/opt/homebrew/Cellar/openjdk/21.0.2/libexec/openjdk.jdk/Contents/Home jvm.arguments= offline.mode=false override.workspace.settings=true diff --git a/lib/config/environment_config.dart b/lib/Bloc/config/enviornment_config.dart similarity index 100% rename from lib/config/environment_config.dart rename to lib/Bloc/config/enviornment_config.dart diff --git a/lib/services/graphql_config.dart b/lib/Bloc/config/graphql_config.dart similarity index 90% rename from lib/services/graphql_config.dart rename to lib/Bloc/config/graphql_config.dart index 6bae32cb..12f52964 100644 --- a/lib/services/graphql_config.dart +++ b/lib/Bloc/config/graphql_config.dart @@ -1,6 +1,4 @@ -import 'dart:developer'; - -import 'package:beacon/config/environment_config.dart'; +import 'package:beacon/Bloc/config/enviornment_config.dart'; import 'package:beacon/locator.dart'; import 'package:graphql_flutter/graphql_flutter.dart'; @@ -28,8 +26,6 @@ class GraphQLConfig { } GraphQLClient clientToQuery() { - log(httpLink.toString()); - log(EnvironmentConfig.httpEndpoint!); return GraphQLClient( cache: GraphQLCache(), // cache: GraphQLCache(partialDataPolicy: PartialDataCachePolicy.accept), diff --git a/lib/queries/auth.dart b/lib/Bloc/core/queries/auth.dart similarity index 100% rename from lib/queries/auth.dart rename to lib/Bloc/core/queries/auth.dart diff --git a/lib/queries/beacon.dart b/lib/Bloc/core/queries/beacon.dart similarity index 100% rename from lib/queries/beacon.dart rename to lib/Bloc/core/queries/beacon.dart diff --git a/lib/queries/group.dart b/lib/Bloc/core/queries/group.dart similarity index 100% rename from lib/queries/group.dart rename to lib/Bloc/core/queries/group.dart diff --git a/lib/Bloc/core/resources/data_state.dart b/lib/Bloc/core/resources/data_state.dart new file mode 100644 index 00000000..a330e545 --- /dev/null +++ b/lib/Bloc/core/resources/data_state.dart @@ -0,0 +1,16 @@ +import 'package:graphql/client.dart'; + +abstract class DataState { + final T? data; + final OperationException? error; + + const DataState({this.data, this.error}); +} + +class DataSuccess extends DataState { + const DataSuccess(T data) : super(data: data); +} + +class DataFailed extends DataState { + const DataFailed(OperationException error) : super(error: error); +} diff --git a/lib/Bloc/core/services/shared_prefrence_service.dart b/lib/Bloc/core/services/shared_prefrence_service.dart new file mode 100644 index 00000000..449a9e13 --- /dev/null +++ b/lib/Bloc/core/services/shared_prefrence_service.dart @@ -0,0 +1,40 @@ +import 'package:flutter/material.dart'; +import 'package:shared_preferences/shared_preferences.dart'; + +class SharedPreferencesService { + SharedPreferenceService() { + init(); + } + + late SharedPreferences _prefs; + + init() async { + _prefs = await SharedPreferences.getInstance(); + } + + Future saveData(String key, dynamic value) async { + try { + if (value is String) { + await _prefs.setString(key, value); + } else if (value is int) { + await _prefs.setInt(key, value); + } else if (value is bool) { + await _prefs.setBool(key, value); + } else if (value is double) { + await _prefs.setDouble(key, value); + } else if (value is List) { + await _prefs.setStringList(key, value); + } + } catch (e) { + debugPrint(e.toString()); + } + } + + Future loadData(String key) async { + return _prefs.get(key); + } + + Future deleteData(String key) async { + return await _prefs.remove('key'); + } +} diff --git a/lib/Bloc/core/services/size_config.dart b/lib/Bloc/core/services/size_config.dart new file mode 100644 index 00000000..0dd0d64d --- /dev/null +++ b/lib/Bloc/core/services/size_config.dart @@ -0,0 +1,32 @@ +import 'package:flutter/material.dart'; + +class SizeConfig { + static late MediaQueryData _mediaQueryData; + static late double screenWidth; + static late double screenHeight; + static double? blockSizeHorizontal; + static double? blockSizeVertical; + static double? paddingTop; + + static late double _safeAreaHorizontal; + static late double _safeAreaVertical; + static double? safeBlockHorizontal; + static double? safeBlockVertical; + + void init(BuildContext context) { + _mediaQueryData = MediaQuery.of(context); + screenWidth = _mediaQueryData.size.width; + screenHeight = _mediaQueryData.size.height; + blockSizeHorizontal = screenWidth / 100; + blockSizeVertical = screenHeight / 100; + + _safeAreaHorizontal = + _mediaQueryData.padding.left + _mediaQueryData.padding.right; + _safeAreaVertical = + _mediaQueryData.padding.top + _mediaQueryData.padding.bottom; + safeBlockHorizontal = (screenWidth - _safeAreaHorizontal) / 100; + safeBlockVertical = (screenHeight - _safeAreaVertical) / 100; + debugPrint("safeBlockHorizontal: $safeBlockHorizontal"); + debugPrint("safeBlockVertical: $safeBlockVertical"); + } +} diff --git a/lib/Bloc/core/usercase/usecase.dart b/lib/Bloc/core/usercase/usecase.dart new file mode 100644 index 00000000..2d8b44d1 --- /dev/null +++ b/lib/Bloc/core/usercase/usecase.dart @@ -0,0 +1,3 @@ +abstract class UseCase { + Future call(Paramas paramas); +} diff --git a/lib/Bloc/core/utils/utils.dart b/lib/Bloc/core/utils/utils.dart new file mode 100644 index 00000000..b941e643 --- /dev/null +++ b/lib/Bloc/core/utils/utils.dart @@ -0,0 +1,78 @@ +import 'dart:developer'; +import 'package:connectivity_plus/connectivity_plus.dart'; +import 'package:flutter/material.dart'; +import 'package:graphql/client.dart'; + +class Utils { + void showSnackBar(String message, BuildContext context, + {Duration duration = const Duration(seconds: 2)}) { + ScaffoldMessenger.of(context).showSnackBar( + SnackBar( + duration: duration, + content: Text( + message, + style: TextStyle(color: Colors.black), + ), + // backgroundColor: kLightBlue.withOpacity(0.8), + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.all( + Radius.circular(10), + ), + ), + behavior: SnackBarBehavior.floating, + elevation: 5, + ), + ); + } + + String filterException(OperationException exception) { + // checking grapqhl exceptions + if (exception.graphqlErrors.isNotEmpty) { + return exception.graphqlErrors.first.message; + } + // checking link exception + else if (exception.linkException != null) { + log('Link Exception: ${exception.linkException!.originalStackTrace}'); + return 'Server exception'; + } else { + return 'Network Error: The request could not be completed.'; + } + } + + Future checkInternetConnectivity() async { + final connectivityResult = await (Connectivity().checkConnectivity()); + + if (connectivityResult == ConnectivityResult.mobile || + connectivityResult == ConnectivityResult.wifi || + connectivityResult == ConnectivityResult.ethernet) { + return true; + } + return false; + } + + String? validateEmail(String? value) { + final emailRegex = RegExp(r'^[\w-\.]+@([\w-]+\.)+[\w-]{2,4}$'); + if (value == null || value.isEmpty) { + return 'Email address is required'; + } else if (!emailRegex.hasMatch(value)) { + return 'Enter a valid email address'; + } + return null; // Return null if the email is valid + } + + String? validatePassword(String? value) { + if (value == null || value.isEmpty) { + return 'Password is required'; + } else if (value.length < 8) { + return '8-digit password is required'; + } + return null; + } + + String? validateName(String? value) { + if (value == null || value.isEmpty) { + return 'Name is required'; + } + return null; + } +} diff --git a/lib/Bloc/theme/theme.dart b/lib/Bloc/theme/theme.dart new file mode 100644 index 00000000..a57f4de5 --- /dev/null +++ b/lib/Bloc/theme/theme.dart @@ -0,0 +1,46 @@ +import 'package:flutter/material.dart'; + +class CustomTheme { + static const String _fontFamily = + 'FuturaBold'; // Match the name in pubspec.yaml + + // Define your custom colors + Color kYellow = Color(0xFFFDBB2C); + Color kBlue = Color(0xFF222375); + Color lightkBlue = Color(0xFF535393); + Color kLightBlue = Color(0xFFE8F1F8); + Color kBlack = Color(0xFF343434); + Color shimmerSkeletonColor = Color(0xff4e4f91); + Color hintColor = Colors.black54; + + // Define your custom theme data + ThemeData myTheme = ThemeData( + fontFamily: _fontFamily, + // Define primary colors + primaryColor: const Color(0xFF222375), + hintColor: const Color.fromARGB(255, 105, 103, 103), + + // Define text themes + textTheme: const TextTheme( + displayLarge: TextStyle( + fontSize: 19, + fontWeight: FontWeight.bold, + fontFamily: _fontFamily, + color: Colors.white, + ), + displayMedium: TextStyle( + fontSize: 16, + fontWeight: FontWeight.w800, + fontFamily: _fontFamily, + color: Colors.black, + ), + bodyLarge: TextStyle( + fontSize: 16, + fontFamily: _fontFamily, + color: Colors.white, + ), + ), + + // Define other theme properties such as fonts, buttons, etc. + ); +} diff --git a/lib/locator.dart b/lib/locator.dart index 5d5f5d05..2073c85c 100644 --- a/lib/locator.dart +++ b/lib/locator.dart @@ -1,15 +1,16 @@ import 'package:beacon/main.dart'; -import 'package:beacon/services/connection_checker.dart'; -import 'package:beacon/services/database_mutation_functions.dart'; -import 'package:beacon/services/graphql_config.dart'; -import 'package:beacon/services/hive_localdb.dart'; -import 'package:beacon/services/local_notification.dart'; -import 'package:beacon/services/navigation_service.dart'; -import 'package:beacon/services/user_config.dart'; -import 'package:beacon/view_model/auth_screen_model.dart'; -import 'package:beacon/view_model/home_screen_view_model.dart'; -import 'package:beacon/view_model/hike_screen_model.dart'; -import 'package:beacon/view_model/group_screen_view_model.dart'; +import 'package:beacon/old/components/services/connection_checker.dart'; +import 'package:beacon/old/components/services/database_mutation_functions.dart'; +import 'package:beacon/Bloc/config/graphql_config.dart'; +import 'package:beacon/old/components/services/hive_localdb.dart'; +import 'package:beacon/old/components/services/local_notification.dart'; +import 'package:beacon/old/components/services/navigation_service.dart'; +import 'package:beacon/old/components/services/shared_preference_service.dart'; +import 'package:beacon/old/components/services/user_config.dart'; +import 'package:beacon/old/components/view_model/auth_screen_model.dart'; +import 'package:beacon/old/components/view_model/home_screen_view_model.dart'; +import 'package:beacon/old/components/view_model/hike_screen_model.dart'; +import 'package:beacon/old/components/view_model/group_screen_view_model.dart'; import 'package:get_it/get_it.dart'; GetIt locator = GetIt.instance; @@ -21,8 +22,12 @@ final GraphQLConfig? graphqlConfig = locator(); final LocalNotification? localNotif = locator(); final HiveLocalDb? hiveDb = locator(); final ConnectionChecker? connectionChecker = locator(); +final sharedPrefrenceService = locator(); void setupLocator() { + // shared prefrence services + locator.registerSingleton(SharedPreferenceService()); + //services locator.registerSingleton(NavigationService()); diff --git a/lib/main.dart b/lib/main.dart index a2e05ed1..1be083dd 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -1,8 +1,8 @@ -import 'package:beacon/config/environment_config.dart'; +import 'package:beacon/Bloc/config/enviornment_config.dart'; import 'package:beacon/locator.dart'; import 'package:beacon/router.dart' as router; -import 'package:beacon/view_model/base_view_model.dart'; -import 'package:beacon/views/base_view.dart'; +import 'package:beacon/old/components/view_model/base_view_model.dart'; +import 'package:beacon/old/components/views/base_view.dart'; import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; import 'package:sizer/sizer.dart'; @@ -16,6 +16,7 @@ void main() async { DeviceOrientation.portraitDown, ]); setupLocator(); + await localNotif!.initialize(); await hiveDb!.init(); runApp( diff --git a/lib/components/active_beacon.dart b/lib/old/components/active_beacon.dart similarity index 100% rename from lib/components/active_beacon.dart rename to lib/old/components/active_beacon.dart diff --git a/lib/components/beacon_card.dart b/lib/old/components/beacon_card.dart similarity index 95% rename from lib/components/beacon_card.dart rename to lib/old/components/beacon_card.dart index 3e529faf..6bed349d 100644 --- a/lib/components/beacon_card.dart +++ b/lib/old/components/beacon_card.dart @@ -1,9 +1,9 @@ -import 'package:beacon/components/active_beacon.dart'; -import 'package:beacon/components/timer.dart'; +import 'package:beacon/old/components/active_beacon.dart'; +import 'package:beacon/old/components/timer.dart'; import 'package:beacon/locator.dart'; -import 'package:beacon/models/beacon/beacon.dart'; -import 'package:beacon/utilities/constants.dart'; -import 'package:beacon/views/hike_screen.dart'; +import 'package:beacon/old/components/models/beacon/beacon.dart'; +import 'package:beacon/old/components/utilities/constants.dart'; +import 'package:beacon/old/components/views/hike_screen.dart'; import 'package:flutter/material.dart'; import 'package:sizer/sizer.dart'; import 'package:skeleton_text/skeleton_text.dart'; @@ -32,9 +32,9 @@ class BeaconCustomWidgets { } } if (!hasStarted) { - navigationService!.showSnackBar( - 'Beacon has not yet started! \nPlease come back at ${DateFormat("hh:mm a, d/M/y").format(DateTime.fromMillisecondsSinceEpoch(beacon.startsAt!)).toString()}', - ); + // navigationService!.showSnackBar( + // 'Beacon has not yet started! \nPlease come back at ${DateFormat("hh:mm a, d/M/y").format(DateTime.fromMillisecondsSinceEpoch(beacon.startsAt!)).toString()}', + // ); return; } if (hasStarted && @@ -49,9 +49,9 @@ class BeaconCustomWidgets { final Beacon? _beacon = await databaseFunctions!.joinBeacon(beacon.shortcode); if (!hasStarted) { - navigationService!.showSnackBar( - 'Beacon has not yet started! \nPlease come back at ${DateFormat("hh:mm a, d/M/y").format(DateTime.fromMillisecondsSinceEpoch(beacon.startsAt!)).toString()}', - ); + // navigationService!.showSnackBar( + // 'Beacon has not yet started! \nPlease come back at ${DateFormat("hh:mm a, d/M/y").format(DateTime.fromMillisecondsSinceEpoch(beacon.startsAt!)).toString()}', + // ); return; } if (hasStarted && _beacon != null) { diff --git a/lib/components/create_join_dialog.dart b/lib/old/components/create_join_dialog.dart similarity index 97% rename from lib/components/create_join_dialog.dart rename to lib/old/components/create_join_dialog.dart index 2ba18179..25e7bc4d 100644 --- a/lib/components/create_join_dialog.dart +++ b/lib/old/components/create_join_dialog.dart @@ -1,13 +1,12 @@ -import 'package:beacon/locator.dart'; -import 'package:beacon/services/validators.dart'; -import 'package:beacon/components/hike_button.dart'; -import 'package:beacon/utilities/constants.dart'; -import 'package:beacon/view_model/group_screen_view_model.dart'; +import 'package:beacon/old/components/services/validators.dart'; +import 'package:beacon/old/components/hike_button.dart'; +import 'package:beacon/old/components/utilities/constants.dart'; +import 'package:beacon/old/components/view_model/group_screen_view_model.dart'; import 'package:duration_picker/duration_picker.dart'; import 'package:flutter/material.dart'; import 'package:sizer/sizer.dart'; -import '../view_model/home_screen_view_model.dart'; +import 'view_model/home_screen_view_model.dart'; class CreateJoinGroupDialog { static Future createGroupDialog(BuildContext context, HomeViewModel model) { @@ -409,8 +408,8 @@ class CreateJoinBeaconDialog { // navigationService.pop(); if (model.startingdate == null || model.startingTime == null) { - navigationService! - .showSnackBar("Enter date and time"); + // navigationService! + // .showSnackBar("Enter date and time"); return; } model.startsAt = DateTime( @@ -422,8 +421,8 @@ class CreateJoinBeaconDialog { ); // localNotif.scheduleNotification(); if (model.startsAt.isBefore(DateTime.now())) { - navigationService!.showSnackBar( - "Enter a valid date and time!!"); + // navigationService!.showSnackBar( + // "Enter a valid date and time!!"); return; } model.createHikeRoom(groupID, reloadList); diff --git a/lib/components/dialog_boxes.dart b/lib/old/components/dialog_boxes.dart similarity index 95% rename from lib/components/dialog_boxes.dart rename to lib/old/components/dialog_boxes.dart index 748ec17f..afd4d771 100644 --- a/lib/components/dialog_boxes.dart +++ b/lib/old/components/dialog_boxes.dart @@ -1,5 +1,5 @@ -import 'package:beacon/components/hike_button.dart'; -import 'package:beacon/utilities/constants.dart'; +import 'package:beacon/old/components/hike_button.dart'; +import 'package:beacon/old/components/utilities/constants.dart'; import 'package:flutter/material.dart'; import 'package:sizer/sizer.dart'; @@ -35,7 +35,7 @@ class DialogBoxes { buttonHeight: 2.5.h, buttonWidth: 8.w, onTap: () => Navigator.of(context).pop(true), - // TODO + // // onTap: () { // navigationService.removeAllAndPush('/groupScreen', '/', // arguments: GroupScreen( diff --git a/lib/enums/view_state.dart b/lib/old/components/enums/view_state.dart similarity index 100% rename from lib/enums/view_state.dart rename to lib/old/components/enums/view_state.dart diff --git a/lib/components/group_card.dart b/lib/old/components/group_card.dart similarity index 97% rename from lib/components/group_card.dart rename to lib/old/components/group_card.dart index db0f62be..b79c677b 100644 --- a/lib/components/group_card.dart +++ b/lib/old/components/group_card.dart @@ -1,11 +1,11 @@ import 'package:beacon/locator.dart'; -import 'package:beacon/utilities/constants.dart'; +import 'package:beacon/old/components/utilities/constants.dart'; import 'package:flutter/material.dart'; import 'package:sizer/sizer.dart'; import 'package:skeleton_text/skeleton_text.dart'; -import '../models/group/group.dart'; -import '../views/group_screen.dart'; +import 'models/group/group.dart'; +import 'views/group_screen.dart'; class GroupCustomWidgets { static final Color textColor = Color(0xFFAFAFAF); diff --git a/lib/components/hike_button.dart b/lib/old/components/hike_button.dart similarity index 94% rename from lib/components/hike_button.dart rename to lib/old/components/hike_button.dart index 5363ec97..9cebe747 100644 --- a/lib/components/hike_button.dart +++ b/lib/old/components/hike_button.dart @@ -1,4 +1,4 @@ -import 'package:beacon/utilities/constants.dart'; +import 'package:beacon/old/components/utilities/constants.dart'; import 'package:flutter/material.dart'; class HikeButton extends StatelessWidget { diff --git a/lib/components/hike_screen_widget.dart b/lib/old/components/hike_screen_widget.dart similarity index 95% rename from lib/components/hike_screen_widget.dart rename to lib/old/components/hike_screen_widget.dart index b7efefb3..50d7aaa3 100644 --- a/lib/components/hike_screen_widget.dart +++ b/lib/old/components/hike_screen_widget.dart @@ -1,10 +1,10 @@ import 'dart:async'; import 'dart:io'; -import 'package:beacon/components/hike_button.dart'; +import 'package:beacon/old/components/hike_button.dart'; import 'package:beacon/locator.dart'; -import 'package:beacon/models/beacon/beacon.dart'; -import 'package:beacon/utilities/constants.dart'; -import 'package:beacon/view_model/hike_screen_model.dart'; +import 'package:beacon/old/components/models/beacon/beacon.dart'; +import 'package:beacon/old/components/utilities/constants.dart'; +import 'package:beacon/old/components/view_model/hike_screen_model.dart'; import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; import 'package:flutter_geocoder_alternative/flutter_geocoder_alternative.dart'; @@ -112,8 +112,8 @@ class HikeScreenWidget extends ChangeNotifier { // sanity check. if (googleMapControllerCompleter.isCompleted == false) return; if (!await connectionChecker!.checkForInternetConnection()) { - navigationService!.showSnackBar( - 'Cannot share the route, please check your internet connection.'); + // navigationService!.showSnackBar( + // 'Cannot share the route, please check your internet connection.'); return; } //show marker description so that image will be more usefull. @@ -239,8 +239,8 @@ class HikeScreenWidget extends ChangeNotifier { ? Fluttertoast.showToast( msg: 'Only beacon holder has access to change the duration') - //TODO: enable this once backend has updated. - //Commented, since we dont have the neccessary mutation atm on backend to change the duration. + // todo enable this once backend has updated. + // Commented, since we dont have the neccessary mutation atm on backend to change the duration. // : DialogBoxes.changeDurationDialog(context); : Container(); }, diff --git a/lib/components/loading_screen.dart b/lib/old/components/loading_screen.dart similarity index 96% rename from lib/components/loading_screen.dart rename to lib/old/components/loading_screen.dart index bfc930dc..a9c9a5c9 100644 --- a/lib/components/loading_screen.dart +++ b/lib/old/components/loading_screen.dart @@ -1,7 +1,7 @@ import 'package:flutter/material.dart'; import 'package:flutter_spinkit/flutter_spinkit.dart'; -import '../utilities/constants.dart'; +import 'utilities/constants.dart'; class LoadingScreen extends StatelessWidget { const LoadingScreen({Key? key}) : super(key: key); diff --git a/lib/models/beacon/beacon.dart b/lib/old/components/models/beacon/beacon.dart similarity index 91% rename from lib/models/beacon/beacon.dart rename to lib/old/components/models/beacon/beacon.dart index c177f502..af4f14d9 100644 --- a/lib/models/beacon/beacon.dart +++ b/lib/old/components/models/beacon/beacon.dart @@ -1,6 +1,6 @@ -import 'package:beacon/models/landmarks/landmark.dart'; -import 'package:beacon/models/location/location.dart'; -import 'package:beacon/models/user/user_info.dart'; +import 'package:beacon/old/components/models/landmarks/landmark.dart'; +import 'package:beacon/old/components/models/location/location.dart'; +import 'package:beacon/old/components/models/user/user_info.dart'; import 'package:flutter/material.dart'; import 'package:hive/hive.dart'; diff --git a/lib/models/beacon/beacon.g.dart b/lib/old/components/models/beacon/beacon.g.dart similarity index 94% rename from lib/models/beacon/beacon.g.dart rename to lib/old/components/models/beacon/beacon.g.dart index f6975e15..73850387 100644 --- a/lib/models/beacon/beacon.g.dart +++ b/lib/old/components/models/beacon/beacon.g.dart @@ -24,8 +24,8 @@ class BeaconAdapter extends TypeAdapter { title: fields[7] as String?, leader: fields[4] as User?, followers: (fields[5] as List?)?.cast(), - route: (fields[6] as List?)?.cast(), - landmarks: (fields[8] as List?)?.cast(), + route: (fields[6] as List?)?.cast(), + landmarks: (fields[8] as List?)?.cast(), location: fields[9] as Location?, group: fields[10] as String?, ); diff --git a/lib/models/group/group.dart b/lib/old/components/models/group/group.dart similarity index 95% rename from lib/models/group/group.dart rename to lib/old/components/models/group/group.dart index 168655af..007e3071 100644 --- a/lib/models/group/group.dart +++ b/lib/old/components/models/group/group.dart @@ -1,4 +1,4 @@ -import 'package:beacon/models/user/user_info.dart'; +import 'package:beacon/old/components/models/user/user_info.dart'; import 'package:flutter/material.dart'; import 'package:hive/hive.dart'; diff --git a/lib/models/group/group.g.dart b/lib/old/components/models/group/group.g.dart similarity index 100% rename from lib/models/group/group.g.dart rename to lib/old/components/models/group/group.g.dart diff --git a/lib/models/landmarks/landmark.dart b/lib/old/components/models/landmarks/landmark.dart similarity index 89% rename from lib/models/landmarks/landmark.dart rename to lib/old/components/models/landmarks/landmark.dart index 4f01fbde..42cd5ab7 100644 --- a/lib/models/landmarks/landmark.dart +++ b/lib/old/components/models/landmarks/landmark.dart @@ -1,4 +1,4 @@ -import 'package:beacon/models/location/location.dart'; +import 'package:beacon/old/components/models/location/location.dart'; import 'package:flutter/material.dart'; import 'package:hive/hive.dart'; part 'landmark.g.dart'; diff --git a/lib/models/landmarks/landmark.g.dart b/lib/old/components/models/landmarks/landmark.g.dart similarity index 100% rename from lib/models/landmarks/landmark.g.dart rename to lib/old/components/models/landmarks/landmark.g.dart diff --git a/lib/models/location/location.dart b/lib/old/components/models/location/location.dart similarity index 100% rename from lib/models/location/location.dart rename to lib/old/components/models/location/location.dart diff --git a/lib/models/location/location.g.dart b/lib/old/components/models/location/location.g.dart similarity index 100% rename from lib/models/location/location.g.dart rename to lib/old/components/models/location/location.g.dart diff --git a/lib/models/user/user_info.dart b/lib/old/components/models/user/user_info.dart similarity index 91% rename from lib/models/user/user_info.dart rename to lib/old/components/models/user/user_info.dart index 19af4446..70bd5cdd 100644 --- a/lib/models/user/user_info.dart +++ b/lib/old/components/models/user/user_info.dart @@ -1,6 +1,6 @@ -import 'package:beacon/models/beacon/beacon.dart'; -import 'package:beacon/models/group/group.dart'; -import 'package:beacon/models/location/location.dart'; +import 'package:beacon/old/components/models/beacon/beacon.dart'; +import 'package:beacon/old/components/models/group/group.dart'; +import 'package:beacon/old/components/models/location/location.dart'; import 'package:flutter/material.dart'; import 'package:hive/hive.dart'; part 'user_info.g.dart'; diff --git a/lib/models/user/user_info.g.dart b/lib/old/components/models/user/user_info.g.dart similarity index 100% rename from lib/models/user/user_info.g.dart rename to lib/old/components/models/user/user_info.g.dart diff --git a/lib/services/connection_checker.dart b/lib/old/components/services/connection_checker.dart similarity index 100% rename from lib/services/connection_checker.dart rename to lib/old/components/services/connection_checker.dart diff --git a/lib/services/database_mutation_functions.dart b/lib/old/components/services/database_mutation_functions.dart similarity index 87% rename from lib/services/database_mutation_functions.dart rename to lib/old/components/services/database_mutation_functions.dart index a7baeb7d..55895f83 100644 --- a/lib/services/database_mutation_functions.dart +++ b/lib/old/components/services/database_mutation_functions.dart @@ -1,18 +1,18 @@ import 'dart:async'; import 'dart:developer'; -import 'package:beacon/models/beacon/beacon.dart'; -import 'package:beacon/models/group/group.dart'; -import 'package:beacon/models/landmarks/landmark.dart'; -import 'package:beacon/models/location/location.dart'; -import 'package:beacon/queries/auth.dart'; -import 'package:beacon/queries/beacon.dart'; -import 'package:beacon/utilities/constants.dart'; +import 'package:beacon/Bloc/core/queries/auth.dart'; +import 'package:beacon/Bloc/core/queries/beacon.dart'; +import 'package:beacon/Bloc/core/queries/group.dart'; +import 'package:beacon/old/components/models/beacon/beacon.dart'; +import 'package:beacon/old/components/models/group/group.dart'; +import 'package:beacon/old/components/models/landmarks/landmark.dart'; +import 'package:beacon/old/components/models/location/location.dart'; +import 'package:beacon/old/components/utilities/constants.dart'; import 'package:flutter/material.dart'; import 'package:google_maps_flutter/google_maps_flutter.dart'; import 'package:graphql_flutter/graphql_flutter.dart'; -import 'package:beacon/models/user/user_info.dart'; -import '../locator.dart'; -import '../queries/group.dart'; +import 'package:beacon/old/components/models/user/user_info.dart'; +import '../../../locator.dart'; class DataBaseMutationFunctions { late ValueNotifier clientNonAuth; @@ -53,21 +53,21 @@ class DataBaseMutationFunctions { return true; } else if (exception.graphqlErrors[i].message == userNotFound.message) { if (showSnackBar) { - navigationService! - .showSnackBar("No account registered with this email"); + // navigationService! + // .showSnackBar("No account registered with this email"); } return false; } else if (exception.graphqlErrors[i].message == wrongCredentials.message) { if (showSnackBar) { - navigationService!.showSnackBar("Enter a valid password"); + // navigationService!.showSnackBar("Enter a valid password"); } return false; } else if (exception.graphqlErrors[i].message == emailAccountPresent.message) { if (showSnackBar) { - navigationService! - .showSnackBar("Account with this email already registered"); + // navigationService! + // .showSnackBar("Account with this email already registered"); } return false; } @@ -129,8 +129,8 @@ class DataBaseMutationFunctions { // ); if (result.hasException) { - navigationService! - .showSnackBar("${result.exception!.graphqlErrors.first.message}"); + // navigationService! + // .showSnackBar("${result.exception!.graphqlErrors.first.message}"); debugPrint('${result.exception!.graphqlErrors}'); return exceptionError; } else if (result.data != null && result.isConcrete) { @@ -153,8 +153,8 @@ class DataBaseMutationFunctions { document: gql(_authQuery.loginUser(email, password)))); log(result.exception.toString()); if (result.hasException) { - navigationService! - .showSnackBar("${result.exception!.graphqlErrors.first.message}"); + // navigationService! + // .showSnackBar("${result.exception!.graphqlErrors.first.message}"); print("${result.exception!.graphqlErrors}"); return exceptionError; } else if (result.data != null && result.isConcrete) { @@ -289,16 +289,16 @@ class DataBaseMutationFunctions { try { loc = await AppConstants.getLocation(); } catch (onErr) { - navigationService! - .showSnackBar("$onErr : Allow location access to start beacon"); + // navigationService! + // .showSnackBar("$onErr : Allow location access to start beacon"); return null; } final QueryResult result = await clientAuth.mutate(MutationOptions( document: gql(_beaconQuery.createBeacon(title, startsAt, expiresAt, loc.latitude.toString(), loc.longitude.toString(), groupID)))); if (result.hasException) { - navigationService!.showSnackBar( - "Something went wrong: ${result.exception!.graphqlErrors.first.message}"); + // navigationService!.showSnackBar( + // "Something went wrong: ${result.exception!.graphqlErrors.first.message}"); print("Something went wrong: ${result.exception}"); } else if (result.data != null && result.isConcrete) { final Beacon beacon = Beacon.fromJson( @@ -318,8 +318,8 @@ class DataBaseMutationFunctions { print( "Something went wrong: ${result.exception}", ); - navigationService!.showSnackBar( - "Something went wrong: ${result.exception!.graphqlErrors.first.message}"); + // navigationService!.showSnackBar( + // "Something went wrong: ${result.exception!.graphqlErrors.first.message}"); } else if (result.data != null && result.isConcrete) { final Location location = Location.fromJson( result.data!['updateBeaconLocation']['location'] @@ -335,8 +335,8 @@ class DataBaseMutationFunctions { final QueryResult result = await clientAuth.mutate( MutationOptions(document: gql(_beaconQuery.joinBeacon(shortcode)))); if (result.hasException) { - navigationService!.showSnackBar( - "Something went wrong: ${result.exception!.graphqlErrors.first.message}"); + // navigationService!.showSnackBar( + // "Something went wrong: ${result.exception!.graphqlErrors.first.message}"); print("Something went wrong: ${result.exception}"); navigationService!.removeAllAndPush('/main', '/'); } else if (result.data != null && result.isConcrete) { @@ -345,18 +345,18 @@ class DataBaseMutationFunctions { ); if (DateTime.fromMillisecondsSinceEpoch(beacon.expiresAt!) .isBefore(DateTime.now())) { - navigationService!.showSnackBar( - "Looks like the beacon you are trying join has expired", - ); + // navigationService!.showSnackBar( + // "Looks like the beacon you are trying join has expired", + // ); return null; } beacon.route!.add(beacon.leader!.location); hiveDb!.putBeaconInBeaconBox(beacon.id, beacon); return beacon; } else { - navigationService!.showSnackBar( - "Something went wrong while trying to join Beacon", - ); + // navigationService!.showSnackBar( + // "Something went wrong while trying to join Beacon", + // ); } return null; } @@ -369,8 +369,8 @@ class DataBaseMutationFunctions { id, loc.latitude.toString(), loc.longitude.toString(), title)))) .then((value) { if (value.hasException) { - navigationService!.showSnackBar( - "Something went wrong: ${value.exception!.graphqlErrors.first.message}"); + // navigationService!.showSnackBar( + // "Something went wrong: ${value.exception!.graphqlErrors.first.message}"); print("Something went wrong: ${value.exception}"); } else if (value.data != null && value.isConcrete) { final Landmark landmark = Landmark.fromJson( @@ -423,8 +423,8 @@ class DataBaseMutationFunctions { document: gql(_beaconQuery.changeLeader(beaconID, newLeaderID)))) .then((value) { if (value.hasException) { - navigationService!.showSnackBar( - "Something went wrong: ${value.exception!.graphqlErrors.first.message}"); + // navigationService!.showSnackBar( + // "Something went wrong: ${value.exception!.graphqlErrors.first.message}"); print("Something went wrong: ${value.exception}"); } else if (value.data != null && value.isConcrete) { final Beacon changedLeader = Beacon.fromJson( @@ -441,8 +441,8 @@ class DataBaseMutationFunctions { final QueryResult result = await clientAuth .mutate(MutationOptions(document: gql(_groupQuery.createGroup(title)))); if (result.hasException) { - navigationService!.showSnackBar( - "Something went wrong: ${result.exception!.graphqlErrors.first.message}"); + // navigationService!.showSnackBar( + // "Something went wrong: ${result.exception!.graphqlErrors.first.message}"); print("Something went wrong: ${result.exception}"); } else if (result.data != null && result.isConcrete) { final Group group = Group.fromJson( @@ -458,8 +458,8 @@ class DataBaseMutationFunctions { final QueryResult result = await clientAuth.mutate( MutationOptions(document: gql(_groupQuery.joinGroup(shortcode)))); if (result.hasException) { - navigationService!.showSnackBar( - "Something went wrong: ${result.exception!.graphqlErrors.first.message}"); + // navigationService!.showSnackBar( + // "Something went wrong: ${result.exception!.graphqlErrors.first.message}"); print("Something went wrong: ${result.exception}"); navigationService!.removeAllAndPush('/main', '/'); } else if (result.data != null && result.isConcrete) { @@ -469,9 +469,9 @@ class DataBaseMutationFunctions { // hiveDb.putBeaconInBeaconBox(beacon.id, beacon); return group; } else { - navigationService!.showSnackBar( - "Something went wrong while trying to join Group", - ); + // navigationService!.showSnackBar( + // "Something went wrong while trying to join Group", + // ); } return null; } diff --git a/lib/services/hive_localdb.dart b/lib/old/components/services/hive_localdb.dart similarity index 85% rename from lib/services/hive_localdb.dart rename to lib/old/components/services/hive_localdb.dart index d0524a9f..fadda2b0 100644 --- a/lib/services/hive_localdb.dart +++ b/lib/old/components/services/hive_localdb.dart @@ -1,8 +1,8 @@ import 'package:beacon/locator.dart'; -import 'package:beacon/models/beacon/beacon.dart'; -import 'package:beacon/models/landmarks/landmark.dart'; -import 'package:beacon/models/location/location.dart'; -import 'package:beacon/models/user/user_info.dart'; +import 'package:beacon/old/components/models/beacon/beacon.dart'; +import 'package:beacon/old/components/models/landmarks/landmark.dart'; +import 'package:beacon/old/components/models/location/location.dart'; +import 'package:beacon/old/components/models/user/user_info.dart'; import 'package:hive/hive.dart'; import 'package:path_provider/path_provider.dart' as path_provider; diff --git a/lib/services/local_notification.dart b/lib/old/components/services/local_notification.dart similarity index 96% rename from lib/services/local_notification.dart rename to lib/old/components/services/local_notification.dart index e0134ffc..835f88e7 100644 --- a/lib/services/local_notification.dart +++ b/lib/old/components/services/local_notification.dart @@ -1,6 +1,6 @@ import 'package:beacon/locator.dart'; -import 'package:beacon/models/beacon/beacon.dart'; -import 'package:beacon/views/hike_screen.dart'; +import 'package:beacon/old/components/models/beacon/beacon.dart'; +import 'package:beacon/old/components/views/hike_screen.dart'; import 'package:flutter_local_notifications/flutter_local_notifications.dart'; import 'package:timezone/timezone.dart' as tz; import 'package:timezone/data/latest.dart' as tz; diff --git a/lib/services/navigation_service.dart b/lib/old/components/services/navigation_service.dart similarity index 67% rename from lib/services/navigation_service.dart rename to lib/old/components/services/navigation_service.dart index b7e26d4c..3a21c838 100644 --- a/lib/services/navigation_service.dart +++ b/lib/old/components/services/navigation_service.dart @@ -1,4 +1,3 @@ -import 'package:beacon/utilities/constants.dart'; import 'package:flutter/material.dart'; class NavigationService { @@ -39,26 +38,26 @@ class NavigationService { }); } - void showSnackBar(String message, - {Duration duration = const Duration(seconds: 2)}) { - ScaffoldMessenger.of(navigatorKey.currentContext!).showSnackBar( - SnackBar( - duration: duration, - content: Text( - message, - style: TextStyle(color: Colors.black), - ), - backgroundColor: kLightBlue.withOpacity(0.8), - shape: RoundedRectangleBorder( - borderRadius: BorderRadius.all( - Radius.circular(10), - ), - ), - behavior: SnackBarBehavior.floating, - elevation: 5, - ), - ); - } + // void showSnackBar(String message, + // {Duration duration = const Duration(seconds: 2)}) { + // ScaffoldMessenger.of(navigatorKey.currentContext!).showSnackBar( + // SnackBar( + // duration: duration, + // content: Text( + // message, + // style: TextStyle(color: Colors.black), + // ), + // backgroundColor: kLightBlue.withOpacity(0.8), + // shape: RoundedRectangleBorder( + // borderRadius: BorderRadius.all( + // Radius.circular(10), + // ), + // ), + // behavior: SnackBarBehavior.floating, + // elevation: 5, + // ), + // ); + // } void pop() { return navigatorKey.currentState!.pop(); diff --git a/lib/services/shared_preference_service.dart b/lib/old/components/services/shared_preference_service.dart similarity index 100% rename from lib/services/shared_preference_service.dart rename to lib/old/components/services/shared_preference_service.dart diff --git a/lib/services/size_config.dart b/lib/old/components/services/size_config.dart similarity index 100% rename from lib/services/size_config.dart rename to lib/old/components/services/size_config.dart diff --git a/lib/services/user_config.dart b/lib/old/components/services/user_config.dart similarity index 87% rename from lib/services/user_config.dart rename to lib/old/components/services/user_config.dart index 13e83953..8706d372 100644 --- a/lib/services/user_config.dart +++ b/lib/old/components/services/user_config.dart @@ -1,7 +1,7 @@ import 'dart:async'; -import 'package:beacon/models/user/user_info.dart'; +import 'package:beacon/old/components/models/user/user_info.dart'; import 'package:flutter/material.dart'; -import '../locator.dart'; +import '../../../locator.dart'; class UserConfig { User? _currentUser = User(id: 'null', authToken: 'null'); @@ -23,7 +23,7 @@ class UserConfig { hiveDb!.saveUserInHive(_currentUser); userUpdated = true; } else { - navigationService!.showSnackBar("Couldn't update User details"); + // navigationService!.showSnackBar("Couldn't update User details"); userUpdated = false; } }); diff --git a/lib/services/validators.dart b/lib/old/components/services/validators.dart similarity index 100% rename from lib/services/validators.dart rename to lib/old/components/services/validators.dart diff --git a/lib/components/shape_painter.dart b/lib/old/components/shape_painter.dart similarity index 96% rename from lib/components/shape_painter.dart rename to lib/old/components/shape_painter.dart index 9b17fe4a..5c31eff5 100644 --- a/lib/components/shape_painter.dart +++ b/lib/old/components/shape_painter.dart @@ -1,5 +1,5 @@ import 'package:flutter/cupertino.dart'; -import '../utilities/constants.dart'; +import 'utilities/constants.dart'; class ShapePainter extends CustomPainter { @override diff --git a/lib/components/timer.dart b/lib/old/components/timer.dart similarity index 92% rename from lib/components/timer.dart rename to lib/old/components/timer.dart index 4cb4f942..a4ea073c 100644 --- a/lib/components/timer.dart +++ b/lib/old/components/timer.dart @@ -1,7 +1,7 @@ import 'package:beacon/locator.dart'; -import 'package:beacon/models/beacon/beacon.dart'; -import 'package:beacon/utilities/constants.dart'; -import 'package:beacon/views/hike_screen.dart'; +import 'package:beacon/old/components/models/beacon/beacon.dart'; +import 'package:beacon/old/components/utilities/constants.dart'; +import 'package:beacon/old/components/views/hike_screen.dart'; import 'package:flutter/material.dart'; import 'package:flutter_countdown_timer/index.dart'; diff --git a/lib/utilities/constants.dart b/lib/old/components/utilities/constants.dart similarity index 100% rename from lib/utilities/constants.dart rename to lib/old/components/utilities/constants.dart diff --git a/lib/utilities/indication_painter.dart b/lib/old/components/utilities/indication_painter.dart similarity index 95% rename from lib/utilities/indication_painter.dart rename to lib/old/components/utilities/indication_painter.dart index 17a64e48..953db2cb 100644 --- a/lib/utilities/indication_painter.dart +++ b/lib/old/components/utilities/indication_painter.dart @@ -1,6 +1,6 @@ import 'dart:math'; -import 'package:beacon/utilities/constants.dart'; +import 'package:beacon/old/components/utilities/constants.dart'; import 'package:flutter/material.dart'; class TabIndicationPainter extends CustomPainter { diff --git a/lib/view_model/auth_screen_model.dart b/lib/old/components/view_model/auth_screen_model.dart similarity index 89% rename from lib/view_model/auth_screen_model.dart rename to lib/old/components/view_model/auth_screen_model.dart index b9a67f55..33714b77 100644 --- a/lib/view_model/auth_screen_model.dart +++ b/lib/old/components/view_model/auth_screen_model.dart @@ -1,10 +1,10 @@ import 'dart:developer'; -import 'package:beacon/enums/view_state.dart'; -import 'package:beacon/utilities/constants.dart'; +import 'package:beacon/old/components/enums/view_state.dart'; +import 'package:beacon/old/components/utilities/constants.dart'; import 'package:flutter/material.dart'; import 'package:beacon/locator.dart'; -import 'package:beacon/view_model/base_view_model.dart'; +import 'package:beacon/old/components/view_model/base_view_model.dart'; class AuthViewModel extends BaseModel { final formKeySignup = GlobalKey(); @@ -58,11 +58,11 @@ class AuthViewModel extends BaseModel { navigationService!.removeAllAndPush('/auth', '/'); } else { navigationService!.removeAllAndPush('/auth', '/'); - navigationService!.showSnackBar('Something went wrong'); + // navigationService!.showSnackBar('Something went wrong'); } setState(ViewState.idle); } else { - navigationService!.showSnackBar('Enter valid entries'); + // navigationService!.showSnackBar('Enter valid entries'); } } @@ -76,7 +76,7 @@ class AuthViewModel extends BaseModel { navigationService!.removeAllAndPush('/main', '/'); } else { navigationService!.removeAllAndPush('/auth', '/'); - navigationService!.showSnackBar('Something went wrong'); + // navigationService!.showSnackBar('Something went wrong'); } setState(ViewState.idle); } @@ -98,11 +98,11 @@ class AuthViewModel extends BaseModel { navigationService!.removeAllAndPush('/auth', '/'); } else { navigationService!.removeAllAndPush('/auth', '/'); - navigationService!.showSnackBar('Something went wrong'); + // navigationService!.showSnackBar('Something went wrong'); } setState(ViewState.idle); } else { - navigationService!.showSnackBar('Enter valid entries'); + // navigationService!.showSnackBar('Enter valid entries'); } } diff --git a/lib/view_model/base_view_model.dart b/lib/old/components/view_model/base_view_model.dart similarity index 82% rename from lib/view_model/base_view_model.dart rename to lib/old/components/view_model/base_view_model.dart index d0b66cb8..42acc5c9 100644 --- a/lib/view_model/base_view_model.dart +++ b/lib/old/components/view_model/base_view_model.dart @@ -1,5 +1,5 @@ import 'package:flutter/material.dart'; -import 'package:beacon/enums/view_state.dart'; +import 'package:beacon/old/components/enums/view_state.dart'; class BaseModel extends ChangeNotifier { ViewState _state = ViewState.idle; diff --git a/lib/view_model/group_screen_view_model.dart b/lib/old/components/view_model/group_screen_view_model.dart similarity index 81% rename from lib/view_model/group_screen_view_model.dart rename to lib/old/components/view_model/group_screen_view_model.dart index 9d4a1504..9951dc10 100644 --- a/lib/view_model/group_screen_view_model.dart +++ b/lib/old/components/view_model/group_screen_view_model.dart @@ -1,10 +1,9 @@ -import 'package:beacon/enums/view_state.dart'; +import 'package:beacon/old/components/enums/view_state.dart'; import 'package:beacon/locator.dart'; -import 'package:beacon/models/beacon/beacon.dart'; -import 'package:beacon/view_model/base_view_model.dart'; -import 'package:beacon/views/hike_screen.dart'; +import 'package:beacon/old/components/models/beacon/beacon.dart'; +import 'package:beacon/old/components/view_model/base_view_model.dart'; +import 'package:beacon/old/components/views/hike_screen.dart'; import 'package:flutter/material.dart'; -import 'package:intl/intl.dart'; class GroupViewModel extends BaseModel { final formKeyCreate = GlobalKey(); @@ -52,9 +51,9 @@ class GroupViewModel extends BaseModel { localNotif!.scheduleNotification(beacon); setState(ViewState.idle); reloadList(); - navigationService!.showSnackBar( - 'Beacon has not yet started! \nPlease come back at ${DateFormat("hh:mm a, d/M/y").format(DateTime.fromMillisecondsSinceEpoch(beacon.startsAt!)).toString()}', - ); + // navigationService!.showSnackBar( + // 'Beacon has not yet started! \nPlease come back at ${DateFormat("hh:mm a, d/M/y").format(DateTime.fromMillisecondsSinceEpoch(beacon.startsAt!)).toString()}', + // ); return; } } else { @@ -85,9 +84,9 @@ class GroupViewModel extends BaseModel { localNotif!.scheduleNotification(beacon); setState(ViewState.idle); reloadList(); - navigationService!.showSnackBar( - 'Beacon has not yet started! \nPlease come back at ${DateFormat("hh:mm a, d/M/y").format(DateTime.fromMillisecondsSinceEpoch(beacon.startsAt!)).toString()}', - ); + // navigationService!.showSnackBar( + // 'Beacon has not yet started! \nPlease come back at ${DateFormat("hh:mm a, d/M/y").format(DateTime.fromMillisecondsSinceEpoch(beacon.startsAt!)).toString()}', + // ); return; } } else { @@ -96,7 +95,7 @@ class GroupViewModel extends BaseModel { } //Snackbar is displayed by joinBeacon itself on any error or trying to join expired beacon. } else { - navigationService!.showSnackBar('Enter Valid Passkey'); + // navigationService!.showSnackBar('Enter Valid Passkey'); } } diff --git a/lib/view_model/hike_screen_model.dart b/lib/old/components/view_model/hike_screen_model.dart similarity index 95% rename from lib/view_model/hike_screen_model.dart rename to lib/old/components/view_model/hike_screen_model.dart index bf9c07f6..81f6364c 100644 --- a/lib/view_model/hike_screen_model.dart +++ b/lib/old/components/view_model/hike_screen_model.dart @@ -1,22 +1,22 @@ import 'dart:async'; - -import 'package:beacon/components/dialog_boxes.dart'; -import 'package:beacon/config/environment_config.dart'; +import 'package:beacon/Bloc/core/queries/beacon.dart'; +import 'package:beacon/old/components/dialog_boxes.dart'; +import 'package:beacon/Bloc/config/enviornment_config.dart'; import 'package:beacon/locator.dart'; -import 'package:beacon/queries/beacon.dart'; -import 'package:beacon/services/graphql_config.dart'; -import 'package:beacon/utilities/constants.dart'; +import 'package:beacon/Bloc/config/graphql_config.dart'; +import 'package:beacon/old/components/utilities/constants.dart'; import 'package:flutter/material.dart'; import 'package:flutter_animarker/core/ripple_marker.dart'; import 'package:flutter_geocoder_alternative/flutter_geocoder_alternative.dart'; import 'package:flutter_polyline_points/flutter_polyline_points.dart'; import 'package:fluttertoast/fluttertoast.dart'; import 'package:google_maps_flutter/google_maps_flutter.dart'; -import 'package:beacon/enums/view_state.dart'; -import 'package:beacon/models/beacon/beacon.dart'; -import 'package:beacon/models/location/location.dart' deferred as locModel; -import 'package:beacon/models/user/user_info.dart'; -import 'package:beacon/view_model/base_view_model.dart'; +import 'package:beacon/old/components/enums/view_state.dart'; +import 'package:beacon/old/components/models/beacon/beacon.dart'; +import 'package:beacon/old/components/models/location/location.dart' + deferred as locModel; +import 'package:beacon/old/components/models/user/user_info.dart'; +import 'package:beacon/old/components/view_model/base_view_model.dart'; import 'package:graphql_flutter/graphql_flutter.dart'; import 'package:overlay_support/overlay_support.dart'; import 'package:share_plus/share_plus.dart'; diff --git a/lib/view_model/home_screen_view_model.dart b/lib/old/components/view_model/home_screen_view_model.dart similarity index 88% rename from lib/view_model/home_screen_view_model.dart rename to lib/old/components/view_model/home_screen_view_model.dart index 8018f112..7b769f48 100644 --- a/lib/view_model/home_screen_view_model.dart +++ b/lib/old/components/view_model/home_screen_view_model.dart @@ -1,6 +1,6 @@ -import 'package:beacon/enums/view_state.dart'; +import 'package:beacon/old/components/enums/view_state.dart'; import 'package:beacon/locator.dart'; -import 'package:beacon/view_model/base_view_model.dart'; +import 'package:beacon/old/components/view_model/base_view_model.dart'; import 'package:flutter/material.dart'; import '../models/group/group.dart'; @@ -32,7 +32,7 @@ class HomeViewModel extends BaseModel { )); } } else { - navigationService!.showSnackBar('Something went wrong'); + // navigationService!.showSnackBar('Something went wrong'); setState(ViewState.idle); } } @@ -57,7 +57,7 @@ class HomeViewModel extends BaseModel { } //Snackbar is displayed by joinBeacon itself on any error or trying to join expired beacon. } else { - navigationService!.showSnackBar('Enter Valid Group Code'); + // navigationService!.showSnackBar('Enter Valid Group Code'); } } diff --git a/lib/views/auth_screen.dart b/lib/old/components/views/auth_screen.dart similarity index 96% rename from lib/views/auth_screen.dart rename to lib/old/components/views/auth_screen.dart index 1cac5694..b91fe75c 100644 --- a/lib/views/auth_screen.dart +++ b/lib/old/components/views/auth_screen.dart @@ -1,18 +1,20 @@ -import 'package:beacon/components/hike_button.dart'; -import 'package:beacon/components/shape_painter.dart'; -import 'package:beacon/services/validators.dart'; -import 'package:beacon/utilities/constants.dart'; -import 'package:beacon/utilities/indication_painter.dart'; -import 'package:beacon/view_model/auth_screen_model.dart'; -import 'package:beacon/views/base_view.dart'; +import 'package:auto_route/auto_route.dart'; +import 'package:beacon/old/components/hike_button.dart'; +import 'package:beacon/old/components/shape_painter.dart'; +import 'package:beacon/old/components/services/validators.dart'; +import 'package:beacon/old/components/utilities/constants.dart'; +import 'package:beacon/old/components/utilities/indication_painter.dart'; +import 'package:beacon/old/components/view_model/auth_screen_model.dart'; +import 'package:beacon/old/components/views/base_view.dart'; import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; import 'package:sizer/sizer.dart'; -import '../components/loading_screen.dart'; +import '../loading_screen.dart'; +@RoutePage() class AuthScreen extends StatefulWidget { - const AuthScreen({Key? key}) : super(key: key); + const AuthScreen({super.key}); @override _AuthScreenState createState() => _AuthScreenState(); diff --git a/lib/views/base_view.dart b/lib/old/components/views/base_view.dart similarity index 100% rename from lib/views/base_view.dart rename to lib/old/components/views/base_view.dart diff --git a/lib/views/group_screen.dart b/lib/old/components/views/group_screen.dart similarity index 96% rename from lib/views/group_screen.dart rename to lib/old/components/views/group_screen.dart index fa0d36ec..fecb5b64 100644 --- a/lib/views/group_screen.dart +++ b/lib/old/components/views/group_screen.dart @@ -1,18 +1,20 @@ -import 'package:beacon/components/beacon_card.dart'; -import 'package:beacon/components/create_join_dialog.dart'; -import 'package:beacon/components/hike_button.dart'; -import 'package:beacon/components/loading_screen.dart'; -import 'package:beacon/components/shape_painter.dart'; +import 'package:auto_route/auto_route.dart'; +import 'package:beacon/old/components/beacon_card.dart'; +import 'package:beacon/old/components/create_join_dialog.dart'; +import 'package:beacon/old/components/hike_button.dart'; +import 'package:beacon/old/components/loading_screen.dart'; +import 'package:beacon/old/components/shape_painter.dart'; import 'package:beacon/locator.dart'; -import 'package:beacon/models/beacon/beacon.dart'; -import 'package:beacon/utilities/constants.dart'; -import 'package:beacon/view_model/group_screen_view_model.dart'; -import 'package:beacon/views/base_view.dart'; +import 'package:beacon/old/components/models/beacon/beacon.dart'; +import 'package:beacon/old/components/utilities/constants.dart'; +import 'package:beacon/old/components/view_model/group_screen_view_model.dart'; +import 'package:beacon/old/components/views/base_view.dart'; import 'package:flutter/material.dart'; import 'package:modal_progress_hud_nsn/modal_progress_hud_nsn.dart'; import 'package:sizer/sizer.dart'; import '../models/group/group.dart'; +@RoutePage() class GroupScreen extends StatefulWidget { final Group group; GroupScreen(this.group); @@ -158,8 +160,8 @@ class _GroupScreenState extends State buttonColor: kYellow, onTap: () { if (userConfig!.currentUser!.isGuest!) { - navigationService!.showSnackBar( - 'You need to login with credentials to start a hike'); + // navigationService!.showSnackBar( + // 'You need to login with credentials to start a hike'); } else { CreateJoinBeaconDialog.createHikeDialog( context, diff --git a/lib/views/hike_screen.dart b/lib/old/components/views/hike_screen.dart similarity index 95% rename from lib/views/hike_screen.dart rename to lib/old/components/views/hike_screen.dart index 24bef382..ae3d56bd 100644 --- a/lib/views/hike_screen.dart +++ b/lib/old/components/views/hike_screen.dart @@ -1,21 +1,23 @@ -import 'package:beacon/components/loading_screen.dart'; +import 'package:auto_route/auto_route.dart'; +import 'package:beacon/old/components/loading_screen.dart'; import 'package:beacon/locator.dart'; -import 'package:beacon/view_model/hike_screen_model.dart'; -import 'package:beacon/views/base_view.dart'; +import 'package:beacon/old/components/view_model/hike_screen_model.dart'; +import 'package:beacon/old/components/views/base_view.dart'; import 'package:flutter/material.dart'; import 'package:flutter_animarker/flutter_map_marker_animation.dart'; import 'package:google_maps_flutter/google_maps_flutter.dart'; import 'package:intl/intl.dart'; -import 'package:beacon/components/hike_screen_widget.dart'; -import 'package:beacon/models/beacon/beacon.dart'; +import 'package:beacon/old/components/hike_screen_widget.dart'; +import 'package:beacon/old/components/models/beacon/beacon.dart'; -import 'package:beacon/utilities/constants.dart'; +import 'package:beacon/old/components/utilities/constants.dart'; import 'package:modal_progress_hud_nsn/modal_progress_hud_nsn.dart'; import 'package:sizer/sizer.dart'; import 'package:sliding_up_panel/sliding_up_panel.dart'; +@RoutePage() class HikeScreen extends StatefulWidget { final Beacon? beacon; final bool? isLeader; diff --git a/lib/views/home_screen.dart b/lib/old/components/views/home_screen.dart similarity index 94% rename from lib/views/home_screen.dart rename to lib/old/components/views/home_screen.dart index cb10fa7b..499cd63b 100644 --- a/lib/views/home_screen.dart +++ b/lib/old/components/views/home_screen.dart @@ -1,28 +1,30 @@ -import 'package:beacon/components/beacon_card.dart'; -import 'package:beacon/components/create_join_dialog.dart'; -import 'package:beacon/components/hike_button.dart'; -import 'package:beacon/components/loading_screen.dart'; -import 'package:beacon/components/shape_painter.dart'; +import 'package:auto_route/auto_route.dart'; +import 'package:beacon/old/components/beacon_card.dart'; +import 'package:beacon/old/components/create_join_dialog.dart'; +import 'package:beacon/old/components/hike_button.dart'; +import 'package:beacon/old/components/loading_screen.dart'; +import 'package:beacon/old/components/shape_painter.dart'; import 'package:beacon/locator.dart'; -import 'package:beacon/models/group/group.dart'; -import 'package:beacon/utilities/constants.dart'; -import 'package:beacon/views/base_view.dart'; +import 'package:beacon/old/components/models/group/group.dart'; +import 'package:beacon/old/components/utilities/constants.dart'; +import 'package:beacon/old/components/views/base_view.dart'; import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; import 'package:modal_progress_hud_nsn/modal_progress_hud_nsn.dart'; // import 'package:modal_progress_hud/modal_progress_hud.dart'; import 'package:sizer/sizer.dart'; -import '../components/group_card.dart'; +import '../group_card.dart'; import '../view_model/home_screen_view_model.dart'; -class MainScreen extends StatefulWidget { - const MainScreen({Key? key}) : super(key: key); +@RoutePage() +class HomeScreen extends StatefulWidget { + const HomeScreen({super.key}); @override - _MainScreenState createState() => _MainScreenState(); + HomeScreenState createState() => HomeScreenState(); } -class _MainScreenState extends State with TickerProviderStateMixin { +class HomeScreenState extends State with TickerProviderStateMixin { var fetchingUserGroups; Future _onPopHome() async { return showDialog( @@ -162,8 +164,8 @@ class _MainScreenState extends State with TickerProviderStateMixin { buttonColor: kYellow, onTap: () { if (userConfig!.currentUser!.isGuest!) { - navigationService!.showSnackBar( - 'You need to login with credentials to be able to create a group'); + // navigationService!.showSnackBar( + // 'You need to login with credentials to be able to create a group'); } else { CreateJoinGroupDialog.createGroupDialog( context, model); diff --git a/lib/views/workspace.code-workspace b/lib/old/components/views/workspace.code-workspace similarity index 100% rename from lib/views/workspace.code-workspace rename to lib/old/components/views/workspace.code-workspace diff --git a/lib/router.dart b/lib/router.dart index 2d9897ca..5db844c4 100644 --- a/lib/router.dart +++ b/lib/router.dart @@ -1,10 +1,14 @@ +import 'package:auto_route/auto_route.dart'; +import 'package:beacon/old/components/models/beacon/beacon.dart'; +import 'package:beacon/old/components/models/group/group.dart'; import 'package:beacon/splash_screen.dart'; -import 'package:beacon/views/home_screen.dart'; +import 'package:beacon/old/components/views/home_screen.dart'; import 'package:flutter/material.dart'; -import 'package:beacon/utilities/constants.dart'; -import 'package:beacon/views/auth_screen.dart'; -import 'package:beacon/views/group_screen.dart'; -import 'package:beacon/views/hike_screen.dart'; +import 'package:beacon/old/components/utilities/constants.dart'; +import 'package:beacon/old/components/views/auth_screen.dart'; +import 'package:beacon/old/components/views/group_screen.dart'; +import 'package:beacon/old/components/views/hike_screen.dart'; +part 'router.gr.dart'; Route generateRoute(RouteSettings settings) { switch (settings.name) { @@ -13,7 +17,7 @@ Route generateRoute(RouteSettings settings) { builder: (context) => const AuthScreen(key: Key('auth'))); case Routes.mainScreen: return MaterialPageRoute( - builder: (context) => const MainScreen(key: Key('MainScreen'))); + builder: (context) => const HomeScreen(key: Key('MainScreen'))); case Routes.hikeScreen: HikeScreen? arguments = settings.arguments as HikeScreen?; return MaterialPageRoute( @@ -32,3 +36,15 @@ Route generateRoute(RouteSettings settings) { builder: (context) => const SplashScreen(key: Key('SplashScreen'))); } } + +@AutoRouterConfig(replaceInRouteName: 'Route') +class AppRouter extends _$AppRouter { + @override + List get routes => [ + AutoRoute(page: SplashScreenRoute.page, initial: true), + AutoRoute(page: AuthScreenRoute.page), + AutoRoute(page: HomeScreenRoute.page), + AutoRoute(page: HikeScreenRoute.page), + AutoRoute(page: GroupScreenRoute.page), + ]; +} diff --git a/lib/router.gr.dart b/lib/router.gr.dart new file mode 100644 index 00000000..cb88f991 --- /dev/null +++ b/lib/router.gr.dart @@ -0,0 +1,163 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +// ************************************************************************** +// AutoRouterGenerator +// ************************************************************************** + +// ignore_for_file: type=lint +// coverage:ignore-file + +part of 'router.dart'; + +abstract class _$AppRouter extends RootStackRouter { + // ignore: unused_element + _$AppRouter({super.navigatorKey}); + + @override + final Map pagesMap = { + AuthScreenRoute.name: (routeData) { + return AutoRoutePage( + routeData: routeData, + child: const AuthScreen(), + ); + }, + GroupScreenRoute.name: (routeData) { + final args = routeData.argsAs(); + return AutoRoutePage( + routeData: routeData, + child: GroupScreen(args.group), + ); + }, + HikeScreenRoute.name: (routeData) { + final args = routeData.argsAs(); + return AutoRoutePage( + routeData: routeData, + child: HikeScreen( + args.beacon, + isLeader: args.isLeader, + ), + ); + }, + HomeScreenRoute.name: (routeData) { + return AutoRoutePage( + routeData: routeData, + child: const HomeScreen(), + ); + }, + SplashScreenRoute.name: (routeData) { + return AutoRoutePage( + routeData: routeData, + child: const SplashScreen(), + ); + }, + }; +} + +/// generated route for +/// [AuthScreen] +class AuthScreenRoute extends PageRouteInfo { + const AuthScreenRoute({List? children}) + : super( + AuthScreenRoute.name, + initialChildren: children, + ); + + static const String name = 'AuthScreenRoute'; + + static const PageInfo page = PageInfo(name); +} + +/// generated route for +/// [GroupScreen] +class GroupScreenRoute extends PageRouteInfo { + GroupScreenRoute({ + required Group group, + List? children, + }) : super( + GroupScreenRoute.name, + args: GroupScreenRouteArgs(group: group), + initialChildren: children, + ); + + static const String name = 'GroupScreenRoute'; + + static const PageInfo page = + PageInfo(name); +} + +class GroupScreenRouteArgs { + const GroupScreenRouteArgs({required this.group}); + + final Group group; + + @override + String toString() { + return 'GroupScreenRouteArgs{group: $group}'; + } +} + +/// generated route for +/// [HikeScreen] +class HikeScreenRoute extends PageRouteInfo { + HikeScreenRoute({ + required Beacon? beacon, + bool? isLeader, + List? children, + }) : super( + HikeScreenRoute.name, + args: HikeScreenRouteArgs( + beacon: beacon, + isLeader: isLeader, + ), + initialChildren: children, + ); + + static const String name = 'HikeScreenRoute'; + + static const PageInfo page = + PageInfo(name); +} + +class HikeScreenRouteArgs { + const HikeScreenRouteArgs({ + required this.beacon, + this.isLeader, + }); + + final Beacon? beacon; + + final bool? isLeader; + + @override + String toString() { + return 'HikeScreenRouteArgs{beacon: $beacon, isLeader: $isLeader}'; + } +} + +/// generated route for +/// [HomeScreen] +class HomeScreenRoute extends PageRouteInfo { + const HomeScreenRoute({List? children}) + : super( + HomeScreenRoute.name, + initialChildren: children, + ); + + static const String name = 'HomeScreenRoute'; + + static const PageInfo page = PageInfo(name); +} + +/// generated route for +/// [SplashScreen] +class SplashScreenRoute extends PageRouteInfo { + const SplashScreenRoute({List? children}) + : super( + SplashScreenRoute.name, + initialChildren: children, + ); + + static const String name = 'SplashScreenRoute'; + + static const PageInfo page = PageInfo(name); +} diff --git a/lib/splash_screen.dart b/lib/splash_screen.dart index 6487615a..1159d979 100644 --- a/lib/splash_screen.dart +++ b/lib/splash_screen.dart @@ -1,15 +1,16 @@ import 'dart:async'; - -import 'package:beacon/views/hike_screen.dart'; +import 'package:auto_route/auto_route.dart'; +import 'package:beacon/old/components/views/hike_screen.dart'; import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; import 'package:beacon/locator.dart'; import 'package:uni_links/uni_links.dart'; -import 'components/loading_screen.dart'; +import 'old/components/loading_screen.dart'; +@RoutePage() class SplashScreen extends StatefulWidget { - const SplashScreen({required Key key}) : super(key: key); + const SplashScreen({super.key}); @override _SplashScreenState createState() => _SplashScreenState(); diff --git a/pubspec.lock b/pubspec.lock index 35424044..c866daf1 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -41,6 +41,22 @@ packages: url: "https://pub.dev" source: hosted version: "2.11.0" + auto_route: + dependency: "direct main" + description: + name: auto_route + sha256: "6cad3f408863ffff2b5757967c802b18415dac4acb1b40c5cdd45d0a26e5080f" + url: "https://pub.dev" + source: hosted + version: "8.1.3" + bloc: + dependency: "direct main" + description: + name: bloc + sha256: "106842ad6569f0b60297619e9e0b1885c2fb9bf84812935490e6c5275777804e" + url: "https://pub.dev" + source: hosted + version: "8.1.4" boolean_selector: dependency: transitive description: @@ -334,6 +350,14 @@ packages: url: "https://pub.dev" source: hosted version: "3.2.0" + flutter_bloc: + dependency: "direct main" + description: + name: flutter_bloc + sha256: f0ecf6e6eb955193ca60af2d5ca39565a86b8a142452c5b24d96fb477428f4d2 + url: "https://pub.dev" + source: hosted + version: "8.1.5" flutter_config: dependency: "direct main" description: @@ -736,6 +760,30 @@ packages: url: "https://pub.dev" source: hosted version: "4.8.1" + leak_tracker: + dependency: transitive + description: + name: leak_tracker + sha256: "78eb209deea09858f5269f5a5b02be4049535f568c07b275096836f01ea323fa" + url: "https://pub.dev" + source: hosted + version: "10.0.0" + leak_tracker_flutter_testing: + dependency: transitive + description: + name: leak_tracker_flutter_testing + sha256: b46c5e37c19120a8a01918cfaf293547f47269f7cb4b0058f21531c2465d6ef0 + url: "https://pub.dev" + source: hosted + version: "2.0.1" + leak_tracker_testing: + dependency: transitive + description: + name: leak_tracker_testing + sha256: a597f72a664dbd293f3bfc51f9ba69816f84dcd403cdac7066cb3f6003f3ab47 + url: "https://pub.dev" + source: hosted + version: "2.0.1" location: dependency: "direct main" description: @@ -772,26 +820,26 @@ packages: dependency: transitive description: name: matcher - sha256: "1803e76e6653768d64ed8ff2e1e67bea3ad4b923eb5c56a295c3e634bad5960e" + sha256: d2323aa2060500f906aa31a895b4030b6da3ebdcc5619d14ce1aada65cd161cb url: "https://pub.dev" source: hosted - version: "0.12.16" + version: "0.12.16+1" material_color_utilities: dependency: transitive description: name: material_color_utilities - sha256: "9528f2f296073ff54cb9fee677df673ace1218163c3bc7628093e7eed5203d41" + sha256: "0e0a020085b65b6083975e499759762399b4475f766c21668c4ecca34ea74e5a" url: "https://pub.dev" source: hosted - version: "0.5.0" + version: "0.8.0" meta: dependency: transitive description: name: meta - sha256: a6e590c838b18133bb482a2745ad77c5bb7715fb0451209e1a7567d416678b8e + sha256: d584fa6707a52763a52446f02cc621b077888fb63b93bbcb1143a7be5a0c0c04 url: "https://pub.dev" source: hosted - version: "1.10.0" + version: "1.11.0" mime: dependency: transitive description: @@ -868,10 +916,10 @@ packages: dependency: transitive description: name: path - sha256: "8829d8a55c13fc0e37127c29fedf290c102f4e40ae94ada574091fe0ff96c917" + sha256: "087ce49c3f0dc39180befefc60fdb4acd8f8620e5682fe2476afd0b3688bb4af" url: "https://pub.dev" source: hosted - version: "1.8.3" + version: "1.9.0" path_provider: dependency: "direct main" description: diff --git a/pubspec.yaml b/pubspec.yaml index a0aac600..3328aee7 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -42,7 +42,20 @@ dependencies: sliding_up_panel: ^2.0.0+1 uni_links: ^0.5.1 data_connection_checker_nulls: ^0.0.2 - flutter_geocoder_alternative: + flutter_geocoder_alternative: any + + # for routing + auto_route: ^8.1.1 + + + # for state management + bloc: ^8.1.4 + flutter_bloc: ^8.1.5 + + + + + dev_dependencies: build_runner: ^2.1.2 diff --git a/test/model_tests/beacon_test.dart b/test/model_tests/beacon_test.dart index 52339850..d459740c 100644 --- a/test/model_tests/beacon_test.dart +++ b/test/model_tests/beacon_test.dart @@ -1,4 +1,4 @@ -import 'package:beacon/models/beacon/beacon.dart'; +import 'package:beacon/old/components/models/beacon/beacon.dart'; import 'package:test/test.dart'; void main() { diff --git a/test/model_tests/user_test.dart b/test/model_tests/user_test.dart index 52612090..40fbfa7f 100644 --- a/test/model_tests/user_test.dart +++ b/test/model_tests/user_test.dart @@ -1,5 +1,5 @@ -import 'package:beacon/models/beacon/beacon.dart'; -import 'package:beacon/models/user/user_info.dart'; +import 'package:beacon/old/components/models/beacon/beacon.dart'; +import 'package:beacon/old/components/models/user/user_info.dart'; import 'package:test/test.dart'; void main() {