From e978e21d627a638d98084d5423ea97fc2aafb6bd Mon Sep 17 00:00:00 2001 From: Abhishek Date: Tue, 20 Feb 2024 02:16:03 +0530 Subject: [PATCH 01/12] added showName feature, list of members, ui improvements --- android/app/build.gradle | 21 +- android/app/src/main/AndroidManifest.xml | 2 +- android/app/src/main/res/values/string.xml | 1 + android/app/upload-debug.jks | Bin 0 -> 2772 bytes android/build.gradle | 1 + lib/components/beacon_card.dart | 43 +- lib/components/create_join_dialog.dart | 42 +- lib/main.dart | 9 +- lib/models/beacon/beacon.dart | 67 +-- lib/models/beacon/beacon.g.dart | 11 +- lib/queries/auth.dart | 1 - lib/queries/beacon.dart | 3 +- lib/queries/group.dart | 1 + lib/services/database_mutation_functions.dart | 45 +- lib/services/hive_localdb.dart | 25 +- lib/services/local_notification.dart | 15 +- lib/utilities/constants.dart | 16 + lib/view_model/group_screen_view_model.dart | 110 +++- lib/views/auth_screen.dart | 1 - lib/views/group_screen.dart | 485 ++++++++++-------- lib/views/hike_screen.dart | 1 + lib/views/home_screen.dart | 91 ++-- pubspec.lock | 4 +- 23 files changed, 655 insertions(+), 340 deletions(-) create mode 100644 android/app/src/main/res/values/string.xml create mode 100644 android/app/upload-debug.jks diff --git a/android/app/build.gradle b/android/app/build.gradle index 9572626d..f4292a21 100644 --- a/android/app/build.gradle +++ b/android/app/build.gradle @@ -7,7 +7,7 @@ if (localPropertiesFile.exists()) { } def flutterRoot = localProperties.getProperty('flutter.sdk') if (flutterRoot == null) { - throw new GradleException("Flutter SDK not found. Define location with flutter.sdk in the local.properties file.") + // throw new GradleException("Flutter SDK not found. Define location with flutter.sdk in the local.properties file.") } def flutterVersionCode = localProperties.getProperty('flutter.versionCode') @@ -33,6 +33,16 @@ android { main.java.srcDirs += 'src/main/kotlin' } + + signingConfigs{ + debug{ + keyAlias 'upload-debug' + keyPassword 'android' + storePassword 'android' + storeFile file('upload-debug.jks') + } + } + defaultConfig { // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html). applicationId "com.example.beacon" @@ -44,9 +54,12 @@ android { } buildTypes { - release { - // TODO: Add your own signing config for the release build. - // Signing with the debug keys for now, so `flutter run --release` works. + // release { + // // TODO: Add your own signing config for the release build. + // // Signing with the debug keys for now, so `flutter run --release` works. + // signingConfig signingConfigs.debug + // } + debug { signingConfig signingConfigs.debug } } diff --git a/android/app/src/main/AndroidManifest.xml b/android/app/src/main/AndroidManifest.xml index 4bf22ad4..1820f9f3 100644 --- a/android/app/src/main/AndroidManifest.xml +++ b/android/app/src/main/AndroidManifest.xml @@ -10,7 +10,7 @@ android:label="Beacon" android:icon="@mipmap/launcher_icon" android:usesCleartextTraffic="true"> - + 289316832965-k9d28ajkk2l4spf9n9l82c65is9b8kfu.apps.googleusercontent.com \ No newline at end of file diff --git a/android/app/upload-debug.jks b/android/app/upload-debug.jks new file mode 100644 index 0000000000000000000000000000000000000000..f0dad661f2011afb6008bd69ea8172a266236591 GIT binary patch literal 2772 zcma);XE+;*8po4Jh*cv>RIO@Jj*1=Bh}IspPSt4a&}i*FP9q0FNfkLpN{tw`s??}h zb!xIsWM1P3$p-xoow5CB4$nbjr1 z2m#gFh5%YluMYgGj2C zf!oQI5N$hQy2ils6a^y*eNHWVU*qTG4Bn(kO=9C1vZbqw=hZ|X>bDhBPKBjLbO}6W z&DffvTCF;jP?mdv;%+`jFCTyCd_x6#afI^+l!o!iN{oqNWpB?<~S~g@FN!UZ-Pdx zxrZ$uHmJC3iPX|rh@0GV#bROpev-=jkv!@69c<`sO=%~*55m$4Gt#2fGBsUvi9t53V(@m(V?>zP>74k&iJ zoaID2#SHB)=Mh-AK%+ME6S`&g?@naWzbCA!413&0HE)H=G21D@Qcch0EsIXyL==%9xD)3w_VvVgqKh1$v0sdLh$5B$L@3|n9;9l9kR9Wq7 zTX?qrf!qw!@%8F{2vw~?E9RAoG2iXA+$QVfncqjkd52NcY&o_*B2P7~WCeRp>U7VK zbUdr-K*qj$I(o9JVlquAdEKwv?ixIiS?(_yLsuQqzHZ-HTB4g^N==Y)Vo(5@Ofnz0 zj4~g`oC&C_!pqnUFq*Cde|?~tdH7@<4OOtEM1y`f*%DQ@E`U) z-6$&VFF8^1#eCE20Opqm)lW?9_(H1ZK38R5n_qxdQ=-xY%8xOaqOVjnHspi|E-jC=6 z+4@?@HKJ`vgs;c2oF0|86*btfM_gudL&auU9j+|`XDxe&y_{%T1)O4Wp4qf;O#9 z*3Ob6^SUVtW(cXDammW3a83jc2m$y5?gIP(t^f~!+^IYPZl}x(A^y+eSp_~YukD?C zo?;4W2vv2Y8d6DF5uu8}gA0Eyu`n0l!Re=n2m%653*ny$@P9=%*TKp`>pim}OX%B? z#9Pv$UAq#4qvlM@wbNA^q&{tapAw~ zLTBMrcka7RH|9Lsx+8tQ)G)6prA4}Hn-}if9bhOGn^_Kfvy}M<=TK`>*|CEFeL%~V zxrnPnEeL7S9F&wuQ55^SO{-gxNSY|%MaOXsYK8Eto?%T^6O0-iSnPw zK`AiQb2$4t16+vJ(Ku-g*rKOtg>XX0(W#+mYd~qt#B7SVHor+11LWOC7U-R_m<1_Mcz9Cg7+oTk*rE zzZx_Wk+PZt52mMY>Ypr`Qz+8TMyTmgV9h095G8-bS%-rtb-UtDnxy0A9Cb@{kMYRe z*i0)=5T-}f;}EMT!a=)da9=do+vkiAreDST)<(}L{}JSSB=GAJ+4WtbI3)RDv--|r zTSouG;KRG8p|TA0|X< zQ|nh5{$?;;YN3VHx~lb-=_t|KGcf|;d2v#hBbXM-UFIX%7c|ExDrcFH*8mhDZ$|lO zxAmq6?^nWyX0c_P;$eabLL?k&fYHmb*L$_-dzX#Ca;J8M{hR0?ae2!-1d?l&2Q%3q zWMXM78aBfug^m|r%q+40!agg?XfDU^b?ZF}OW8DK&lo1g;1)$6DVa>|WYc!%n+do1 zTV0tk&3o^1xFa60#1Dk%*^&S?mwYrfY+AB{&l4J%lh|fVvil@vN;7ZRp(?$tr$H8R zS{*5shg!Jg_mrGzXdcPF{QAWrN$&@el6o4Y1W6qJSnfr5j`eoWh4W6P?gGUor9C`c zeOC-%`JaYnuse?m#$>|EbDF3C*cnSBfAzzG-+e(R7ek%H;;^60(;m9GcN)2(X}c0h z9pw9l>d)C_mX^2|J%{0KVcVl%K9JCbba6DvXYT$E_F-TGzy%+AmXN>7hg{ge5;)dR z0`di2%yJ=qytpehj+co+oAjX~M}ibt-z=@d(m$#*%Q5k81%&V)QYQbw2~6cC(0KRpl-0sxB{(!Yyq8>(g~O)P literal 0 HcmV?d00001 diff --git a/android/build.gradle b/android/build.gradle index 9b6b7376..029bee74 100644 --- a/android/build.gradle +++ b/android/build.gradle @@ -8,6 +8,7 @@ buildscript { dependencies { classpath 'com.android.tools.build:gradle:7.1.0' classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" + classpath 'com.google.gms:google-services:4.3.8' } } diff --git a/lib/components/beacon_card.dart b/lib/components/beacon_card.dart index 3e529faf..9fb4fed5 100644 --- a/lib/components/beacon_card.dart +++ b/lib/components/beacon_card.dart @@ -12,8 +12,31 @@ import 'package:intl/intl.dart'; class BeaconCustomWidgets { static final Color textColor = Color(0xFFAFAFAF); + static Widget buildName(Beacon beacon) { + return FutureBuilder( + future: hiveDb!.getCurrentUser(), + builder: (context, snapshot) { + if (snapshot.connectionState == ConnectionState.waiting) { + return Text( + '${beacon.title} by ... ', + style: Style.titleTextStyle, + ); + } else if (snapshot.hasError || snapshot.data == null) { + return Text( + '${beacon.title} by Anonymous ', + style: Style.titleTextStyle, + ); + } + final user = snapshot.data; + return Text( + '${beacon.title} by ${user!.id == beacon.leader!.id ? beacon.leader!.name : beacon.showAdminName == true ? beacon.leader!.name : 'Anonymous'} ', + style: Style.titleTextStyle, + ); + }, + ); + } + static Widget getBeaconCard(BuildContext context, Beacon beacon) { - print(beacon.leader!.name); bool hasStarted; bool hasEnded; bool willStart; @@ -78,13 +101,7 @@ class BeaconCustomWidgets { Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ - Container( - width: 70.w, - child: Text( - '${beacon.title} by ${beacon.leader!.name} ', - style: Style.titleTextStyle, - ), - ), + Container(width: 70.w, child: buildName(beacon)), Align( alignment: Alignment.topRight, child: BlinkIcon(), @@ -134,10 +151,7 @@ class BeaconCustomWidgets { children: [ Container( width: 70.w, - child: Text( - '${beacon.title} by ${beacon.leader!.name} ', - style: Style.titleTextStyle, - ), + child: buildName(beacon), ), Align( alignment: Alignment.topRight, @@ -208,10 +222,7 @@ class BeaconCustomWidgets { children: [ Container( width: 70.w, - child: Text( - '${beacon.title} by ${beacon.leader!.name} ', - style: Style.titleTextStyle, - ), + child: buildName(beacon), ), SizedBox(height: 4.0), RichText( diff --git a/lib/components/create_join_dialog.dart b/lib/components/create_join_dialog.dart index 2ba18179..716505b7 100644 --- a/lib/components/create_join_dialog.dart +++ b/lib/components/create_join_dialog.dart @@ -5,6 +5,7 @@ import 'package:beacon/utilities/constants.dart'; import 'package:beacon/view_model/group_screen_view_model.dart'; import 'package:duration_picker/duration_picker.dart'; import 'package:flutter/material.dart'; +import 'package:provider/provider.dart'; import 'package:sizer/sizer.dart'; import '../view_model/home_screen_view_model.dart'; @@ -154,8 +155,8 @@ class CreateJoinGroupDialog { } class CreateJoinBeaconDialog { - static Future createHikeDialog(BuildContext context, GroupViewModel model, - Function reloadList, String? groupID) { + static Future createHikeDialog( + BuildContext context, GroupViewModel model, String? groupID) { bool isSmallSized = MediaQuery.of(context).size.height < 800; model.resultingDuration = Duration(minutes: 30); model.durationController = new TextEditingController(); @@ -173,7 +174,7 @@ class CreateJoinBeaconDialog { child: Form( key: model.formKeyCreate, child: Container( - height: isSmallSized ? 75.h : 65.h, + height: isSmallSized ? 85.h : 80.h, child: Padding( padding: const EdgeInsets.symmetric(horizontal: 32, vertical: 16), @@ -226,7 +227,7 @@ class CreateJoinBeaconDialog { data: ThemeData().copyWith( textTheme: Theme.of(context).textTheme, colorScheme: ColorScheme.light( - primary: kBlue, + primary: kYellow, onPrimary: Colors.white, surface: kBlue, ), @@ -397,6 +398,35 @@ class CreateJoinBeaconDialog { SizedBox( height: 2.h, ), + Container( + height: isSmallSized ? 14.h : 12.h, + width: 100.w, + child: Padding( + padding: const EdgeInsets.all(4.0), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text( + 'Show name', + style: TextStyle(fontSize: 18, color: kYellow), + ), + Consumer( + builder: (context, groupviewmodel, child) { + return Switch( + value: groupviewmodel.showName, + onChanged: (value) { + groupviewmodel.toogleShowName(value); + }); + }, + ) + ], + ), + ), + color: kLightBlue, + ), + SizedBox( + height: 2.h, + ), Flexible( flex: 2, child: HikeButton( @@ -426,7 +456,9 @@ class CreateJoinBeaconDialog { "Enter a valid date and time!!"); return; } - model.createHikeRoom(groupID, reloadList); + model.createHikeRoom( + groupID, + ); }), ), ], diff --git a/lib/main.dart b/lib/main.dart index a2e05ed1..827ef08b 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -2,9 +2,11 @@ import 'package:beacon/config/environment_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/view_model/group_screen_view_model.dart'; import 'package:beacon/views/base_view.dart'; import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; +import 'package:provider/provider.dart'; import 'package:sizer/sizer.dart'; import 'package:overlay_support/overlay_support.dart'; @@ -18,8 +20,9 @@ void main() async { setupLocator(); await localNotif!.initialize(); await hiveDb!.init(); - runApp( - OverlaySupport( + runApp(MultiProvider( + providers: [ChangeNotifierProvider(create: (_) => GroupViewModel())], + child: OverlaySupport( child: Sizer( builder: (context, orientation, deviceType) => MaterialApp( debugShowCheckedModeBanner: false, @@ -31,7 +34,7 @@ void main() async { ), ), ), - ); + )); } class DemoPageView extends StatelessWidget { diff --git a/lib/models/beacon/beacon.dart b/lib/models/beacon/beacon.dart index c177f502..341ea4bd 100644 --- a/lib/models/beacon/beacon.dart +++ b/lib/models/beacon/beacon.dart @@ -19,41 +19,42 @@ class Beacon extends HiveObject { this.route, this.landmarks, this.location, - this.group}); + this.group, + this.showAdminName}); factory Beacon.fromJson(Map json) { return Beacon( - id: json['_id'] as String?, - shortcode: json['shortcode'] as String?, - title: json['title'] != null ? json['title'] as String? : null, - startsAt: json['startsAt'] as int?, - expiresAt: json['expiresAt'] as int?, - leader: json['leader'] != null - ? User.fromJson(json['leader'] as Map) - : null, - location: json['location'] != null - ? Location.fromJson(json['location'] as Map) - : null, - followers: json['followers'] != null - ? (json['followers'] as List) - .map((e) => User.fromJson(e as Map)) - .toList() - : [], - route: json['route'] != null - ? (json['route'] as List) - .map((e) => Location.fromJson(e as Map)) - .toList() - : [], - landmarks: json['landmarks'] != null - ? (json['landmarks'] as List) - .map((e) => Landmark.fromJson(e as Map)) - .toList() - : [], - // group: json['group'] != null - // ? Group.fromJson(json['group'] as Map) - // : null, - group: json['group'] != null ? json['group']['_id'] : null, - ); + id: json['_id'] as String?, + shortcode: json['shortcode'] as String?, + title: json['title'] != null ? json['title'] as String? : null, + startsAt: json['startsAt'] as int?, + expiresAt: json['expiresAt'] as int?, + leader: json['leader'] != null + ? User.fromJson(json['leader'] as Map) + : null, + location: json['location'] != null + ? Location.fromJson(json['location'] as Map) + : null, + followers: json['followers'] != null + ? (json['followers'] as List) + .map((e) => User.fromJson(e as Map)) + .toList() + : [], + route: json['route'] != null + ? (json['route'] as List) + .map((e) => Location.fromJson(e as Map)) + .toList() + : [], + landmarks: json['landmarks'] != null + ? (json['landmarks'] as List) + .map((e) => Landmark.fromJson(e as Map)) + .toList() + : [], + // group: json['group'] != null + // ? Group.fromJson(json['group'] as Map) + // : null, + group: json['group'] != null ? json['group']['_id'] : null, + showAdminName: json['showAdminName'] ?? false); } @HiveField(0) @@ -78,6 +79,8 @@ class Beacon extends HiveObject { Location? location; @HiveField(10) String? group; + @HiveField(11) + bool? showAdminName; print() { debugPrint('shortCode: ${this.shortcode}'); diff --git a/lib/models/beacon/beacon.g.dart b/lib/models/beacon/beacon.g.dart index f6975e15..6797d160 100644 --- a/lib/models/beacon/beacon.g.dart +++ b/lib/models/beacon/beacon.g.dart @@ -24,17 +24,18 @@ 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?, + showAdminName: fields[11] as bool?, ); } @override void write(BinaryWriter writer, Beacon obj) { writer - ..writeByte(11) + ..writeByte(12) ..writeByte(0) ..write(obj.id) ..writeByte(1) @@ -56,7 +57,9 @@ class BeaconAdapter extends TypeAdapter { ..writeByte(9) ..write(obj.location) ..writeByte(10) - ..write(obj.group); + ..write(obj.group) + ..writeByte(11) + ..write(obj.showAdminName); } @override diff --git a/lib/queries/auth.dart b/lib/queries/auth.dart index 37eca718..ff311558 100644 --- a/lib/queries/auth.dart +++ b/lib/queries/auth.dart @@ -43,7 +43,6 @@ class AuthQueries { } String fetchUserInfo() { - log('fetching user info'); return ''' query{ me{ diff --git a/lib/queries/beacon.dart b/lib/queries/beacon.dart index 5cef7678..935b3642 100644 --- a/lib/queries/beacon.dart +++ b/lib/queries/beacon.dart @@ -41,7 +41,7 @@ class BeaconQueries { } String createBeacon(String? title, int startsAt, int expiresAt, String lat, - String lon, String? groupID) { + String lon, String? groupID, bool showAdminName) { return ''' mutation{ createBeacon(beacon: { @@ -51,6 +51,7 @@ class BeaconQueries { startLocation: { lat: "$lat", lon: "$lon" } + showAdminName: $showAdminName }, groupID:"$groupID") { diff --git a/lib/queries/group.dart b/lib/queries/group.dart index f9b335b5..834260c9 100644 --- a/lib/queries/group.dart +++ b/lib/queries/group.dart @@ -121,6 +121,7 @@ class GroupQueries { _id name } + showAdminName startsAt expiresAt } diff --git a/lib/services/database_mutation_functions.dart b/lib/services/database_mutation_functions.dart index a7baeb7d..8df44f52 100644 --- a/lib/services/database_mutation_functions.dart +++ b/lib/services/database_mutation_functions.dart @@ -23,7 +23,10 @@ class DataBaseMutationFunctions { init() async { clientNonAuth = await ValueNotifier(graphqlConfig!.clientToQuery()); ValueNotifier(clientNonAuth); - clientAuth = await graphqlConfig!.authClient(); + if (1 == 1) { + log('this is started'); + clientAuth = await graphqlConfig!.authClient(); + } _authQuery = AuthQueries(); _beaconQuery = BeaconQueries(); _groupQuery = GroupQueries(); @@ -190,6 +193,7 @@ class DataBaseMutationFunctions { navigationService!.pushReplacementScreen('/auth'); } } else if (result.data != null && result.isConcrete) { + log('data fetched'); User userInfo = User.fromJson( result.data!['me'] as Map, ); @@ -282,8 +286,33 @@ class DataBaseMutationFunctions { return beacons; } - Future createBeacon( - String? title, int startsAt, int expiresAt, String? groupID) async { + Future fetchGroup(String? groupId) async { + Group? group = Group(); + + if (!await connectionChecker!.checkForInternetConnection()) { + // fetch from local db + + group = await hiveDb!.getGroup(groupId!); + return group; + } + final QueryResult result = await clientAuth + .query(QueryOptions(document: gql(_groupQuery.groupDetail(groupId)))); + + if (result.hasException) { + final bool exception = + encounteredExceptionOrError(result.exception!, showSnackBar: false); + if (exception) { + print('$exception'); + } + } else if (result.data != null && result.isConcrete) { + group = Group.fromJson(result.data!['group']); + await hiveDb!.putGroupInGroupBox(groupId, group); + } + return group; + } + + Future createBeacon(String? title, int startsAt, int expiresAt, + String? groupID, bool showAdminName) async { log(startsAt.toString()); LatLng loc; try { @@ -294,8 +323,14 @@ class DataBaseMutationFunctions { return null; } final QueryResult result = await clientAuth.mutate(MutationOptions( - document: gql(_beaconQuery.createBeacon(title, startsAt, expiresAt, - loc.latitude.toString(), loc.longitude.toString(), groupID)))); + document: gql(_beaconQuery.createBeacon( + title, + startsAt, + expiresAt, + loc.latitude.toString(), + loc.longitude.toString(), + groupID, + showAdminName)))); if (result.hasException) { navigationService!.showSnackBar( "Something went wrong: ${result.exception!.graphqlErrors.first.message}"); diff --git a/lib/services/hive_localdb.dart b/lib/services/hive_localdb.dart index d0524a9f..c5015380 100644 --- a/lib/services/hive_localdb.dart +++ b/lib/services/hive_localdb.dart @@ -11,7 +11,7 @@ import '../models/group/group.dart'; class HiveLocalDb { late Box currentUserBox; late Box beaconsBox; - Box? groupsBox; + late Box groupsBox; Future init() async { final appDocumentDirectory = @@ -54,4 +54,27 @@ class HiveLocalDb { final userBeacons = beaconsBox.values.toList(); return userBeacons; } + + Future putGroupInGroupBox(String? groupId, Group? group, + {bool fetchFromNetwork = false}) async { + if (groupsBox.containsKey(groupId)) { + await groupsBox.delete(groupId); + } + if (fetchFromNetwork) { + databaseFunctions!.init(); + group = await databaseFunctions!.fetchGroup(groupId); + } + await groupsBox.put(groupId, group); + } + + Future getGroup(String groupId) async { + final group = await groupsBox.get(groupId); + return group; + } + + Future getCurrentUser() async { + currentUserBox = await Hive.openBox('currentUser'); + final user = await currentUserBox.get('user'); + return user; + } } diff --git a/lib/services/local_notification.dart b/lib/services/local_notification.dart index d22cd89a..a6d8b4f2 100644 --- a/lib/services/local_notification.dart +++ b/lib/services/local_notification.dart @@ -1,3 +1,5 @@ +import 'dart:developer'; + import 'package:beacon/locator.dart'; import 'package:beacon/models/beacon/beacon.dart'; import 'package:beacon/views/hike_screen.dart'; @@ -48,13 +50,13 @@ class LocalNotification { } Future scheduleNotification(Beacon beacon) async { - var scheduledDate = await tz.TZDateTime.from( + tz.TZDateTime scheduledDate1 = await tz.TZDateTime.from( DateTime.fromMillisecondsSinceEpoch(beacon.startsAt!), tz.local); await flutterLocalNotificationsPlugin.zonedSchedule( beacon.id.hashCode, 'Hike ' + beacon.title! + ' has started', 'Click here to join!', - scheduledDate, + scheduledDate1, NotificationDetails( android: AndroidNotificationDetails( 'channel id', @@ -78,15 +80,20 @@ class LocalNotification { ); // We have to check if the hike is after 1 hour or not - scheduledDate = await tz.TZDateTime.from( + var scheduledDate2 = await tz.TZDateTime.from( DateTime.fromMillisecondsSinceEpoch(beacon.startsAt!), tz.local, ).subtract(Duration(hours: 1)); + + // We will check if beacon start time is less than the 2nd notification scheduling time + + if (scheduledDate2.compareTo(scheduledDate1) < 0) return; + await flutterLocalNotificationsPlugin.zonedSchedule( beacon.id.hashCode, 'Reminder: ' + beacon.title! + ' will start in an hour', 'Get Ready!', - scheduledDate, + scheduledDate2, NotificationDetails( android: AndroidNotificationDetails( 'channel id', diff --git a/lib/utilities/constants.dart b/lib/utilities/constants.dart index 8f272eaf..ed66fc0c 100644 --- a/lib/utilities/constants.dart +++ b/lib/utilities/constants.dart @@ -53,6 +53,22 @@ class AppConstants { Position position = await Geolocator.getCurrentPosition(); return LatLng(position.latitude, position.longitude); } + + double calculateDistance(double startLatitude, double startLongitude, + double endLatitude, double endLongitude) { + double distanceInMeters = Geolocator.distanceBetween( + startLatitude, + startLongitude, + endLatitude, + endLongitude, + ); + + // The distance is returned in meters. You can convert it to kilometers or miles if needed. + // For example, to convert meters to kilometers: + double distanceInKm = distanceInMeters / 1000; + + return distanceInKm; + } } //routes diff --git a/lib/view_model/group_screen_view_model.dart b/lib/view_model/group_screen_view_model.dart index 9d4a1504..1e308422 100644 --- a/lib/view_model/group_screen_view_model.dart +++ b/lib/view_model/group_screen_view_model.dart @@ -1,9 +1,15 @@ +import 'dart:developer'; + import 'package:beacon/enums/view_state.dart'; import 'package:beacon/locator.dart'; import 'package:beacon/models/beacon/beacon.dart'; +import 'package:beacon/models/group/group.dart'; +import 'package:beacon/models/user/user_info.dart'; +import 'package:beacon/utilities/constants.dart'; import 'package:beacon/view_model/base_view_model.dart'; import 'package:beacon/views/hike_screen.dart'; import 'package:flutter/material.dart'; +import 'package:google_maps_flutter/google_maps_flutter.dart'; import 'package:intl/intl.dart'; class GroupViewModel extends BaseModel { @@ -25,7 +31,96 @@ class GroupViewModel extends BaseModel { TextEditingController startsAtTime = new TextEditingController(); String? enteredPasskey; - createHikeRoom(String? groupID, Function reloadList) async { + bool showName = false; + bool loadingUserBeacons = false; + List userBeacons = []; + bool loadingGroupMembers = false; + List groupMembers = []; + bool loadingNearbyBeacons = false; + List nearByBeacons = []; + + toogleShowName(bool value) { + showName = value; + notifyListeners(); + } + + clearGroupInfo() { + userBeacons.clear(); + groupMembers.clear(); + nearByBeacons.clear(); + } + + fetchGroupDetails(String groupId) async { + // starting loading indicator + loadingUserBeacons = true; + loadingGroupMembers = true; + loadingNearbyBeacons = true; + notifyListeners(); + + // fetching group details + Group? group = await databaseFunctions!.fetchGroup(groupId); + + if (group != null) { + // adding beacons + if (group.beacons != null) { + for (Beacon beacon in group.beacons!) { + userBeacons.add(beacon); + } + } + // adding group leader + if (group.leader != null) { + groupMembers.add(group.leader!); + log('added leader'); + } + // adding group members + if (group.members != null) { + for (User member in group.members!) { + groupMembers.add(member); + } + } + } + + // sorting nearby beacons from userbeacons + fetchNearByBeacons(userBeacons); + + // turning off the loading widget + loadingUserBeacons = false; + loadingGroupMembers = false; + notifyListeners(); + } + + fetchNearByBeacons(List groupBeacons) async { + LatLng currentLocation = await AppConstants.getLocation(); + + for (Beacon beacon in groupBeacons) { + double distance = await AppConstants().calculateDistance( + currentLocation.latitude, + currentLocation.longitude, + double.parse(beacon.location!.lat!), + double.parse(beacon.location!.lon!)); + if (distance < 1.5) { + nearByBeacons.add(beacon); + } + } + // turning off loading widget + loadingNearbyBeacons = false; + notifyListeners(); + } + + checkNearByBeacon(Beacon beacon) async { + LatLng currentLocation = await AppConstants.getLocation(); + + double distance = await AppConstants().calculateDistance( + currentLocation.latitude, + currentLocation.longitude, + double.parse(beacon.location!.lat!), + double.parse(beacon.location!.lon!)); + if (distance < 1.5) { + nearByBeacons.add(beacon); + } + } + + createHikeRoom(String? groupID) async { FocusScope.of(navigationService!.navigatorKey.currentContext!).unfocus(); validate = AutovalidateMode.always; if (formKeyCreate.currentState!.validate()) { @@ -37,9 +132,13 @@ class GroupViewModel extends BaseModel { title, startsAt.millisecondsSinceEpoch.toInt(), startsAt.add(resultingDuration!).millisecondsSinceEpoch.toInt(), - groupID); + groupID, + showName); // setState(ViewState.idle); if (beacon != null) { + userBeacons.add(beacon); + checkNearByBeacon(beacon); + notifyListeners(); hasStarted = DateTime.now() .isAfter(DateTime.fromMillisecondsSinceEpoch(beacon.startsAt!)); if (hasStarted) { @@ -51,7 +150,6 @@ class GroupViewModel extends BaseModel { } else { 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()}', ); @@ -77,14 +175,16 @@ class GroupViewModel extends BaseModel { if (beacon != null) { hasStarted = DateTime.now() .isAfter(DateTime.fromMillisecondsSinceEpoch(beacon.startsAt!)); - + userBeacons.add(beacon); + checkNearByBeacon(beacon); + notifyListeners(); if (hasStarted) { navigationService!.pushScreen('/hikeScreen', arguments: HikeScreen(beacon, isLeader: false)); } else { localNotif!.scheduleNotification(beacon); setState(ViewState.idle); - reloadList(); + // 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()}', ); diff --git a/lib/views/auth_screen.dart b/lib/views/auth_screen.dart index 1cac5694..83a18507 100644 --- a/lib/views/auth_screen.dart +++ b/lib/views/auth_screen.dart @@ -8,7 +8,6 @@ import 'package:beacon/views/base_view.dart'; import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; import 'package:sizer/sizer.dart'; - import '../components/loading_screen.dart'; class AuthScreen extends StatefulWidget { diff --git a/lib/views/group_screen.dart b/lib/views/group_screen.dart index fa0d36ec..c77b3492 100644 --- a/lib/views/group_screen.dart +++ b/lib/views/group_screen.dart @@ -7,9 +7,9 @@ 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:flutter/material.dart'; import 'package:modal_progress_hud_nsn/modal_progress_hud_nsn.dart'; +import 'package:provider/provider.dart'; import 'package:sizer/sizer.dart'; import '../models/group/group.dart'; @@ -29,6 +29,11 @@ class _GroupScreenState extends State @override void initState() { super.initState(); + + WidgetsBinding.instance.addPostFrameCallback((timeStamp) { + Provider.of(context, listen: false) + .fetchGroupDetails(widget.group.id!); + }); } fetchUserBeacons() async { @@ -49,15 +54,20 @@ class _GroupScreenState extends State @override Widget build(BuildContext context) { - return BaseView(builder: (context, model, child) { - TabController tabController = new TabController(length: 2, vsync: this); - return model.isBusy + TabController tabController = new TabController(length: 2, vsync: this); + return PopScope(onPopInvoked: (didPop) { + if (didPop == true) { + Provider.of(context, listen: false).clearGroupInfo(); + } + }, child: + Consumer(builder: (context, groupviewmodel, child) { + return groupviewmodel.isBusy ? LoadingScreen() : Scaffold( resizeToAvoidBottomInset: false, body: SafeArea( child: ModalProgressHUD( - inAsyncCall: model.isCreatingHike, + inAsyncCall: groupviewmodel.isCreatingHike, child: Stack( children: [ CustomPaint( @@ -89,108 +99,205 @@ class _GroupScreenState extends State ), ), Align( - alignment: Alignment(0.9, -0.8), - child: FloatingActionButton( - onPressed: () => showDialog( - context: context, - builder: (context) => AlertDialog( - shape: RoundedRectangleBorder( - borderRadius: BorderRadius.circular(10.0), - ), - // actionsAlignment: - // MainAxisAlignment.spaceEvenly, - title: Text( - userConfig!.currentUser!.isGuest! - ? 'Create Account' - : 'Logout', - style: TextStyle( - fontSize: 25, color: kYellow), - ), - content: Text( - userConfig!.currentUser!.isGuest! - ? 'Would you like to create an account?' - : 'Are you sure you wanna logout?', - style: TextStyle( - fontSize: 16, color: kBlack), - ), - actions: [ - HikeButton( - buttonHeight: 2.5.h, - buttonWidth: 8.w, - onTap: () => - Navigator.of(context).pop(false), - text: 'No', - textSize: 18.0, - ), - HikeButton( - buttonHeight: 2.5.h, - buttonWidth: 8.w, - onTap: () { - navigationService!.pop(); - model.logout(); - }, - text: 'Yes', - textSize: 18.0, - ), - ], - )), - backgroundColor: kYellow, - child: userConfig!.currentUser!.isGuest! - ? Icon(Icons.person) - : Icon(Icons.logout), - ), - ), - Padding( - padding: EdgeInsets.fromLTRB(4.w, 25.h, 4.w, 5), + alignment: Alignment(0.8, -0.8), child: Row( - mainAxisAlignment: MainAxisAlignment.spaceEvenly, - mainAxisSize: MainAxisSize.max, - crossAxisAlignment: CrossAxisAlignment.center, - children: [ - Container( - width: 45.w, - child: HikeButton( - buttonWidth: homebwidth, - buttonHeight: homebheight - 2, - text: 'Create Hike', - textColor: Colors.white, - borderColor: Colors.white, - buttonColor: kYellow, - onTap: () { - if (userConfig!.currentUser!.isGuest!) { - navigationService!.showSnackBar( - 'You need to login with credentials to start a hike'); - } else { - CreateJoinBeaconDialog.createHikeDialog( - context, - model, - reloadList, - widget.group.id); - } - }, - ), + mainAxisAlignment: MainAxisAlignment.end, + children: [ + FloatingActionButton( + heroTag: 'list button', + onPressed: () => showDialog( + context: context, + builder: (context) => AlertDialog( + shape: RoundedRectangleBorder( + borderRadius: + BorderRadius.circular(10.0), + ), + // actionsAlignment: + // MainAxisAlignment.spaceEvenly, + title: Text( + 'Group members', + textAlign: TextAlign.center, + style: TextStyle( + fontSize: 25, color: kYellow), + ), + content: Container( + height: 250, + width: 250, + child: Builder( + builder: (context) { + if (groupviewmodel + .loadingGroupMembers) { + return Center( + child: BeaconCustomWidgets + .getPlaceholder(), + ); + } else { + return groupviewmodel + .groupMembers.isEmpty + ? Container( + child: Text('emplty'), + ) + : ListView.builder( + itemCount: + groupviewmodel + .groupMembers + .length, + itemBuilder: + (context, index) { + return Container( + padding: EdgeInsets + .symmetric( + horizontal: + 5), + margin: EdgeInsets + .symmetric( + vertical: + 5), + height: 7.h, + width: 50.w, + decoration: + BoxDecoration( + color: + kLightBlue), + child: Row( + mainAxisAlignment: + MainAxisAlignment + .spaceBetween, + children: [ + Text(groupviewmodel + .groupMembers[ + index] + .name + .toString()), + Text(index == 0 + ? '(leader)' + : '(member)') + ], + ), + ); + }, + ); + } + }, + ), + ), + )), + backgroundColor: kYellow, + child: Icon(Icons.list), ), SizedBox( width: 1.w, ), - Container( - width: 45.w, - child: HikeButton( - buttonWidth: homebwidth, - buttonHeight: homebheight - 2, - text: 'Join a Hike', - textColor: kYellow, - borderColor: kYellow, - buttonColor: Colors.white, - onTap: () async { - CreateJoinBeaconDialog.joinBeaconDialog( - context, model, reloadList); - }, - ), + FloatingActionButton( + heroTag: 'log out ', + onPressed: () => showDialog( + context: context, + builder: (context) => AlertDialog( + shape: RoundedRectangleBorder( + borderRadius: + BorderRadius.circular(10.0), + ), + // actionsAlignment: + // MainAxisAlignment.spaceEvenly, + title: Text( + userConfig!.currentUser!.isGuest! + ? 'Create Account' + : 'Logout', + style: TextStyle( + fontSize: 25, color: kYellow), + ), + content: Text( + userConfig!.currentUser!.isGuest! + ? 'Would you like to create an account?' + : 'Are you sure you wanna logout?', + style: TextStyle( + fontSize: 16, color: kBlack), + ), + actions: [ + HikeButton( + buttonHeight: 2.5.h, + buttonWidth: 8.w, + onTap: () => Navigator.of(context) + .pop(false), + text: 'No', + textSize: 18.0, + ), + HikeButton( + buttonHeight: 2.5.h, + buttonWidth: 8.w, + onTap: () { + navigationService!.pop(); + groupviewmodel.logout(); + }, + text: 'Yes', + textSize: 18.0, + ), + ], + )), + backgroundColor: kYellow, + child: userConfig!.currentUser!.isGuest! + ? Icon(Icons.person) + : Icon(Icons.logout), + ), + SizedBox( + width: 2.w, ), ], ), ), + Positioned( + bottom: 58.h, + child: Padding( + padding: EdgeInsets.fromLTRB(4.w, 25.h, 4.w, 5), + child: Row( + mainAxisAlignment: MainAxisAlignment.spaceEvenly, + mainAxisSize: MainAxisSize.max, + crossAxisAlignment: CrossAxisAlignment.center, + children: [ + Container( + width: 45.w, + child: HikeButton( + buttonWidth: homebwidth, + buttonHeight: homebheight - 2, + text: 'Create Hike', + textColor: Colors.white, + borderColor: Colors.white, + buttonColor: kYellow, + onTap: () { + if (userConfig!.currentUser!.isGuest!) { + navigationService!.showSnackBar( + 'You need to login with credentials to start a hike'); + } else { + CreateJoinBeaconDialog.createHikeDialog( + context, + groupviewmodel, + widget.group.id); + } + }, + ), + ), + SizedBox( + width: 1.w, + ), + Container( + width: 45.w, + child: HikeButton( + buttonWidth: homebwidth, + buttonHeight: homebheight - 2, + text: 'Join a Hike', + textColor: kYellow, + borderColor: kYellow, + buttonColor: Colors.white, + onTap: () async { + CreateJoinBeaconDialog.joinBeaconDialog( + context, groupviewmodel, reloadList); + }, + ), + ), + ], + ), + ), + ), Column( mainAxisAlignment: MainAxisAlignment.end, crossAxisAlignment: CrossAxisAlignment.center, @@ -222,29 +329,21 @@ class _GroupScreenState extends State controller: tabController, children: [ Padding( - padding: const EdgeInsets.all(12.0), - child: FutureBuilder( - future: fetchUserBeacons(), - builder: (context, snapshot) { - if (snapshot.connectionState == - ConnectionState.done) { - if (snapshot.hasError) { + padding: const EdgeInsets.all(12.0), + child: Builder( + builder: (context) { + if (groupviewmodel + .loadingUserBeacons) { return Center( - child: Text( - snapshot.error.toString(), - textAlign: TextAlign.center, - textScaler: - TextScaler.linear(1.3), - ), + child: BeaconCustomWidgets + .getPlaceholder(), ); - } - final List posts = - snapshot.data - as List; - return Container( - alignment: Alignment.center, - child: posts.length == 0 - ? SingleChildScrollView( + } else { + return groupviewmodel + .userBeacons.isEmpty + ? Center( + child: + SingleChildScrollView( physics: AlwaysScrollableScrollPhysics(), child: Column( @@ -297,107 +396,71 @@ class _GroupScreenState extends State ), ], ), - ) - : ListView.builder( + ), + ) + : ListView.builder( + itemCount: + groupviewmodel + .userBeacons + .length, + itemBuilder: + (context, index) { + return BeaconCustomWidgets + .getBeaconCard( + context, + groupviewmodel + .userBeacons[ + index]); + }, + ); + } + }, + )), + Padding( + padding: const EdgeInsets.all(12.0), + child: Container( + alignment: Alignment.center, + child: Builder( + builder: (context) { + if (groupviewmodel + .loadingNearbyBeacons) { + return Center( + child: BeaconCustomWidgets + .getPlaceholder(), + ); + } else { + return groupviewmodel + .nearByBeacons.isEmpty + ? SingleChildScrollView( physics: AlwaysScrollableScrollPhysics(), - scrollDirection: - Axis.vertical, + child: Center( + child: Text( + 'No nearby beacons found :(', + style: TextStyle( + color: kBlack, + fontSize: 20), + ), + ), + ) + : ListView.builder( itemCount: - posts.length, - padding: - EdgeInsets.all(8), + groupviewmodel + .nearByBeacons + .length, itemBuilder: (context, index) { return BeaconCustomWidgets .getBeaconCard( context, - posts[ - index]!); + groupviewmodel + .nearByBeacons[ + index]); }, - )); - } else { - return Center( - child: BeaconCustomWidgets - .getPlaceholder(), - ); - } - }, - ), - ), - Padding( - padding: const EdgeInsets.all(12.0), - child: Container( - alignment: Alignment.center, - child: FutureBuilder( - future: fetchNearByBeacons(), - builder: (context, snapshot) { - if (snapshot.connectionState == - ConnectionState.waiting) - return Center( - child: BeaconCustomWidgets - .getPlaceholder(), - ); - if (snapshot.connectionState == - ConnectionState.done) { - if (snapshot.hasError) { - return Center( - child: Text( - snapshot.error.toString(), - textAlign: - TextAlign.center, - textScaler: - TextScaler.linear( - 1.3), - ), - ); + ); } - - final posts = snapshot.data - as List; - if (posts.length == 0) { - return SingleChildScrollView( - physics: - AlwaysScrollableScrollPhysics(), - child: Center( - child: Text( - 'No nearby beacons found :(', - style: TextStyle( - color: kBlack, - fontSize: 20), - ), - ), - ); - } - return ListView.builder( - physics: - AlwaysScrollableScrollPhysics(), - scrollDirection: - Axis.vertical, - itemCount: posts.length, - padding: EdgeInsets.all(8), - itemBuilder: - (context, index) { - return BeaconCustomWidgets - .getBeaconCard(context, - posts[index]); - }, - ); - } else { - return SingleChildScrollView( - physics: - AlwaysScrollableScrollPhysics(), - child: Center( - child: Text( - 'No nearby beacons found :(', - style: TextStyle( - color: kBlack, - fontSize: 18))), - ); - } - }, - ), - ), + }, + )), ), ], ), @@ -412,6 +475,6 @@ class _GroupScreenState extends State ), ), ); - }); + })); } } diff --git a/lib/views/hike_screen.dart b/lib/views/hike_screen.dart index 24bef382..7351d751 100644 --- a/lib/views/hike_screen.dart +++ b/lib/views/hike_screen.dart @@ -184,6 +184,7 @@ class _HikeScreenState extends State { Align( alignment: Alignment(-0.9, -0.98), child: FloatingActionButton( + heroTag: 'back button', onPressed: () { navigationService!.pop(); }, diff --git a/lib/views/home_screen.dart b/lib/views/home_screen.dart index cb10fa7b..cc69bd15 100644 --- a/lib/views/home_screen.dart +++ b/lib/views/home_screen.dart @@ -144,52 +144,55 @@ class _MainScreenState extends State with TickerProviderStateMixin { : Icon(Icons.logout), ), ), - Padding( - padding: EdgeInsets.fromLTRB(4.w, 25.h, 4.w, 5), - child: Row( - mainAxisAlignment: MainAxisAlignment.spaceEvenly, - mainAxisSize: MainAxisSize.max, - crossAxisAlignment: CrossAxisAlignment.center, - children: [ - Container( - width: 45.w, - child: HikeButton( - buttonWidth: homebwidth - 10, - buttonHeight: homebheight - 2, - text: 'Create Group', - textColor: Colors.white, - borderColor: Colors.white, - buttonColor: kYellow, - onTap: () { - if (userConfig!.currentUser!.isGuest!) { - navigationService!.showSnackBar( - 'You need to login with credentials to be able to create a group'); - } else { - CreateJoinGroupDialog.createGroupDialog( - context, model); - } - }, + Positioned( + bottom: 58.h, + child: Padding( + padding: EdgeInsets.fromLTRB(4.w, 25.h, 4.w, 5), + child: Row( + mainAxisAlignment: MainAxisAlignment.spaceEvenly, + mainAxisSize: MainAxisSize.max, + crossAxisAlignment: CrossAxisAlignment.center, + children: [ + Container( + width: 45.w, + child: HikeButton( + buttonWidth: homebwidth - 10, + buttonHeight: homebheight - 2, + text: 'Create Group', + textColor: Colors.white, + borderColor: Colors.white, + buttonColor: kYellow, + onTap: () { + if (userConfig!.currentUser!.isGuest!) { + navigationService!.showSnackBar( + 'You need to login with credentials to be able to create a group'); + } else { + CreateJoinGroupDialog.createGroupDialog( + context, model); + } + }, + ), ), - ), - SizedBox( - width: 1.w, - ), - Container( - width: 45.w, - child: HikeButton( - buttonWidth: homebwidth, - buttonHeight: homebheight - 2, - text: 'Join a Group', - textColor: kYellow, - borderColor: kYellow, - buttonColor: Colors.white, - onTap: () async { - CreateJoinGroupDialog.joinGroupDialog( - context, model); - }, + SizedBox( + width: 1.w, ), - ), - ], + Container( + width: 45.w, + child: HikeButton( + buttonWidth: homebwidth, + buttonHeight: homebheight - 2, + text: 'Join a Group', + textColor: kYellow, + borderColor: kYellow, + buttonColor: Colors.white, + onTap: () async { + CreateJoinGroupDialog.joinGroupDialog( + context, model); + }, + ), + ), + ], + ), ), ), Column( diff --git a/pubspec.lock b/pubspec.lock index 35424044..6597e2bb 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -556,10 +556,10 @@ packages: dependency: transitive description: name: google_maps_flutter_web - sha256: "6245721c160d6f531c1ef568cf9bef8d660cd585a982aa75121269030163785a" + sha256: f893d1542c6562bc8299ef768fbbe92ade83c220ab3209b9477ec9f81ad585e4 url: "https://pub.dev" source: hosted - version: "0.5.4+3" + version: "0.5.4+2" gql: dependency: transitive description: From 5d9ba23d4e3d65a9298cbf9df3a1f828c19d0fdd Mon Sep 17 00:00:00 2001 From: Abhishek Date: Tue, 20 Feb 2024 02:17:25 +0530 Subject: [PATCH 02/12] keys and string removed --- android/app/src/main/res/values/string.xml | 1 - android/app/upload-debug.jks | Bin 2772 -> 0 bytes 2 files changed, 1 deletion(-) delete mode 100644 android/app/src/main/res/values/string.xml delete mode 100644 android/app/upload-debug.jks diff --git a/android/app/src/main/res/values/string.xml b/android/app/src/main/res/values/string.xml deleted file mode 100644 index 25a17518..00000000 --- a/android/app/src/main/res/values/string.xml +++ /dev/null @@ -1 +0,0 @@ - 289316832965-k9d28ajkk2l4spf9n9l82c65is9b8kfu.apps.googleusercontent.com \ No newline at end of file diff --git a/android/app/upload-debug.jks b/android/app/upload-debug.jks deleted file mode 100644 index f0dad661f2011afb6008bd69ea8172a266236591..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 2772 zcma);XE+;*8po4Jh*cv>RIO@Jj*1=Bh}IspPSt4a&}i*FP9q0FNfkLpN{tw`s??}h zb!xIsWM1P3$p-xoow5CB4$nbjr1 z2m#gFh5%YluMYgGj2C zf!oQI5N$hQy2ils6a^y*eNHWVU*qTG4Bn(kO=9C1vZbqw=hZ|X>bDhBPKBjLbO}6W z&DffvTCF;jP?mdv;%+`jFCTyCd_x6#afI^+l!o!iN{oqNWpB?<~S~g@FN!UZ-Pdx zxrZ$uHmJC3iPX|rh@0GV#bROpev-=jkv!@69c<`sO=%~*55m$4Gt#2fGBsUvi9t53V(@m(V?>zP>74k&iJ zoaID2#SHB)=Mh-AK%+ME6S`&g?@naWzbCA!413&0HE)H=G21D@Qcch0EsIXyL==%9xD)3w_VvVgqKh1$v0sdLh$5B$L@3|n9;9l9kR9Wq7 zTX?qrf!qw!@%8F{2vw~?E9RAoG2iXA+$QVfncqjkd52NcY&o_*B2P7~WCeRp>U7VK zbUdr-K*qj$I(o9JVlquAdEKwv?ixIiS?(_yLsuQqzHZ-HTB4g^N==Y)Vo(5@Ofnz0 zj4~g`oC&C_!pqnUFq*Cde|?~tdH7@<4OOtEM1y`f*%DQ@E`U) z-6$&VFF8^1#eCE20Opqm)lW?9_(H1ZK38R5n_qxdQ=-xY%8xOaqOVjnHspi|E-jC=6 z+4@?@HKJ`vgs;c2oF0|86*btfM_gudL&auU9j+|`XDxe&y_{%T1)O4Wp4qf;O#9 z*3Ob6^SUVtW(cXDammW3a83jc2m$y5?gIP(t^f~!+^IYPZl}x(A^y+eSp_~YukD?C zo?;4W2vv2Y8d6DF5uu8}gA0Eyu`n0l!Re=n2m%653*ny$@P9=%*TKp`>pim}OX%B? z#9Pv$UAq#4qvlM@wbNA^q&{tapAw~ zLTBMrcka7RH|9Lsx+8tQ)G)6prA4}Hn-}if9bhOGn^_Kfvy}M<=TK`>*|CEFeL%~V zxrnPnEeL7S9F&wuQ55^SO{-gxNSY|%MaOXsYK8Eto?%T^6O0-iSnPw zK`AiQb2$4t16+vJ(Ku-g*rKOtg>XX0(W#+mYd~qt#B7SVHor+11LWOC7U-R_m<1_Mcz9Cg7+oTk*rE zzZx_Wk+PZt52mMY>Ypr`Qz+8TMyTmgV9h095G8-bS%-rtb-UtDnxy0A9Cb@{kMYRe z*i0)=5T-}f;}EMT!a=)da9=do+vkiAreDST)<(}L{}JSSB=GAJ+4WtbI3)RDv--|r zTSouG;KRG8p|TA0|X< zQ|nh5{$?;;YN3VHx~lb-=_t|KGcf|;d2v#hBbXM-UFIX%7c|ExDrcFH*8mhDZ$|lO zxAmq6?^nWyX0c_P;$eabLL?k&fYHmb*L$_-dzX#Ca;J8M{hR0?ae2!-1d?l&2Q%3q zWMXM78aBfug^m|r%q+40!agg?XfDU^b?ZF}OW8DK&lo1g;1)$6DVa>|WYc!%n+do1 zTV0tk&3o^1xFa60#1Dk%*^&S?mwYrfY+AB{&l4J%lh|fVvil@vN;7ZRp(?$tr$H8R zS{*5shg!Jg_mrGzXdcPF{QAWrN$&@el6o4Y1W6qJSnfr5j`eoWh4W6P?gGUor9C`c zeOC-%`JaYnuse?m#$>|EbDF3C*cnSBfAzzG-+e(R7ek%H;;^60(;m9GcN)2(X}c0h z9pw9l>d)C_mX^2|J%{0KVcVl%K9JCbba6DvXYT$E_F-TGzy%+AmXN>7hg{ge5;)dR z0`di2%yJ=qytpehj+co+oAjX~M}ibt-z=@d(m$#*%Q5k81%&V)QYQbw2~6cC(0KRpl-0sxB{(!Yyq8>(g~O)P From f32260bcd5c22e391fa24420baa083b5051d6cf5 Mon Sep 17 00:00:00 2001 From: Abhishek Date: Tue, 20 Feb 2024 02:22:46 +0530 Subject: [PATCH 03/12] fvm and map key removed --- .fvm/flutter_sdk | 1 - android/app/src/main/AndroidManifest.xml | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) delete mode 120000 .fvm/flutter_sdk 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/android/app/src/main/AndroidManifest.xml b/android/app/src/main/AndroidManifest.xml index 1820f9f3..3fa667ad 100644 --- a/android/app/src/main/AndroidManifest.xml +++ b/android/app/src/main/AndroidManifest.xml @@ -10,7 +10,7 @@ android:label="Beacon" android:icon="@mipmap/launcher_icon" android:usesCleartextTraffic="true"> - + Date: Tue, 20 Feb 2024 02:44:40 +0530 Subject: [PATCH 04/12] dart formatting --- lib/queries/auth.dart | 2 -- lib/services/local_notification.dart | 2 -- 2 files changed, 4 deletions(-) diff --git a/lib/queries/auth.dart b/lib/queries/auth.dart index ff311558..299f461f 100644 --- a/lib/queries/auth.dart +++ b/lib/queries/auth.dart @@ -1,5 +1,3 @@ -import 'dart:developer'; - class AuthQueries { String registerUser(String? name, String email, String? password) { return ''' diff --git a/lib/services/local_notification.dart b/lib/services/local_notification.dart index a6d8b4f2..72961624 100644 --- a/lib/services/local_notification.dart +++ b/lib/services/local_notification.dart @@ -1,5 +1,3 @@ -import 'dart:developer'; - import 'package:beacon/locator.dart'; import 'package:beacon/models/beacon/beacon.dart'; import 'package:beacon/views/hike_screen.dart'; From bd449ea8dfbc0502ce61b4f300b08c9fdb0c79f0 Mon Sep 17 00:00:00 2001 From: Abhishek Date: Tue, 20 Feb 2024 02:49:37 +0530 Subject: [PATCH 05/12] removed unnecessary logs --- lib/services/database_mutation_functions.dart | 2 -- lib/services/graphql_config.dart | 2 -- 2 files changed, 4 deletions(-) diff --git a/lib/services/database_mutation_functions.dart b/lib/services/database_mutation_functions.dart index 8df44f52..772148e2 100644 --- a/lib/services/database_mutation_functions.dart +++ b/lib/services/database_mutation_functions.dart @@ -24,7 +24,6 @@ class DataBaseMutationFunctions { clientNonAuth = await ValueNotifier(graphqlConfig!.clientToQuery()); ValueNotifier(clientNonAuth); if (1 == 1) { - log('this is started'); clientAuth = await graphqlConfig!.authClient(); } _authQuery = AuthQueries(); @@ -193,7 +192,6 @@ class DataBaseMutationFunctions { navigationService!.pushReplacementScreen('/auth'); } } else if (result.data != null && result.isConcrete) { - log('data fetched'); User userInfo = User.fromJson( result.data!['me'] as Map, ); diff --git a/lib/services/graphql_config.dart b/lib/services/graphql_config.dart index 6bae32cb..4032c51a 100644 --- a/lib/services/graphql_config.dart +++ b/lib/services/graphql_config.dart @@ -28,8 +28,6 @@ class GraphQLConfig { } GraphQLClient clientToQuery() { - log(httpLink.toString()); - log(EnvironmentConfig.httpEndpoint!); return GraphQLClient( cache: GraphQLCache(), // cache: GraphQLCache(partialDataPolicy: PartialDataCachePolicy.accept), From b0a196cc8d2e1d9e54eed6bb6b3d623d64b39a38 Mon Sep 17 00:00:00 2001 From: Abhishek Date: Tue, 20 Feb 2024 02:58:22 +0530 Subject: [PATCH 06/12] removed unused import --- lib/services/graphql_config.dart | 2 -- 1 file changed, 2 deletions(-) diff --git a/lib/services/graphql_config.dart b/lib/services/graphql_config.dart index 4032c51a..fa279554 100644 --- a/lib/services/graphql_config.dart +++ b/lib/services/graphql_config.dart @@ -1,5 +1,3 @@ -import 'dart:developer'; - import 'package:beacon/config/environment_config.dart'; import 'package:beacon/locator.dart'; import 'package:graphql_flutter/graphql_flutter.dart'; From 44f6ffa4a203d03e45c0bd43a1aa734b9c3fd196 Mon Sep 17 00:00:00 2001 From: Abhishek Date: Tue, 20 Feb 2024 15:14:05 +0530 Subject: [PATCH 07/12] keys removed --- android/app/build.gradle | 18 +++--------------- android/app/src/main/AndroidManifest.xml | 2 +- lib/view_model/group_screen_view_model.dart | 3 --- 3 files changed, 4 insertions(+), 19 deletions(-) diff --git a/android/app/build.gradle b/android/app/build.gradle index f4292a21..9d5ba66a 100644 --- a/android/app/build.gradle +++ b/android/app/build.gradle @@ -34,15 +34,6 @@ android { } - signingConfigs{ - debug{ - keyAlias 'upload-debug' - keyPassword 'android' - storePassword 'android' - storeFile file('upload-debug.jks') - } - } - defaultConfig { // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html). applicationId "com.example.beacon" @@ -54,12 +45,9 @@ android { } buildTypes { - // release { - // // TODO: Add your own signing config for the release build. - // // Signing with the debug keys for now, so `flutter run --release` works. - // signingConfig signingConfigs.debug - // } - debug { + release { + // TODO: Add your own signing config for the release build. + // Signing with the debug keys for now, so `flutter run --release` works. signingConfig signingConfigs.debug } } diff --git a/android/app/src/main/AndroidManifest.xml b/android/app/src/main/AndroidManifest.xml index 3fa667ad..853decff 100644 --- a/android/app/src/main/AndroidManifest.xml +++ b/android/app/src/main/AndroidManifest.xml @@ -10,7 +10,7 @@ android:label="Beacon" android:icon="@mipmap/launcher_icon" android:usesCleartextTraffic="true"> - + Date: Tue, 20 Feb 2024 19:31:03 +0530 Subject: [PATCH 08/12] cleaned --- android/app/src/main/AndroidManifest.xml | 2 +- lib/components/create_join_dialog.dart | 5 +- lib/services/database_mutation_functions.dart | 43 ++--- lib/services/hive_localdb.dart | 17 -- lib/view_model/group_screen_view_model.dart | 76 +++++--- lib/views/group_screen.dart | 163 +++++++++--------- 6 files changed, 149 insertions(+), 157 deletions(-) diff --git a/android/app/src/main/AndroidManifest.xml b/android/app/src/main/AndroidManifest.xml index 853decff..1820f9f3 100644 --- a/android/app/src/main/AndroidManifest.xml +++ b/android/app/src/main/AndroidManifest.xml @@ -10,7 +10,7 @@ android:label="Beacon" android:icon="@mipmap/launcher_icon" android:usesCleartextTraffic="true"> - + fetchGroup(String? groupId) async { - Group? group = Group(); - - if (!await connectionChecker!.checkForInternetConnection()) { - // fetch from local db - - group = await hiveDb!.getGroup(groupId!); - return group; - } - final QueryResult result = await clientAuth - .query(QueryOptions(document: gql(_groupQuery.groupDetail(groupId)))); - - if (result.hasException) { - final bool exception = - encounteredExceptionOrError(result.exception!, showSnackBar: false); - if (exception) { - print('$exception'); - } - } else if (result.data != null && result.isConcrete) { - group = Group.fromJson(result.data!['group']); - await hiveDb!.putGroupInGroupBox(groupId, group); - } - return group; - } - Future createBeacon(String? title, int startsAt, int expiresAt, String? groupID, bool showAdminName) async { log(startsAt.toString()); diff --git a/lib/services/hive_localdb.dart b/lib/services/hive_localdb.dart index c5015380..c5a9830f 100644 --- a/lib/services/hive_localdb.dart +++ b/lib/services/hive_localdb.dart @@ -55,23 +55,6 @@ class HiveLocalDb { return userBeacons; } - Future putGroupInGroupBox(String? groupId, Group? group, - {bool fetchFromNetwork = false}) async { - if (groupsBox.containsKey(groupId)) { - await groupsBox.delete(groupId); - } - if (fetchFromNetwork) { - databaseFunctions!.init(); - group = await databaseFunctions!.fetchGroup(groupId); - } - await groupsBox.put(groupId, group); - } - - Future getGroup(String groupId) async { - final group = await groupsBox.get(groupId); - return group; - } - Future getCurrentUser() async { currentUserBox = await Hive.openBox('currentUser'); final user = await currentUserBox.get('user'); diff --git a/lib/view_model/group_screen_view_model.dart b/lib/view_model/group_screen_view_model.dart index 6126d10f..17003a92 100644 --- a/lib/view_model/group_screen_view_model.dart +++ b/lib/view_model/group_screen_view_model.dart @@ -1,8 +1,6 @@ import 'package:beacon/enums/view_state.dart'; import 'package:beacon/locator.dart'; import 'package:beacon/models/beacon/beacon.dart'; -import 'package:beacon/models/group/group.dart'; -import 'package:beacon/models/user/user_info.dart'; import 'package:beacon/utilities/constants.dart'; import 'package:beacon/view_model/base_view_model.dart'; import 'package:beacon/views/hike_screen.dart'; @@ -32,8 +30,6 @@ class GroupViewModel extends BaseModel { bool showName = false; bool loadingUserBeacons = false; List userBeacons = []; - bool loadingGroupMembers = false; - List groupMembers = []; bool loadingNearbyBeacons = false; List nearByBeacons = []; @@ -44,45 +40,29 @@ class GroupViewModel extends BaseModel { clearGroupInfo() { userBeacons.clear(); - groupMembers.clear(); nearByBeacons.clear(); } fetchGroupDetails(String groupId) async { // starting loading indicator loadingUserBeacons = true; - loadingGroupMembers = true; loadingNearbyBeacons = true; notifyListeners(); - // fetching group details - Group? group = await databaseFunctions!.fetchGroup(groupId); + // fetching group beacons + List groupBeacons = + await databaseFunctions!.fetchUserBeacons(groupId); - if (group != null) { - // adding beacons - if (group.beacons != null) { - for (Beacon beacon in group.beacons!) { - userBeacons.add(beacon); - } - } - // adding group leader - if (group.leader != null) { - groupMembers.add(group.leader!); - } - // adding group members - if (group.members != null) { - for (User member in group.members!) { - groupMembers.add(member); - } + for (Beacon? beacon in groupBeacons) { + if (beacon != null) { + userBeacons.add(beacon); } } - // sorting nearby beacons from userbeacons + // sorting nearby beacons under 1.5 KM radius from userbeacons fetchNearByBeacons(userBeacons); - // turning off the loading widget loadingUserBeacons = false; - loadingGroupMembers = false; notifyListeners(); } @@ -114,6 +94,9 @@ class GroupViewModel extends BaseModel { double.parse(beacon.location!.lon!)); if (distance < 1.5) { nearByBeacons.add(beacon); + List beacons = beaconsSorting(nearByBeacons); + nearByBeacons.clear(); + nearByBeacons.addAll(beacons); } } @@ -133,9 +116,17 @@ class GroupViewModel extends BaseModel { showName); // setState(ViewState.idle); if (beacon != null) { + // adding beacons and then sorting userBeacons.add(beacon); + List beacons = beaconsSorting(userBeacons); + userBeacons.clear(); + userBeacons.addAll(beacons); + notifyListeners(); + + // checking if new beacon created is nearby or not checkNearByBeacon(beacon); notifyListeners(); + hasStarted = DateTime.now() .isAfter(DateTime.fromMillisecondsSinceEpoch(beacon.startsAt!)); if (hasStarted) { @@ -159,7 +150,7 @@ class GroupViewModel extends BaseModel { } } - joinHikeRoom(Function reloadList) async { + joinHikeRoom() async { FocusScope.of(navigationService!.navigatorKey.currentContext!).unfocus(); validate = AutovalidateMode.always; if (formKeyJoin.currentState!.validate()) { @@ -172,7 +163,14 @@ class GroupViewModel extends BaseModel { if (beacon != null) { hasStarted = DateTime.now() .isAfter(DateTime.fromMillisecondsSinceEpoch(beacon.startsAt!)); + // adding beacons and then sorting userBeacons.add(beacon); + List beacons = beaconsSorting(userBeacons); + userBeacons.clear(); + userBeacons.addAll(beacons); + notifyListeners(); + + // checking if new beacon created is nearby or not checkNearByBeacon(beacon); notifyListeners(); if (hasStarted) { @@ -197,6 +195,28 @@ class GroupViewModel extends BaseModel { } } + List beaconsSorting(List beacons) { + List expiredBeacons = []; + List workingBeacons = []; + + for (var beacon in beacons) { + if (beacon != null) { + if (DateTime.fromMillisecondsSinceEpoch(beacon.expiresAt!) + .isBefore(DateTime.now())) { + expiredBeacons.insert(0, beacon); + expiredBeacons.sort((a, b) => a.expiresAt!.compareTo(b.expiresAt!)); + expiredBeacons = expiredBeacons.reversed.toList(); + } else { + workingBeacons.add(beacon); + workingBeacons.sort((a, b) => a.startsAt!.compareTo(b.startsAt!)); + } + } + } + // adding expired beacons at last + workingBeacons.addAll(expiredBeacons); + return workingBeacons; + } + logout() async { setState(ViewState.busy); await userConfig!.currentUser!.delete(); diff --git a/lib/views/group_screen.dart b/lib/views/group_screen.dart index c77b3492..b7b368f0 100644 --- a/lib/views/group_screen.dart +++ b/lib/views/group_screen.dart @@ -4,7 +4,6 @@ import 'package:beacon/components/hike_button.dart'; import 'package:beacon/components/loading_screen.dart'; import 'package:beacon/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:flutter/material.dart'; @@ -23,9 +22,6 @@ class GroupScreen extends StatefulWidget { class _GroupScreenState extends State with TickerProviderStateMixin { - late List fetchingUserBeacons; - late List fetchingNearbyBeacons; - @override void initState() { super.initState(); @@ -36,22 +32,6 @@ class _GroupScreenState extends State }); } - fetchUserBeacons() async { - return await databaseFunctions!.fetchUserBeacons(widget.group.id); - } - - fetchNearByBeacons() async { - return await databaseFunctions!.fetchNearbyBeacon(widget.group.id); - } - - reloadList() async { - fetchingUserBeacons = - await databaseFunctions!.fetchUserBeacons(widget.group.id); - fetchingNearbyBeacons = await databaseFunctions! - .fetchNearbyBeacon(widget.group.id) as List; - setState(() {}); - } - @override Widget build(BuildContext context) { TabController tabController = new TabController(length: 2, vsync: this); @@ -112,8 +92,6 @@ class _GroupScreenState extends State borderRadius: BorderRadius.circular(10.0), ), - // actionsAlignment: - // MainAxisAlignment.spaceEvenly, title: Text( 'Group members', textAlign: TextAlign.center, @@ -121,66 +99,87 @@ class _GroupScreenState extends State fontSize: 25, color: kYellow), ), content: Container( - height: 250, - width: 250, - child: Builder( - builder: (context) { - if (groupviewmodel - .loadingGroupMembers) { - return Center( - child: BeaconCustomWidgets - .getPlaceholder(), - ); - } else { - return groupviewmodel - .groupMembers.isEmpty - ? Container( - child: Text('emplty'), + height: 250, + width: 250, + child: ListView( + children: [ + widget.group.leader == null + ? Container() + : Container( + padding: EdgeInsets + .symmetric( + horizontal: 5), + margin: EdgeInsets + .symmetric( + vertical: 5), + height: 7.h, + width: 50.w, + decoration: + BoxDecoration( + color: + kLightBlue), + child: Row( + mainAxisAlignment: + MainAxisAlignment + .spaceBetween, + children: [ + Text(widget.group + .leader!.name + .toString()), + Text('(leader)') + ], + ), + ), + widget.group.members == null + ? Container() + : Container( + width: 250, + height: 250, + child: ListView.builder( + physics: + NeverScrollableScrollPhysics(), + itemCount: widget + .group + .members! + .length, + itemBuilder: + (context, index) { + return Container( + padding: EdgeInsets + .symmetric( + horizontal: + 5), + margin: EdgeInsets + .symmetric( + vertical: + 5), + height: 7.h, + width: 50.w, + decoration: + BoxDecoration( + color: + kLightBlue), + child: Row( + mainAxisAlignment: + MainAxisAlignment + .spaceBetween, + children: [ + Text(widget + .group + .members![ + index] + .name + .toString()), + Text( + '(member)') + ], + ), + ); + }, + ), ) - : ListView.builder( - itemCount: - groupviewmodel - .groupMembers - .length, - itemBuilder: - (context, index) { - return Container( - padding: EdgeInsets - .symmetric( - horizontal: - 5), - margin: EdgeInsets - .symmetric( - vertical: - 5), - height: 7.h, - width: 50.w, - decoration: - BoxDecoration( - color: - kLightBlue), - child: Row( - mainAxisAlignment: - MainAxisAlignment - .spaceBetween, - children: [ - Text(groupviewmodel - .groupMembers[ - index] - .name - .toString()), - Text(index == 0 - ? '(leader)' - : '(member)') - ], - ), - ); - }, - ); - } - }, - ), - ), + ], + )), )), backgroundColor: kYellow, child: Icon(Icons.list), @@ -290,7 +289,7 @@ class _GroupScreenState extends State buttonColor: Colors.white, onTap: () async { CreateJoinBeaconDialog.joinBeaconDialog( - context, groupviewmodel, reloadList); + context, groupviewmodel); }, ), ), From 4d7f627e11742b8da70c5b59e3ab45068112419d Mon Sep 17 00:00:00 2001 From: Abhishek Date: Tue, 20 Feb 2024 19:31:58 +0530 Subject: [PATCH 09/12] keys removed --- android/app/src/main/AndroidManifest.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/android/app/src/main/AndroidManifest.xml b/android/app/src/main/AndroidManifest.xml index 1820f9f3..a883ac95 100644 --- a/android/app/src/main/AndroidManifest.xml +++ b/android/app/src/main/AndroidManifest.xml @@ -10,7 +10,7 @@ android:label="Beacon" android:icon="@mipmap/launcher_icon" android:usesCleartextTraffic="true"> - + Date: Fri, 23 Feb 2024 02:50:36 +0530 Subject: [PATCH 10/12] dart format applied --- android/app/src/main/AndroidManifest.xml | 2 +- lib/components/hike_screen_widget.dart | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/android/app/src/main/AndroidManifest.xml b/android/app/src/main/AndroidManifest.xml index a883ac95..be699edb 100644 --- a/android/app/src/main/AndroidManifest.xml +++ b/android/app/src/main/AndroidManifest.xml @@ -10,7 +10,7 @@ android:label="Beacon" android:icon="@mipmap/launcher_icon" android:usesCleartextTraffic="true"> - + Date: Fri, 23 Feb 2024 03:02:38 +0530 Subject: [PATCH 11/12] formatted --- lib/services/local_notification.dart | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/services/local_notification.dart b/lib/services/local_notification.dart index 72961624..c9624697 100644 --- a/lib/services/local_notification.dart +++ b/lib/services/local_notification.dart @@ -78,14 +78,14 @@ class LocalNotification { ); // We have to check if the hike is after 1 hour or not - var scheduledDate2 = await tz.TZDateTime.from( + tz.TZDateTime scheduledDate2 = await tz.TZDateTime.from( DateTime.fromMillisecondsSinceEpoch(beacon.startsAt!), tz.local, ).subtract(Duration(hours: 1)); - // We will check if beacon start time is less than the 2nd notification scheduling time + // We will check if the beacon scheduled time is after then the current time - if (scheduledDate2.compareTo(scheduledDate1) < 0) return; + if (scheduledDate2.compareTo(tz.TZDateTime.now(tz.local)) < 0) return; await flutterLocalNotificationsPlugin.zonedSchedule( beacon.id.hashCode, From 779229ff071cb5a548aa9b7d97b58d9b3874975b Mon Sep 17 00:00:00 2001 From: Abhishek Date: Fri, 23 Feb 2024 03:23:45 +0530 Subject: [PATCH 12/12] fixed formatting --- lib/services/local_notification.dart | 6 ------ 1 file changed, 6 deletions(-) diff --git a/lib/services/local_notification.dart b/lib/services/local_notification.dart index 3c776f40..c9624697 100644 --- a/lib/services/local_notification.dart +++ b/lib/services/local_notification.dart @@ -48,7 +48,6 @@ class LocalNotification { } Future scheduleNotification(Beacon beacon) async { - tz.TZDateTime scheduledDate1 = await tz.TZDateTime.from( DateTime.fromMillisecondsSinceEpoch(beacon.startsAt!), tz.local); await flutterLocalNotificationsPlugin.zonedSchedule( @@ -79,20 +78,15 @@ class LocalNotification { ); // We have to check if the hike is after 1 hour or not - tz.TZDateTime scheduledDate2 = await tz.TZDateTime.from( DateTime.fromMillisecondsSinceEpoch(beacon.startsAt!), tz.local, ).subtract(Duration(hours: 1)); - // We will check if the beacon scheduled time is after then the current time if (scheduledDate2.compareTo(tz.TZDateTime.now(tz.local)) < 0) return; - - - await flutterLocalNotificationsPlugin.zonedSchedule( beacon.id.hashCode, 'Reminder: ' + beacon.title! + ' will start in an hour',