diff --git a/.gitignore b/.gitignore
index a7b2b06b..fe1246bb 100644
--- a/.gitignore
+++ b/.gitignore
@@ -40,6 +40,9 @@ app.*.symbols
# Obfuscation related
app.*.map.json
+# Keystore file path when building apk on windows
+/android/app/onestop-keystore.jks
+
# Android Studio will place build artifacts here
/android/app/debug
/android/app/profile
diff --git a/android/app/build.gradle b/android/app/build.gradle
index 9e6e40ee..7cbf5298 100644
--- a/android/app/build.gradle
+++ b/android/app/build.gradle
@@ -34,6 +34,7 @@ if (project.hasProperty('dart-defines')) {
apply plugin: 'com.android.application'
+apply plugin: 'com.google.gms.google-services'
apply plugin: 'kotlin-android'
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"
@@ -67,6 +68,7 @@ android {
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
manifestPlaceholders['GMAP_KEY'] = dartEnvironmentVariables.GMAP_KEY
+ multiDexEnabled true
}
signingConfigs {
@@ -90,5 +92,6 @@ flutter {
dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version"
+ implementation "com.android.support:multidex:1.0.3"
}
diff --git a/android/app/google-services.json b/android/app/google-services.json
new file mode 100644
index 00000000..ab204a0f
--- /dev/null
+++ b/android/app/google-services.json
@@ -0,0 +1,46 @@
+{
+ "project_info": {
+ "project_number": "755380116666",
+ "project_id": "onestopiitg-2",
+ "storage_bucket": "onestopiitg-2.appspot.com"
+ },
+ "client": [
+ {
+ "client_info": {
+ "mobilesdk_app_id": "1:755380116666:android:93baf948818388bfe2f683",
+ "android_client_info": {
+ "package_name": "com.swciitg.onestop2"
+ }
+ },
+ "oauth_client": [
+ {
+ "client_id": "755380116666-8eqlpn3rnrp3j4v1unhonm6qldqhek2c.apps.googleusercontent.com",
+ "client_type": 3
+ }
+ ],
+ "api_key": [
+ {
+ "current_key": "AIzaSyBsoG-Xp8P2FGth4pE38cUyT2ljSjrAfLE"
+ }
+ ],
+ "services": {
+ "appinvite_service": {
+ "other_platform_oauth_client": [
+ {
+ "client_id": "755380116666-8eqlpn3rnrp3j4v1unhonm6qldqhek2c.apps.googleusercontent.com",
+ "client_type": 3
+ },
+ {
+ "client_id": "755380116666-7glnointr5aktgrk2rvsonjlfjvuoqpq.apps.googleusercontent.com",
+ "client_type": 2,
+ "ios_info": {
+ "bundle_id": "com.example.testNotification"
+ }
+ }
+ ]
+ }
+ }
+ }
+ ],
+ "configuration_version": "1"
+}
\ No newline at end of file
diff --git a/android/app/src/main/AndroidManifest.xml b/android/app/src/main/AndroidManifest.xml
index d68f0ebc..89c795cf 100644
--- a/android/app/src/main/AndroidManifest.xml
+++ b/android/app/src/main/AndroidManifest.xml
@@ -17,7 +17,9 @@
android:theme="@style/LaunchTheme"
android:configChanges="orientation|keyboardHidden|keyboard|screenSize|smallestScreenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode"
android:hardwareAccelerated="true"
- android:windowSoftInputMode="adjustResize">
+ android:windowSoftInputMode="adjustResize"
+ android:showWhenLocked="true"
+ android:turnScreenOn="true">
+
+
+
+
diff --git a/android/app/src/main/res/drawable-hdpi/ic_stat_notification_icon.png b/android/app/src/main/res/drawable-hdpi/ic_stat_notification_icon.png
new file mode 100644
index 00000000..7df3134f
Binary files /dev/null and b/android/app/src/main/res/drawable-hdpi/ic_stat_notification_icon.png differ
diff --git a/android/app/src/main/res/drawable-mdpi/ic_stat_notification_icon.png b/android/app/src/main/res/drawable-mdpi/ic_stat_notification_icon.png
new file mode 100644
index 00000000..5690b961
Binary files /dev/null and b/android/app/src/main/res/drawable-mdpi/ic_stat_notification_icon.png differ
diff --git a/android/app/src/main/res/drawable-xhdpi/ic_stat_notification_icon.png b/android/app/src/main/res/drawable-xhdpi/ic_stat_notification_icon.png
new file mode 100644
index 00000000..8eb46c1d
Binary files /dev/null and b/android/app/src/main/res/drawable-xhdpi/ic_stat_notification_icon.png differ
diff --git a/android/app/src/main/res/drawable-xxhdpi/ic_stat_notification_icon.png b/android/app/src/main/res/drawable-xxhdpi/ic_stat_notification_icon.png
new file mode 100644
index 00000000..16159e73
Binary files /dev/null and b/android/app/src/main/res/drawable-xxhdpi/ic_stat_notification_icon.png differ
diff --git a/android/app/src/main/res/drawable-xxxhdpi/ic_stat_notification_icon.png b/android/app/src/main/res/drawable-xxxhdpi/ic_stat_notification_icon.png
new file mode 100644
index 00000000..b6e72cda
Binary files /dev/null and b/android/app/src/main/res/drawable-xxxhdpi/ic_stat_notification_icon.png differ
diff --git a/android/app/src/main/res/drawable/notification_icon.png b/android/app/src/main/res/drawable/notification_icon.png
new file mode 100644
index 00000000..766b161a
Binary files /dev/null and b/android/app/src/main/res/drawable/notification_icon.png differ
diff --git a/android/app/src/main/res/values/colors.xml b/android/app/src/main/res/values/colors.xml
index e71cfdea..4602a4e2 100644
--- a/android/app/src/main/res/values/colors.xml
+++ b/android/app/src/main/res/values/colors.xml
@@ -1,4 +1,5 @@
-
+
#001B3E
+ #76ACFF
\ No newline at end of file
diff --git a/android/build.gradle b/android/build.gradle
index 83ae2200..35e8b225 100644
--- a/android/build.gradle
+++ b/android/build.gradle
@@ -1,5 +1,6 @@
buildscript {
- ext.kotlin_version = '1.6.10'
+ ext.kotlin_version = '1.8.22'
+
repositories {
google()
mavenCentral()
@@ -8,6 +9,7 @@ buildscript {
dependencies {
classpath 'com.android.tools.build:gradle:7.1.2'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
+ classpath 'com.google.gms:google-services:4.3.13'
}
}
@@ -26,6 +28,6 @@ subprojects {
project.evaluationDependsOn(':app')
}
-task clean(type: Delete) {
+tasks.register("clean", Delete) {
delete rootProject.buildDir
}
diff --git a/assets/images/profile_placeholder.png b/assets/images/profile_placeholder.png
new file mode 100644
index 00000000..3fe20584
Binary files /dev/null and b/assets/images/profile_placeholder.png differ
diff --git a/ios/Runner.xcodeproj/project.pbxproj b/ios/Runner.xcodeproj/project.pbxproj
index 52e10fba..f9797b07 100644
--- a/ios/Runner.xcodeproj/project.pbxproj
+++ b/ios/Runner.xcodeproj/project.pbxproj
@@ -10,6 +10,7 @@
1498D2341E8E89220040F4C2 /* GeneratedPluginRegistrant.m in Sources */ = {isa = PBXBuildFile; fileRef = 1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */; };
3B3967161E833CAA004F5970 /* AppFrameworkInfo.plist in Resources */ = {isa = PBXBuildFile; fileRef = 3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */; };
74858FAF1ED2DC5600515810 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 74858FAE1ED2DC5600515810 /* AppDelegate.swift */; };
+ 797FFB145D937626B7EA4ADA /* GoogleService-Info.plist in Resources */ = {isa = PBXBuildFile; fileRef = 9822E429D96AFE0F8D730785 /* GoogleService-Info.plist */; };
97C146FC1CF9000F007C117D /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FA1CF9000F007C117D /* Main.storyboard */; };
97C146FE1CF9000F007C117D /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FD1CF9000F007C117D /* Assets.xcassets */; };
97C147011CF9000F007C117D /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FF1CF9000F007C117D /* LaunchScreen.storyboard */; };
@@ -46,7 +47,9 @@
97C146FD1CF9000F007C117D /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; };
97C147001CF9000F007C117D /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; };
97C147021CF9000F007C117D /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; };
+ 9822E429D96AFE0F8D730785 /* GoogleService-Info.plist */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.plist.xml; name = "GoogleService-Info.plist"; path = "Runner/GoogleService-Info.plist"; sourceTree = ""; };
C05463DD6012FC0ED5AB6BC0 /* Pods-Runner.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runner.release.xcconfig"; path = "Target Support Files/Pods-Runner/Pods-Runner.release.xcconfig"; sourceTree = ""; };
+ D800439E29DB5F970022C839 /* Runner.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = Runner.entitlements; sourceTree = ""; };
/* End PBXFileReference section */
/* Begin PBXFrameworksBuildPhase section */
@@ -98,6 +101,7 @@
97C146EF1CF9000F007C117D /* Products */,
94BCE952F797F377FEC6B694 /* Pods */,
550921A1AB19070431638329 /* Frameworks */,
+ 9822E429D96AFE0F8D730785 /* GoogleService-Info.plist */,
);
sourceTree = "";
};
@@ -112,6 +116,7 @@
97C146F01CF9000F007C117D /* Runner */ = {
isa = PBXGroup;
children = (
+ D800439E29DB5F970022C839 /* Runner.entitlements */,
97C146FA1CF9000F007C117D /* Main.storyboard */,
97C146FD1CF9000F007C117D /* Assets.xcassets */,
97C146FF1CF9000F007C117D /* LaunchScreen.storyboard */,
@@ -192,6 +197,7 @@
3B3967161E833CAA004F5970 /* AppFrameworkInfo.plist in Resources */,
97C146FE1CF9000F007C117D /* Assets.xcassets in Resources */,
97C146FC1CF9000F007C117D /* Main.storyboard in Resources */,
+ 797FFB145D937626B7EA4ADA /* GoogleService-Info.plist in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
@@ -222,6 +228,7 @@
files = (
);
inputPaths = (
+ "${TARGET_BUILD_DIR}/${INFOPLIST_PATH}",
);
name = "Thin Binary";
outputPaths = (
@@ -374,6 +381,7 @@
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CLANG_ENABLE_MODULES = YES;
+ CODE_SIGN_ENTITLEMENTS = Runner/Runner.entitlements;
CODE_SIGN_IDENTITY = "Apple Development";
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)";
@@ -506,6 +514,7 @@
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CLANG_ENABLE_MODULES = YES;
+ CODE_SIGN_ENTITLEMENTS = Runner/Runner.entitlements;
CODE_SIGN_IDENTITY = "Apple Development";
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)";
@@ -532,6 +541,7 @@
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CLANG_ENABLE_MODULES = YES;
+ CODE_SIGN_ENTITLEMENTS = Runner/Runner.entitlements;
CODE_SIGN_IDENTITY = "Apple Development";
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)";
diff --git a/ios/Runner/AppDelegate.swift b/ios/Runner/AppDelegate.swift
index 435706da..7473d1f9 100644
--- a/ios/Runner/AppDelegate.swift
+++ b/ios/Runner/AppDelegate.swift
@@ -1,6 +1,8 @@
import UIKit
import Flutter
import GoogleMaps
+import flutter_local_notifications
+
@UIApplicationMain
@objc class AppDelegate: FlutterAppDelegate {
@@ -8,6 +10,12 @@ import GoogleMaps
_ application: UIApplication,
didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?
) -> Bool {
+ if #available(iOS 10.0, *) {
+ UNUserNotificationCenter.current().delegate = self as? UNUserNotificationCenterDelegate
+ }
+ FlutterLocalNotificationsPlugin.setPluginRegistrantCallback { (registry) in
+ GeneratedPluginRegistrant.register(with: registry)
+ }
let dartDefinesString = Bundle.main.infoDictionary!["DART_DEFINES"] as! String
var dartDefinesDictionary = [String:String]()
for definedValue in dartDefinesString.components(separatedBy: ",") {
diff --git a/ios/Runner/GoogleService-Info.plist b/ios/Runner/GoogleService-Info.plist
new file mode 100644
index 00000000..4194fa6c
--- /dev/null
+++ b/ios/Runner/GoogleService-Info.plist
@@ -0,0 +1,34 @@
+
+
+
+
+ CLIENT_ID
+ 755380116666-if5jvrpuk5hja4qtlqoaa5eil2nlhmaa.apps.googleusercontent.com
+ REVERSED_CLIENT_ID
+ com.googleusercontent.apps.755380116666-if5jvrpuk5hja4qtlqoaa5eil2nlhmaa
+ API_KEY
+ AIzaSyDwfpfZYu7h93Ze4XfU00EdYA-b2Tr39Kk
+ GCM_SENDER_ID
+ 755380116666
+ PLIST_VERSION
+ 1
+ BUNDLE_ID
+ com.swciitg.onestop2swc2022
+ PROJECT_ID
+ onestopiitg-2
+ STORAGE_BUCKET
+ onestopiitg-2.appspot.com
+ IS_ADS_ENABLED
+
+ IS_ANALYTICS_ENABLED
+
+ IS_APPINVITE_ENABLED
+
+ IS_GCM_ENABLED
+
+ IS_SIGNIN_ENABLED
+
+ GOOGLE_APP_ID
+ 1:755380116666:ios:2fde1264d6300380e2f683
+
+
\ No newline at end of file
diff --git a/ios/Runner/Info.plist b/ios/Runner/Info.plist
index 10967e83..d43565b1 100644
--- a/ios/Runner/Info.plist
+++ b/ios/Runner/Info.plist
@@ -58,6 +58,13 @@
This app needs access to location to show you the nearest bus stops, ferry ghats, restaurants etc.
NSPhotoLibraryUsageDescription
This app requires Photo Library access for Lost/Found or Buy/Sell images
+ UIApplicationSupportsIndirectInputEvents
+
+ UIBackgroundModes
+
+ fetch
+ remote-notification
+
UILaunchStoryboardName
LaunchScreen
UIMainStoryboardFile
@@ -77,7 +84,5 @@
UIViewControllerBasedStatusBarAppearance
- UIApplicationSupportsIndirectInputEvents
-
diff --git a/ios/Runner/Runner.entitlements b/ios/Runner/Runner.entitlements
new file mode 100644
index 00000000..903def2a
--- /dev/null
+++ b/ios/Runner/Runner.entitlements
@@ -0,0 +1,8 @@
+
+
+
+
+ aps-environment
+ development
+
+
diff --git a/ios/firebase_app_id_file.json b/ios/firebase_app_id_file.json
new file mode 100644
index 00000000..afae3c1b
--- /dev/null
+++ b/ios/firebase_app_id_file.json
@@ -0,0 +1,7 @@
+{
+ "file_generated_by": "FlutterFire CLI",
+ "purpose": "FirebaseAppID & ProjectID for this Firebase app in this directory",
+ "GOOGLE_APP_ID": "1:755380116666:ios:2fde1264d6300380e2f683",
+ "FIREBASE_PROJECT_ID": "onestopiitg-2",
+ "GCM_SENDER_ID": "755380116666"
+}
\ No newline at end of file
diff --git a/lib/firebase_options.dart b/lib/firebase_options.dart
new file mode 100644
index 00000000..02293bc0
--- /dev/null
+++ b/lib/firebase_options.dart
@@ -0,0 +1,69 @@
+// File generated by FlutterFire CLI.
+// ignore_for_file: lines_longer_than_80_chars, avoid_classes_with_only_static_members
+import 'package:firebase_core/firebase_core.dart' show FirebaseOptions;
+import 'package:flutter/foundation.dart'
+ show defaultTargetPlatform, kIsWeb, TargetPlatform;
+
+/// Default [FirebaseOptions] for use with your Firebase apps.
+///
+/// Example:
+/// ```dart
+/// import 'firebase_options.dart';
+/// // ...
+/// await Firebase.initializeApp(
+/// options: DefaultFirebaseOptions.currentPlatform,
+/// );
+/// ```
+class DefaultFirebaseOptions {
+ static FirebaseOptions get currentPlatform {
+ if (kIsWeb) {
+ throw UnsupportedError(
+ 'DefaultFirebaseOptions have not been configured for web - '
+ 'you can reconfigure this by running the FlutterFire CLI again.',
+ );
+ }
+ switch (defaultTargetPlatform) {
+ case TargetPlatform.android:
+ return android;
+ case TargetPlatform.iOS:
+ return ios;
+ case TargetPlatform.macOS:
+ throw UnsupportedError(
+ 'DefaultFirebaseOptions have not been configured for macos - '
+ 'you can reconfigure this by running the FlutterFire CLI again.',
+ );
+ case TargetPlatform.windows:
+ throw UnsupportedError(
+ 'DefaultFirebaseOptions have not been configured for windows - '
+ 'you can reconfigure this by running the FlutterFire CLI again.',
+ );
+ case TargetPlatform.linux:
+ throw UnsupportedError(
+ 'DefaultFirebaseOptions have not been configured for linux - '
+ 'you can reconfigure this by running the FlutterFire CLI again.',
+ );
+ default:
+ throw UnsupportedError(
+ 'DefaultFirebaseOptions are not supported for this platform.',
+ );
+ }
+ }
+
+ static const FirebaseOptions android = FirebaseOptions(
+ apiKey: 'AIzaSyBsoG-Xp8P2FGth4pE38cUyT2ljSjrAfLE',
+ appId: '1:755380116666:android:93baf948818388bfe2f683',
+ messagingSenderId: '755380116666',
+ projectId: 'onestopiitg-2',
+ storageBucket: 'onestopiitg-2.appspot.com',
+ );
+
+ static const FirebaseOptions ios = FirebaseOptions(
+ apiKey: 'AIzaSyDwfpfZYu7h93Ze4XfU00EdYA-b2Tr39Kk',
+ appId: '1:755380116666:ios:2fde1264d6300380e2f683',
+ messagingSenderId: '755380116666',
+ projectId: 'onestopiitg-2',
+ storageBucket: 'onestopiitg-2.appspot.com',
+ iosClientId: '755380116666-if5jvrpuk5hja4qtlqoaa5eil2nlhmaa.apps.googleusercontent.com',
+ iosBundleId: 'com.swciitg.onestop2swc2022',
+ );
+}
diff --git a/lib/functions/buysell/get_items.dart b/lib/functions/buysell/get_items.dart
index 426daa32..8304f443 100644
--- a/lib/functions/buysell/get_items.dart
+++ b/lib/functions/buysell/get_items.dart
@@ -1,8 +1,8 @@
-import 'package:onestop_dev/services/api.dart';
-
-Future getBuySellItems(mail) async {
- var list1 = await APIService.getBuyItems();
- var list2 = await APIService.getSellItems();
- var list3 = await APIService.getBnsMyItems(mail);
- return [list1, list2, list3];
-}
+// import 'package:onestop_dev/services/api.dart';
+//
+// Future getBuySellItems(mail) async {
+// var list1 = await APIService().getBuyItems();
+// var list2 = await APIService.getSellItems();
+// var list3 = await APIService.getBnsMyItems(mail);
+// return [list1, list2, list3];
+// }
diff --git a/lib/functions/food/get_day.dart b/lib/functions/food/get_day.dart
index 141fd3ee..b38e2be8 100644
--- a/lib/functions/food/get_day.dart
+++ b/lib/functions/food/get_day.dart
@@ -4,3 +4,7 @@ String getFormattedDay() {
DateTime now = DateTime.now();
return DateFormat("EEE").format(now);
}
+String getFormattedDayForMess() {
+ DateTime now = DateTime.now();
+ return DateFormat("EEEE").format(now);
+}
diff --git a/lib/functions/home/action_button.dart b/lib/functions/home/action_button.dart
index 0b7ca7e6..38dbbbb4 100644
--- a/lib/functions/home/action_button.dart
+++ b/lib/functions/home/action_button.dart
@@ -2,9 +2,11 @@ import 'package:fluentui_system_icons/fluentui_system_icons.dart';
import 'package:flutter/material.dart';
import 'package:onestop_dev/functions/timetable/show_dialog.dart';
import 'package:onestop_dev/globals/my_colors.dart';
+import 'package:onestop_dev/stores/login_store.dart';
+import 'package:provider/provider.dart';
Widget homeActionButton(BuildContext context, int index) {
- return (index == 3)
+ return (index == 3 && !LoginStore.isGuest)
? FloatingActionButton(
backgroundColor: lBlue2,
shape:
diff --git a/lib/functions/notifications/get_notifications.dart b/lib/functions/notifications/get_notifications.dart
new file mode 100644
index 00000000..90d3caf6
--- /dev/null
+++ b/lib/functions/notifications/get_notifications.dart
@@ -0,0 +1,27 @@
+import 'dart:convert';
+
+import 'package:onestop_dev/pages/notifications/notifications.dart';
+import 'package:shared_preferences/shared_preferences.dart';
+
+Future> getSavedNotifications(bool changeReadStatus) async {
+ List n = [];
+ List newNotifList = [];
+ n.clear();
+ final SharedPreferences prefs = await SharedPreferences.getInstance();
+ await prefs.reload();
+ List result = prefs.getStringList('notifications')!;
+ for (String r in result) {
+ Map notifData = jsonDecode(r);
+ print("Notif Data = $notifData");
+ n.add(NotifsModel(notifData['header'], notifData['body'],
+ notifData['read'], notifData['category'], DateTime.parse(notifData['time']), notifData['messageId']));
+ if (changeReadStatus) {
+ // Set Read Recipient to True and then save to prefs
+ notifData['read'] = true;
+ }
+ newNotifList.add(jsonEncode(notifData));
+ }
+
+ prefs.setStringList('notifications', newNotifList);
+ return n.reversed.toList();
+}
diff --git a/lib/functions/travel/has_left.dart b/lib/functions/travel/has_left.dart
index d5e96dc0..68a94c81 100644
--- a/lib/functions/travel/has_left.dart
+++ b/lib/functions/travel/has_left.dart
@@ -1,44 +1,46 @@
-import 'package:intl/intl.dart';
-
-bool hasLeft(String inputTime) {
- var currentTime = DateTime.now();
- List currentHour =
- DateFormat.j().format(currentTime).toString().split(' ');
- List inputHour = inputTime.split(' ');
-
- //Checking if both AM or both PM
- if (inputHour[1] == currentHour[1]) {
- List hm = inputHour[0].split(':');
- int a = int.parse(hm[0]);
- int b = int.parse(currentHour[0]);
-
- if (a == 12) {
- a = 0;
- }
- if (b == 12) {
- b = 0;
- }
-
- //Checking if both have same hour
- if (a > b) {
- return false;
- } else if (a < b) {
- return true;
- } else {
- //Checking if both have same minute
- a = int.parse(hm[1]);
- b = int.parse(DateFormat.m().format(currentTime));
- if (a > b) {
- return false;
- } else {
- return true;
- }
- }
- } else {
- if (inputHour[1] == 'AM') {
- return true;
- } else {
- return false;
- }
- }
+bool hasLeft(DateTime s) {
+ DateTime x = DateTime.now();
+ return x.isBefore(s);
}
+// bool hasLeft(String inputTime) {
+// var currentTime = DateTime.now();
+// List currentHour =
+// DateFormat.j().format(currentTime).toString().split(' ');
+// List inputHour = inputTime.split(' ');
+//
+// //Checking if both AM or both PM
+// if (inputHour[1] == currentHour[1]) {
+// List hm = inputHour[0].split(':');
+// int a = int.parse(hm[0]);
+// int b = int.parse(currentHour[0]);
+//
+// if (a == 12) {
+// a = 0;
+// }
+// if (b == 12) {
+// b = 0;
+// }
+//
+// //Checking if both have same hour
+// if (a > b) {
+// return false;
+// } else if (a < b) {
+// return true;
+// } else {
+// //Checking if both have same minute
+// a = int.parse(hm[1]);
+// b = int.parse(DateFormat.m().format(currentTime));
+// if (a > b) {
+// return false;
+// } else {
+// return true;
+// }
+// }
+// } else {
+// if (inputHour[1] == 'AM') {
+// return true;
+// } else {
+// return false;
+// }
+// }
+// }
diff --git a/lib/functions/travel/next_time.dart b/lib/functions/travel/next_time.dart
index f9d7784b..167b869d 100644
--- a/lib/functions/travel/next_time.dart
+++ b/lib/functions/travel/next_time.dart
@@ -1,23 +1,32 @@
import 'package:onestop_dev/functions/travel/has_left.dart';
-
-String nextTime(List timings, {String firstTime = ''}) {
- String answer = "Nothing";
- for (String time in timings) {
+String nextTime(List timings, {String firstTime = ''}) {
+ DateTime answer = DateTime.now();
+ bool changed = false;
+ for (var time in timings) {
if (!hasLeft(time)) {
answer = time;
+ changed = true;
break;
}
}
- if (answer == "Nothing") {
+
+ if (!changed) {
if (firstTime == '') {
answer = timings[0];
} else {
- answer = firstTime;
+ answer = DateTime.parse(firstTime);
}
}
- return answer;
+ String a= formatTime(answer);
+ return a;
+}
+String formatTime(DateTime dateTime) {
+ var hour = dateTime.hour;
+ hour=hour>12?hour-12:hour;
+ final minute = dateTime.minute.toString().padLeft(2, '0');
+ final period = dateTime.hour < 12 ? 'AM' : 'PM';
+ return '$hour:$minute $period';
}
-
int parseTime(String time) {
var components = time.split(RegExp('[: ]'));
if (components.length != 3) {
@@ -41,3 +50,46 @@ int parseTime(String time) {
return hours * 100 + minutes;
}
+
+//
+// String nextTime(List timings, {String firstTime = ''}) {
+// String answer = "Nothing";
+// for (String time in timings) {
+// if (!hasLeft(time)) {
+// answer = time;
+// break;
+// }
+// }
+// if (answer == "Nothing") {
+// if (firstTime == '') {
+// answer = timings[0];
+// } else {
+// answer = firstTime;
+// }
+// }
+// return answer;
+// }
+//
+// int parseTime(String time) {
+// var components = time.split(RegExp('[: ]'));
+// if (components.length != 3) {
+// throw FormatException('Time not in the expected format: $time');
+// }
+// var hours = int.parse(components[0]);
+// var minutes = int.parse(components[1]);
+// var period = components[2].toUpperCase();
+//
+// if (hours < 1 || hours > 12 || minutes < 0 || minutes > 59) {
+// throw FormatException('Time not in the expected format: $time');
+// }
+//
+// if (hours == 12) {
+// hours = 0;
+// }
+//
+// if (period == 'PM') {
+// hours += 12;
+// }
+//
+// return hours * 100 + minutes;
+// }
diff --git a/lib/functions/utility/auth_user_helper.dart b/lib/functions/utility/auth_user_helper.dart
new file mode 100644
index 00000000..11044e9d
--- /dev/null
+++ b/lib/functions/utility/auth_user_helper.dart
@@ -0,0 +1,24 @@
+import 'package:onestop_dev/globals/database_strings.dart';
+import 'package:shared_preferences/shared_preferences.dart';
+
+class AuthUserHelpers{
+ static Future getAccessToken() async {
+ SharedPreferences prefs = await SharedPreferences.getInstance();
+ return prefs.getString(BackendHelper.accesstoken) ?? " ";
+ }
+
+ static Future setAccessToken(String value) async {
+ SharedPreferences prefs = await SharedPreferences.getInstance();
+ await prefs.setString(BackendHelper.accesstoken, value);
+ }
+
+ static Future getRefreshToken() async {
+ SharedPreferences prefs = await SharedPreferences.getInstance();
+ return prefs.getString(BackendHelper.refreshtoken) ?? " ";
+ }
+
+ static Future setRefreshToken(String value) async {
+ SharedPreferences prefs = await SharedPreferences.getInstance();
+ await prefs.setString(BackendHelper.refreshtoken, value);
+ }
+}
\ No newline at end of file
diff --git a/lib/functions/utility/check_last_updated.dart b/lib/functions/utility/check_last_updated.dart
index f31677d6..46de44d6 100644
--- a/lib/functions/utility/check_last_updated.dart
+++ b/lib/functions/utility/check_last_updated.dart
@@ -1,13 +1,15 @@
import 'package:flutter/foundation.dart';
+import 'package:flutter/material.dart';
import 'package:onestop_dev/globals/database_strings.dart';
import 'package:onestop_dev/services/api.dart';
import 'package:onestop_dev/services/data_provider.dart';
import 'package:onestop_dev/services/local_storage.dart';
+import 'package:shared_preferences/shared_preferences.dart';
Map> recordNames = {
- "food": [DatabaseRecords.restaurant],
- "travel": [DatabaseRecords.busTimings, DatabaseRecords.ferryTimings],
- "menu": [DatabaseRecords.messMenu],
+ "foodOutlet": [DatabaseRecords.restaurant],
+ "timing": [DatabaseRecords.busTimings, DatabaseRecords.ferryTimings],
+ "messMenu": [DatabaseRecords.messMenu],
"contact": [DatabaseRecords.contacts]
};
@@ -15,11 +17,12 @@ Future checkLastUpdated() async {
Map? lastUpdated = await DataProvider.getLastUpdated();
try {
- Map last = await APIService.getLastUpdated();
+ Map last = await APIService().getLastUpdated();
if (lastUpdated == null) {
await LocalStorage.instance.deleteAllRecord();
- await LocalStorage.instance.storeData([last], DatabaseRecords.lastUpdated);
+ await LocalStorage.instance
+ .storeData([last], DatabaseRecords.lastUpdated);
return true;
}
for (var key in lastUpdated.keys) {
diff --git a/lib/functions/utility/pick_file.dart b/lib/functions/utility/pick_file.dart
index 4c269817..fee03e94 100644
--- a/lib/functions/utility/pick_file.dart
+++ b/lib/functions/utility/pick_file.dart
@@ -18,7 +18,7 @@ Future uploadFile(
if (result != null) {
File file = File(result.files.single.path!);
uploadCallback();
- String? responseFilename = await APIService.uploadFileToServer(file);
+ String? responseFilename = await APIService().uploadFileToServer(file);
if (responseFilename == null) {
showSnackBar("There was an error uploading your file");
}
diff --git a/lib/functions/utility/show_snackbar.dart b/lib/functions/utility/show_snackbar.dart
index b21e4505..24dd8795 100644
--- a/lib/functions/utility/show_snackbar.dart
+++ b/lib/functions/utility/show_snackbar.dart
@@ -1,5 +1,6 @@
import 'package:flutter/material.dart';
import 'package:onestop_dev/globals/my_fonts.dart';
+import 'package:dio/dio.dart';
import 'package:onestop_dev/main.dart';
void showSnackBar(String message) {
@@ -9,3 +10,15 @@ void showSnackBar(String message) {
),
);
}
+
+void showErrorSnackBar(DioException err) {
+ rootScaffoldMessengerKey.currentState?.showSnackBar(SnackBar(
+ content: Text(
+ (err.response != null)
+ ? err.response!.data['message']
+ : "Some error occurred. try again",
+ style: MyFonts.w500,
+ ),
+ duration: const Duration(seconds: 5),
+ ));
+}
diff --git a/lib/functions/utility/validator.dart b/lib/functions/utility/validator.dart
new file mode 100644
index 00000000..d10481f1
--- /dev/null
+++ b/lib/functions/utility/validator.dart
@@ -0,0 +1,7 @@
+String? validatefield(String? value) {
+
+ if (value == null || value.isEmpty) {
+ return 'Field cannot be empty';
+ }
+ return null;
+}
\ No newline at end of file
diff --git a/lib/globals/database_strings.dart b/lib/globals/database_strings.dart
index e7ee39c2..b7407ef5 100644
--- a/lib/globals/database_strings.dart
+++ b/lib/globals/database_strings.dart
@@ -7,4 +7,10 @@ abstract class DatabaseRecords {
static const messMenu = "MessMenu";
static const ferryTimings = "FerryTimings";
static const busTimings = "BusTimings";
+}
+
+class BackendHelper {
+ static const refreshtoken = "refreshToken";
+ static const accesstoken = "accessToken";
+ static const authorization = "authorization";
}
\ No newline at end of file
diff --git a/lib/globals/endpoints.dart b/lib/globals/endpoints.dart
new file mode 100644
index 00000000..92040a7c
--- /dev/null
+++ b/lib/globals/endpoints.dart
@@ -0,0 +1,43 @@
+import 'package:onestop_dev/globals/database_strings.dart';
+
+import '../functions/utility/auth_user_helper.dart';
+
+class Endpoints {
+ static const baseUrl = String.fromEnvironment('SERVER-URL');
+ static const String restaurantURL = "/getAllOutlets";
+ static const String lastUpdatedURL = "/lastDataUpdate";
+ static const String contactURL = "/getContacts";
+ static const String timetableURL = "https://swc.iitg.ac.in/smartTimetable/get-my-courses";
+ static const String ferryURL = '/ferryTimings';
+ static const String busURL = '/busTimings';
+ static const String busStops = '/busstops';
+ static const String messURL = "/hostelsMessMenu";
+ static const String buyURL = '/buy';
+ static const String sellURL = '/sell';
+ static const String buyPath = '/buyPage';
+ static const String sellPath = '/sellPage';
+ static const String bnsMyAdsURL = '/bns/myads';
+ static const String lnfMyAdsURL = '/lnf/myads';
+ static const String deleteBuyURL = "/buy/remove";
+ static const String deleteSellURL = "/sell/remove";
+ static const String deleteLostURL = "/lost/remove";
+ static const String deleteFoundURL = "/found/remove";
+ static const String lostURL = '/lost';
+ static const String lostPath = '/lostPage';
+ static const String foundPath = '/foundPage';
+ static const String foundURL = '/found';
+ static const String claimItemURL = "/found/claim";
+ static const String newsURL = "/news";
+ static const String githubIssueToken = String.fromEnvironment('GITHUB_ISSUE_TOKEN');
+ static const apiSecurityKey = String.fromEnvironment('SECURITY-KEY');
+ static const feedback = 'https://api.github.com/repos/swciitg/onestop_flutter/issues';
+ static const String upspPost = '/upsp/submit-request';
+ static const String uploadFileUPSP = "/upsp/file-upload";
+ static const String guestLogin = "/user/guest/login";
+ static const String userProfile = "/user";
+ static const String userDeviceTokens = "/user/device-tokens";
+ //static const String userLogout = "/user/logout";
+ static getHeader() {
+ return {'Content-Type': 'application/json', 'security-key': Endpoints.apiSecurityKey};
+ }
+}
diff --git a/lib/globals/my_colors.dart b/lib/globals/my_colors.dart
index 2d5e6c76..1e5d6c90 100644
--- a/lib/globals/my_colors.dart
+++ b/lib/globals/my_colors.dart
@@ -42,3 +42,6 @@ const Color kGrey14 = Color.fromRGBO(41, 45, 53, 1);
const Color kGreen = Color.fromRGBO(124, 198, 154, 1);
const Color kBadgeColor = Color.fromRGBO(255, 201, 7, 1);
const Color kTimetableDisabled = Color.fromRGBO(120, 120, 120, 0.16);
+const Color kfocusColor = Color.fromRGBO(94, 94, 94, 1);
+const Color kdatePickerSurfaceColor = Color.fromRGBO(43, 62, 92, 1);
+const Color kGreenDisabled = Color.fromRGBO(124, 198, 154, 0.5);
\ No newline at end of file
diff --git a/lib/main.dart b/lib/main.dart
index e1ce8cec..c559ca29 100644
--- a/lib/main.dart
+++ b/lib/main.dart
@@ -1,24 +1,36 @@
// ignore_for_file: unused_import
-
+import 'package:firebase_core/firebase_core.dart';
+import 'package:firebase_messaging/firebase_messaging.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:onestop_dev/functions/utility/check_last_updated.dart';
import 'package:onestop_dev/globals/my_colors.dart';
import 'package:onestop_dev/routes.dart';
+import 'package:onestop_dev/services/api.dart';
+import 'package:onestop_dev/services/notifications_provider.dart';
import 'package:onestop_dev/stores/common_store.dart';
import 'package:onestop_dev/stores/login_store.dart';
import 'package:onestop_dev/stores/mapbox_store.dart';
import 'package:onestop_dev/stores/restaurant_store.dart';
-import 'package:onestop_dev/stores/timetable_store.dart';
import 'package:provider/provider.dart';
+import './services/api.dart';
+import 'firebase_options.dart';
+
+import 'firebase_options.dart';
void main() async {
WidgetsFlutterBinding.ensureInitialized();
+ await Firebase.initializeApp(options:DefaultFirebaseOptions.currentPlatform);
SystemChrome.setPreferredOrientations(
[DeviceOrientation.portraitDown, DeviceOrientation.portraitUp]);
SystemChrome.setEnabledSystemUIMode(SystemUiMode.manual,
overlays: [SystemUiOverlay.bottom, SystemUiOverlay.top]);
await checkLastUpdated();
+ await checkForNotifications();
+ final fcmToken = await FirebaseMessaging.instance.getToken(); // ask for notification permission
+ print("FCM Token is $fcmToken");
+ // await APIService.createUser(fcmToken ?? '');
+ FirebaseMessaging.onBackgroundMessage(firebaseMessagingBackgroundHandler);
runApp(const MyApp());
}
@@ -30,8 +42,8 @@ class MyApp extends StatelessWidget {
// This widget is the root of your application.
@override
Widget build(BuildContext context) {
+ print("IN MY APP");
debugInvertOversizedImages = true;
-
return MultiProvider(
providers: [
Provider(
@@ -54,7 +66,7 @@ class MyApp extends StatelessWidget {
scaffoldBackgroundColor: kBackground,
splashColor: Colors.transparent),
title: 'OneStop 2.0',
- routes: routes,
+ routes: routes
),
);
}
diff --git a/lib/models/contacts/contact_model.dart b/lib/models/contacts/contact_model.dart
index aa71aac7..537b665d 100644
--- a/lib/models/contacts/contact_model.dart
+++ b/lib/models/contacts/contact_model.dart
@@ -6,15 +6,13 @@ part 'contact_model.g.dart';
@JsonSerializable(explicitToJson: true)
class ContactModel {
@JsonKey(defaultValue: "Untitled")
- late String name;
+ late String sectionName;
@JsonKey(defaultValue: [])
late List contacts;
- @JsonKey(defaultValue: "")
- late String group;
//Constructor
ContactModel(
- {required this.name, required this.contacts, required this.group});
+ {required this.sectionName, required this.contacts});
factory ContactModel.fromJson(Map json) =>
_$ContactModelFromJson(json);
@@ -22,7 +20,7 @@ class ContactModel {
Map toJson() => _$ContactModelToJson(this);
//This constructor also does the work of initialising the variables
// ContactModel.fromJson(Map json) {
- // name = json['name'];
+ // sectionName = json['sectionName'];
// parent = 'Campus';
// contacts = [];
// List.from(json['contacts']).forEach((element) {
diff --git a/lib/models/contacts/contact_model.g.dart b/lib/models/contacts/contact_model.g.dart
index 5e910cba..708d4bf1 100644
--- a/lib/models/contacts/contact_model.g.dart
+++ b/lib/models/contacts/contact_model.g.dart
@@ -7,18 +7,16 @@ part of 'contact_model.dart';
// **************************************************************************
ContactModel _$ContactModelFromJson(Map json) => ContactModel(
- name: json['name'] as String? ?? 'Untitled',
+ sectionName: json['sectionName'] as String? ?? 'Untitled',
contacts: (json['contacts'] as List?)
?.map((e) =>
ContactDetailsModel.fromJson(e as Map))
.toList() ??
[],
- group: json['group'] as String? ?? '',
);
Map _$ContactModelToJson(ContactModel instance) =>
{
- 'name': instance.name,
+ 'sectionName': instance.sectionName,
'contacts': instance.contacts.map((e) => e.toJson()).toList(),
- 'group': instance.group,
};
diff --git a/lib/models/food/dish_model.dart b/lib/models/food/dish_model.dart
index b1d4ae82..b8cae8ca 100644
--- a/lib/models/food/dish_model.dart
+++ b/lib/models/food/dish_model.dart
@@ -6,28 +6,15 @@ part 'dish_model.g.dart';
@JsonSerializable()
class DishModel {
@JsonKey(defaultValue: "Unnamed")
- late String name;
- @JsonKey(defaultValue: false)
- late bool veg;
- @JsonKey(
- defaultValue: " ",
- fromJson: ingredientsFromJson,
- toJson: ingredientsToJson)
- late String ingredients;
+ late String itemName;
@JsonKey(defaultValue: 2)
- late int waiting_time;
- @JsonKey(defaultValue: 150)
late int price;
-
- String image;
+ String imageURL;
DishModel(
- {required this.name,
- required this.veg,
- required this.ingredients,
- required this.waiting_time,
+ {required this.itemName,
required this.price,
- this.image =
+ this.imageURL =
"https://d4t7t8y8xqo0t.cloudfront.net/resized/750X436/eazytrendz%2F3070%2Ftrend20210218124824.jpg"});
factory DishModel.fromJson(Map json) =>
@@ -42,13 +29,4 @@ class DishModel {
// waiting_time = json['waiting_time'] ?? "Not Known";
// price = json['price'] ?? "Not Known";
// }
-}
-
-String ingredientsFromJson(List ing) {
- return ing.toString();
-}
-
-List ingredientsToJson(String ing) {
- ing = ing.substring(1, ing.length - 1);
- return ing.split(',').toList();
-}
+}
\ No newline at end of file
diff --git a/lib/models/food/dish_model.g.dart b/lib/models/food/dish_model.g.dart
index 252ae72d..c4047200 100644
--- a/lib/models/food/dish_model.g.dart
+++ b/lib/models/food/dish_model.g.dart
@@ -7,22 +7,14 @@ part of 'dish_model.dart';
// **************************************************************************
DishModel _$DishModelFromJson(Map json) => DishModel(
- name: json['name'] as String? ?? 'Unnamed',
- veg: json['veg'] as bool? ?? false,
- ingredients: json['ingredients'] == null
- ? ' '
- : ingredientsFromJson(json['ingredients'] as List),
- waiting_time: json['waiting_time'] as int? ?? 2,
- price: json['price'] as int? ?? 150,
- image: json['image'] as String? ??
+ itemName: json['itemName'] as String? ?? 'Unnamed',
+ price: json['price'] as int? ?? 2,
+ imageURL: json['imageURL'] as String? ??
"https://d4t7t8y8xqo0t.cloudfront.net/resized/750X436/eazytrendz%2F3070%2Ftrend20210218124824.jpg",
);
Map _$DishModelToJson(DishModel instance) => {
- 'name': instance.name,
- 'veg': instance.veg,
- 'ingredients': ingredientsToJson(instance.ingredients),
- 'waiting_time': instance.waiting_time,
+ 'itemName': instance.itemName,
'price': instance.price,
- 'image': instance.image,
+ 'imageURL': instance.imageURL,
};
diff --git a/lib/models/food/mess_menu_model.dart b/lib/models/food/mess_menu_model.dart
index 679e0fbb..4e9cfa29 100644
--- a/lib/models/food/mess_menu_model.dart
+++ b/lib/models/food/mess_menu_model.dart
@@ -1,33 +1,97 @@
import 'package:json_annotation/json_annotation.dart';
part 'mess_menu_model.g.dart';
-
@JsonSerializable()
-class MessMenuModel {
- @JsonKey(defaultValue: "Untitled Hostel")
- late String hostel;
+class MessMenu {
+ final String id;
+ final String hostel;
+ final Day monday;
+ final Day tuesday;
+ final Day wednesday;
+ final Day thursday;
+ final Day friday;
+ final Day saturday;
+ final Day sunday;
+ final int v;
+
+ MessMenu({
+ required this.id,
+ required this.hostel,
+ required this.monday,
+ required this.tuesday,
+ required this.wednesday,
+ required this.thursday,
+ required this.friday,
+ required this.saturday,
+ required this.sunday,
+ required this.v,
+ });
+ factory MessMenu.fromJson(Map json) => _$MessMenuFromJson(json);
- @JsonKey(defaultValue: "Untitled Meal")
- late String meal;
+ Map toJson() => _$MessMenuToJson(this);
- @JsonKey(defaultValue: "Untitled Menu")
- late String menu;
+}
+@JsonSerializable()
+class Day {
+ final String id;
+ final MealType breakfast;
+ final MealType lunch;
+ final MealType dinner;
- @JsonKey(defaultValue: "Untitled Timing")
- late String timing;
+ Day({
+ required this.id,
+ required this.breakfast,
+ required this.lunch,
+ required this.dinner,
+ });
+ factory Day.fromJson(Map json) => _$DayFromJson(json);
- @JsonKey(defaultValue: "Untitled Day")
- late String day;
+ Map toJson() => _$DayToJson(this);
+}
+@JsonSerializable()
+class MealType {
+ final String id;
+ final String mealDescription;
+ final DateTime startTiming;
+ final DateTime endTiming;
- MessMenuModel(
- {required this.hostel,
- required this.meal,
- required this.menu,
- required this.day,
- required this.timing});
+ MealType({
+ required this.id,
+ required this.mealDescription,
+ required this.startTiming,
+ required this.endTiming,
+ });
+ factory MealType.fromJson(Map json) => _$MealTypeFromJson(json);
- factory MessMenuModel.fromJson(Map json) =>
- _$MessMenuModelFromJson(json);
+ Map toJson() => _$MealTypeToJson(this);
- Map toJson() => _$MessMenuModelToJson(this);
}
+// @JsonSerializable()
+// class MessMenuModel {
+// @JsonKey(defaultValue: "Untitled Hostel")
+// late String hostel;
+//
+// @JsonKey(defaultValue: "Untitled Meal")
+// late String meal;
+//
+// @JsonKey(defaultValue: "Untitled Menu")
+// late String menu;
+//
+// @JsonKey(defaultValue: "Untitled Timing")
+// late String timing;
+//
+// @JsonKey(defaultValue: "Untitled Day")
+// late String day;
+//
+// MessMenuModel(
+// {required this.hostel,
+// required this.meal,
+// required this.menu,
+// required this.day,
+// required this.timing});
+//
+// factory MessMenuModel.fromJson(Map json) =>
+// _$MessMenuModelFromJson(json);
+//
+// Map toJson() => _$MessMenuModelToJson(this);
+//}
diff --git a/lib/models/food/mess_menu_model.g.dart b/lib/models/food/mess_menu_model.g.dart
index f1177fa0..ecc92e23 100644
--- a/lib/models/food/mess_menu_model.g.dart
+++ b/lib/models/food/mess_menu_model.g.dart
@@ -6,20 +6,56 @@ part of 'mess_menu_model.dart';
// JsonSerializableGenerator
// **************************************************************************
-MessMenuModel _$MessMenuModelFromJson(Map json) =>
- MessMenuModel(
- hostel: json['hostel'] as String? ?? 'Untitled Hostel',
- meal: json['meal'] as String? ?? 'Untitled Meal',
- menu: json['menu'] as String? ?? 'Untitled Menu',
- day: json['day'] as String? ?? 'Untitled Day',
- timing: json['timing'] as String? ?? 'Untitled Timing',
+MessMenu _$MessMenuFromJson(Map json) => MessMenu(
+ id: json['id'] as String,
+ hostel: json['hostel'] as String,
+ monday: Day.fromJson(json['monday'] as Map),
+ tuesday: Day.fromJson(json['tuesday'] as Map),
+ wednesday: Day.fromJson(json['wednesday'] as Map),
+ thursday: Day.fromJson(json['thursday'] as Map),
+ friday: Day.fromJson(json['friday'] as Map),
+ saturday: Day.fromJson(json['saturday'] as Map),
+ sunday: Day.fromJson(json['sunday'] as Map),
+ v: json['v'] as int,
);
-Map _$MessMenuModelToJson(MessMenuModel instance) =>
- {
+Map _$MessMenuToJson(MessMenu instance) => {
+ 'id': instance.id,
'hostel': instance.hostel,
- 'meal': instance.meal,
- 'menu': instance.menu,
- 'timing': instance.timing,
- 'day': instance.day,
+ 'monday': instance.monday,
+ 'tuesday': instance.tuesday,
+ 'wednesday': instance.wednesday,
+ 'thursday': instance.thursday,
+ 'friday': instance.friday,
+ 'saturday': instance.saturday,
+ 'sunday': instance.sunday,
+ 'v': instance.v,
+ };
+
+Day _$DayFromJson(Map json) => Day(
+ id: json['id'] as String,
+ breakfast: MealType.fromJson(json['breakfast'] as Map),
+ lunch: MealType.fromJson(json['lunch'] as Map),
+ dinner: MealType.fromJson(json['dinner'] as Map),
+ );
+
+Map _$DayToJson(Day instance) => {
+ 'id': instance.id,
+ 'breakfast': instance.breakfast,
+ 'lunch': instance.lunch,
+ 'dinner': instance.dinner,
+ };
+
+MealType _$MealTypeFromJson(Map json) => MealType(
+ id: json['id'] as String,
+ mealDescription: json['mealDescription'] as String,
+ startTiming: DateTime.parse(json['startTiming'] as String),
+ endTiming: DateTime.parse(json['endTiming'] as String),
+ );
+
+Map _$MealTypeToJson(MealType instance) => {
+ 'id': instance.id,
+ 'mealDescription': instance.mealDescription,
+ 'startTiming': instance.startTiming.toIso8601String(),
+ 'endTiming': instance.endTiming.toIso8601String(),
};
diff --git a/lib/models/food/restaurant_model.dart b/lib/models/food/restaurant_model.dart
index e2869697..70f53e1c 100644
--- a/lib/models/food/restaurant_model.dart
+++ b/lib/models/food/restaurant_model.dart
@@ -8,19 +8,19 @@ part 'restaurant_model.g.dart';
@JsonSerializable(explicitToJson: true)
class RestaurantModel {
@JsonKey(defaultValue: "Untitled Restaurant")
- late String name;
+ late String outletName;
@JsonKey(defaultValue: " ")
late String caption;
@JsonKey(defaultValue: "10:00 PM")
- late String closing_time;
+ late String closingTime;
- @JsonKey(defaultValue: "2 hrs")
- late String waiting_time;
+ @JsonKey(defaultValue: "IIT Guwahati")
+ late String location;
@JsonKey(defaultValue: " ", fromJson: fromJsonPhone, toJson: toJsonPhone)
- late String phone_number;
+ late String phoneNumber;
@JsonKey(defaultValue: 26.19247153449412)
late double latitude;
@@ -28,29 +28,25 @@ class RestaurantModel {
@JsonKey(defaultValue: 91.6993500129393)
late double longitude;
- @JsonKey(defaultValue: " ")
- late String address;
-
@JsonKey(defaultValue: [])
late List tags;
@JsonKey(defaultValue: [])
late List menu;
- @JsonKey(name: "imageURL")
- late String image;
+ @JsonKey(defaultValue: "https://dw7n6pv5zdng0.cloudfront.net/modules/0001/04/thumb_3251_modules_big.jpeg")
+ late String imageURL;
RestaurantModel(
- {required this.name,
+ {required this.outletName,
required this.caption,
- required this.closing_time,
- required this.waiting_time,
- required this.phone_number,
+ required this.closingTime,
+ required this.phoneNumber,
required this.latitude,
required this.longitude,
- required this.address,
+ required this.location,
required this.tags,
- required this.image});
+ required this.imageURL});
// RestaurantModel.fromJson(Map json) {
// name = json['name'] ?? "Unnamed";= "https://live.staticflickr.com/3281/5813689894_a558bb341f_b.jpg"
diff --git a/lib/models/food/restaurant_model.g.dart b/lib/models/food/restaurant_model.g.dart
index fded6ec6..51c0f233 100644
--- a/lib/models/food/restaurant_model.g.dart
+++ b/lib/models/food/restaurant_model.g.dart
@@ -8,20 +8,20 @@ part of 'restaurant_model.dart';
RestaurantModel _$RestaurantModelFromJson(Map json) =>
RestaurantModel(
- name: json['name'] as String? ?? 'Untitled Restaurant',
+ outletName: json['outletName'] as String? ?? 'Untitled Restaurant',
caption: json['caption'] as String? ?? ' ',
- closing_time: json['closing_time'] as String? ?? '10:00 PM',
- waiting_time: json['waiting_time'] as String? ?? '2 hrs',
- phone_number: json['phone_number'] == null
+ closingTime: json['closingTime'] as String? ?? '10:00 PM',
+ phoneNumber: json['phoneNumber'] == null
? ' '
- : fromJsonPhone(json['phone_number'] as int),
+ : fromJsonPhone(json['phoneNumber'] as int),
latitude: (json['latitude'] as num?)?.toDouble() ?? 26.19247153449412,
longitude: (json['longitude'] as num?)?.toDouble() ?? 91.6993500129393,
- address: json['address'] as String? ?? ' ',
+ location: json['location'] as String? ?? 'IIT Guwahati',
tags:
(json['tags'] as List?)?.map((e) => e as String).toList() ??
[],
- image: json['imageURL'] as String,
+ imageURL: json['imageURL'] as String? ??
+ 'https://dw7n6pv5zdng0.cloudfront.net/modules/0001/04/thumb_3251_modules_big.jpeg',
)..menu = (json['menu'] as List?)
?.map((e) => DishModel.fromJson(e as Map))
.toList() ??
@@ -29,15 +29,14 @@ RestaurantModel _$RestaurantModelFromJson(Map json) =>
Map _$RestaurantModelToJson(RestaurantModel instance) =>
{
- 'name': instance.name,
+ 'outletName': instance.outletName,
'caption': instance.caption,
- 'closing_time': instance.closing_time,
- 'waiting_time': instance.waiting_time,
- 'phone_number': toJsonPhone(instance.phone_number),
+ 'closingTime': instance.closingTime,
+ 'location': instance.location,
+ 'phoneNumber': toJsonPhone(instance.phoneNumber),
'latitude': instance.latitude,
'longitude': instance.longitude,
- 'address': instance.address,
'tags': instance.tags,
'menu': instance.menu.map((e) => e.toJson()).toList(),
- 'imageURL': instance.image,
+ 'imageURL': instance.imageURL,
};
diff --git a/lib/models/lostfound/lost_model.g.dart b/lib/models/lostfound/lost_model.g.dart
index 068124b9..57159075 100644
--- a/lib/models/lostfound/lost_model.g.dart
+++ b/lib/models/lostfound/lost_model.g.dart
@@ -14,8 +14,8 @@ LostModel _$LostModelFromJson(Map json) => LostModel(
email: json['email'] as String,
compressedImageURL: json['compressedImageURL'] as String,
date: DateTime.parse(json['date'] as String),
- phonenumber: json['phonenumber'] as String,
id: json['_id'] as String,
+ phonenumber: json['phonenumber'] as String,
);
Map _$LostModelToJson(LostModel instance) => {
diff --git a/lib/models/profile/profile_model.dart b/lib/models/profile/profile_model.dart
new file mode 100644
index 00000000..47bcbc4f
--- /dev/null
+++ b/lib/models/profile/profile_model.dart
@@ -0,0 +1,38 @@
+import 'package:json_annotation/json_annotation.dart';
+part 'profile_model.g.dart';
+
+@JsonSerializable()
+class ProfileModel {
+ final String name;
+ final String rollNo;
+ final String outlookEmail;
+ final String? altEmail;
+ final int? phoneNumber;
+ final int? emergencyPhoneNumber;
+ final String? gender;
+ final String? roomNo;
+ final String? homeAddress;
+ final String? dob;
+ final String? hostel;
+ final String? linkedin;
+ final String? image;
+ ProfileModel(
+ {required this.name,
+ required this.rollNo,
+ required this.outlookEmail,
+ this.altEmail,
+ this.phoneNumber,
+ this.emergencyPhoneNumber,
+ this.gender,
+ this.roomNo,
+ this.homeAddress,
+ this.dob,
+ this.hostel,
+ this.linkedin,
+ this.image});
+
+ factory ProfileModel.fromJson(Map map) =>
+ _$ProfileModelFromJson(map);
+
+ Map toJson() => _$ProfileModelToJson(this);
+}
diff --git a/lib/models/profile/profile_model.g.dart b/lib/models/profile/profile_model.g.dart
new file mode 100644
index 00000000..acd57101
--- /dev/null
+++ b/lib/models/profile/profile_model.g.dart
@@ -0,0 +1,40 @@
+// GENERATED CODE - DO NOT MODIFY BY HAND
+
+part of 'profile_model.dart';
+
+// **************************************************************************
+// JsonSerializableGenerator
+// **************************************************************************
+
+ProfileModel _$ProfileModelFromJson(Map json) => ProfileModel(
+ name: json['name'] as String,
+ rollNo: json['rollNo'] as String,
+ outlookEmail: json['outlookEmail'] as String,
+ altEmail: json['altEmail'] as String?,
+ phoneNumber: json['phoneNumber'] as int?,
+ emergencyPhoneNumber: json['emergencyPhoneNumber'] as int?,
+ gender: json['gender'] as String?,
+ roomNo: json['roomNo'] as String?,
+ homeAddress: json['homeAddress'] as String?,
+ dob: json['dob'] as String?,
+ hostel: json['hostel'] as String?,
+ linkedin: json['linkedin'] as String?,
+ image: json['image'] as String?,
+ );
+
+Map _$ProfileModelToJson(ProfileModel instance) =>
+ {
+ 'name': instance.name,
+ 'rollNo': instance.rollNo,
+ 'outlookEmail': instance.outlookEmail,
+ 'altEmail': instance.altEmail,
+ 'phoneNumber': instance.phoneNumber,
+ 'emergencyPhoneNumber': instance.emergencyPhoneNumber,
+ 'gender': instance.gender,
+ 'roomNo': instance.roomNo,
+ 'homeAddress': instance.homeAddress,
+ 'dob': instance.dob,
+ 'hostel': instance.hostel,
+ 'linkedin': instance.linkedin,
+ 'image': instance.image,
+ };
diff --git a/lib/models/travel/day_type_model.dart b/lib/models/travel/day_type_model.dart
new file mode 100644
index 00000000..ca40f4af
--- /dev/null
+++ b/lib/models/travel/day_type_model.dart
@@ -0,0 +1,21 @@
+// ignore_for_file: non_constant_identifier_names
+
+import 'package:json_annotation/json_annotation.dart';
+
+part 'day_type_model.g.dart';
+
+@JsonSerializable()
+class DayType {
+ final List fromCampus;
+ final List toCampus;
+ const DayType(
+ {
+ required this.fromCampus,
+ required this.toCampus,
+ }
+ );
+ factory DayType.fromJson(Map json) =>
+ _$DayTypeFromJson(json);
+
+ Map toJson() => _$DayTypeToJson(this);
+}
diff --git a/lib/models/travel/day_type_model.g.dart b/lib/models/travel/day_type_model.g.dart
new file mode 100644
index 00000000..35e7fc69
--- /dev/null
+++ b/lib/models/travel/day_type_model.g.dart
@@ -0,0 +1,22 @@
+// GENERATED CODE - DO NOT MODIFY BY HAND
+
+part of 'day_type_model.dart';
+
+// **************************************************************************
+// JsonSerializableGenerator
+// **************************************************************************
+
+DayType _$DayTypeFromJson(Map json) => DayType(
+ fromCampus: (json['fromCampus'] as List)
+ .map((e) => DateTime.parse(e as String))
+ .toList(),
+ toCampus: (json['toCampus'] as List)
+ .map((e) => DateTime.parse(e as String))
+ .toList(),
+ );
+
+Map _$DayTypeToJson(DayType instance) => {
+ 'fromCampus':
+ instance.fromCampus.map((e) => e.toIso8601String()).toList(),
+ 'toCampus': instance.toCampus.map((e) => e.toIso8601String()).toList(),
+ };
diff --git a/lib/models/travel/ferry_data_model.dart b/lib/models/travel/ferry_data_model.dart
deleted file mode 100644
index 31e49b5d..00000000
--- a/lib/models/travel/ferry_data_model.dart
+++ /dev/null
@@ -1,26 +0,0 @@
-// ignore_for_file: non_constant_identifier_names
-
-import 'package:json_annotation/json_annotation.dart';
-
-part 'ferry_data_model.g.dart';
-
-@JsonSerializable()
-class FerryTimeData {
- final String name;
- final List MonToFri_GuwahatiToNorthGuwahati;
- final List MonToFri_NorthGuwahatiToGuwahati;
- final List Sunday_GuwahatiToNorthGuwahati;
- final List Sunday_NorthGuwahatiToGuwahati;
-
- FerryTimeData(
- this.name,
- this.MonToFri_GuwahatiToNorthGuwahati,
- this.MonToFri_NorthGuwahatiToGuwahati,
- this.Sunday_GuwahatiToNorthGuwahati,
- this.Sunday_NorthGuwahatiToGuwahati);
-
- factory FerryTimeData.fromJson(Map json) =>
- _$FerryTimeDataFromJson(json);
-
- Map toJson() => _$FerryTimeDataToJson(this);
-}
diff --git a/lib/models/travel/ferry_data_model.g.dart b/lib/models/travel/ferry_data_model.g.dart
deleted file mode 100644
index 83b4dfe4..00000000
--- a/lib/models/travel/ferry_data_model.g.dart
+++ /dev/null
@@ -1,35 +0,0 @@
-// GENERATED CODE - DO NOT MODIFY BY HAND
-
-part of 'ferry_data_model.dart';
-
-// **************************************************************************
-// JsonSerializableGenerator
-// **************************************************************************
-
-FerryTimeData _$FerryTimeDataFromJson(Map json) =>
- FerryTimeData(
- json['name'] as String,
- (json['MonToFri_GuwahatiToNorthGuwahati'] as List)
- .map((e) => e as String)
- .toList(),
- (json['MonToFri_NorthGuwahatiToGuwahati'] as List)
- .map((e) => e as String)
- .toList(),
- (json['Sunday_GuwahatiToNorthGuwahati'] as List)
- .map((e) => e as String)
- .toList(),
- (json['Sunday_NorthGuwahatiToGuwahati'] as List)
- .map((e) => e as String)
- .toList(),
- );
-
-Map _$FerryTimeDataToJson(FerryTimeData instance) =>
- {
- 'name': instance.name,
- 'MonToFri_GuwahatiToNorthGuwahati':
- instance.MonToFri_GuwahatiToNorthGuwahati,
- 'MonToFri_NorthGuwahatiToGuwahati':
- instance.MonToFri_NorthGuwahatiToGuwahati,
- 'Sunday_GuwahatiToNorthGuwahati': instance.Sunday_GuwahatiToNorthGuwahati,
- 'Sunday_NorthGuwahatiToGuwahati': instance.Sunday_NorthGuwahatiToGuwahati,
- };
diff --git a/lib/models/travel/travel_timing_model.dart b/lib/models/travel/travel_timing_model.dart
new file mode 100644
index 00000000..84447297
--- /dev/null
+++ b/lib/models/travel/travel_timing_model.dart
@@ -0,0 +1,30 @@
+import 'package:json_annotation/json_annotation.dart';
+
+import './day_type_model.dart';
+
+part 'travel_timing_model.g.dart';
+
+@JsonSerializable()
+class TravelTiming {
+ @JsonKey(name: '_id')
+ final String id;
+ @JsonKey(defaultValue: '')
+ final String type;
+ @JsonKey(defaultValue: '')
+ final String stop;
+ final DayType weekend;
+ final DayType weekdays;
+
+
+ TravelTiming({
+ required this.type,
+ required this.id,
+ required this.stop,
+ required this.weekend,
+ required this.weekdays,
+ });
+ factory TravelTiming.fromJson(Map json) =>
+ _$TravelTimingFromJson(json);
+
+ Map toJson() => _$TravelTimingToJson(this);
+}
diff --git a/lib/models/travel/travel_timing_model.g.dart b/lib/models/travel/travel_timing_model.g.dart
new file mode 100644
index 00000000..0ec3fcb3
--- /dev/null
+++ b/lib/models/travel/travel_timing_model.g.dart
@@ -0,0 +1,24 @@
+// GENERATED CODE - DO NOT MODIFY BY HAND
+
+part of 'travel_timing_model.dart';
+
+// **************************************************************************
+// JsonSerializableGenerator
+// **************************************************************************
+
+TravelTiming _$TravelTimingFromJson(Map json) => TravelTiming(
+ type: json['type'] as String? ?? '',
+ id: json['_id'] as String,
+ stop: json['stop'] as String? ?? '',
+ weekend: DayType.fromJson(json['weekend'] as Map),
+ weekdays: DayType.fromJson(json['weekdays'] as Map),
+ );
+
+Map _$TravelTimingToJson(TravelTiming instance) =>
+ {
+ '_id': instance.id,
+ 'type': instance.type,
+ 'stop': instance.stop,
+ 'weekend': instance.weekend,
+ 'weekdays': instance.weekdays,
+ };
diff --git a/lib/pages/buy_sell/bns_home.dart b/lib/pages/buy_sell/bns_home.dart
index ced85633..10210a9e 100644
--- a/lib/pages/buy_sell/bns_home.dart
+++ b/lib/pages/buy_sell/bns_home.dart
@@ -14,6 +14,7 @@ import 'package:onestop_dev/widgets/buy_sell/buy_tile.dart';
import 'package:onestop_dev/widgets/buy_sell/item_type_bar.dart';
import 'package:onestop_dev/widgets/lostfound/add_item_button.dart';
import 'package:onestop_dev/widgets/lostfound/ads_tile.dart';
+import 'package:onestop_dev/widgets/ui/guest_restrict.dart';
import 'package:onestop_dev/widgets/ui/list_shimmer.dart';
import 'package:provider/provider.dart';
@@ -35,10 +36,10 @@ class _BuySellHomeState extends State {
void initState() {
super.initState();
_sellController.addPageRequestListener((pageKey) async {
- await listener(_sellController, APIService.getSellPage, pageKey);
+ await listener(_sellController, APIService().getSellPage, pageKey);
});
_buyController.addPageRequestListener((pageKey) async {
- await listener(_buyController, APIService.getBuyPage, pageKey);
+ await listener(_buyController, APIService().getBuyPage, pageKey);
});
}
@@ -65,6 +66,8 @@ class _BuySellHomeState extends State {
@override
Widget build(BuildContext context) {
var commonStore = context.read();
+
+
return Observer(
builder: (BuildContext context) {
return Scaffold(
@@ -166,9 +169,10 @@ class _BuySellHomeState extends State {
)
else
Expanded(
- child: FutureBuilder(
- future: APIService.getBnsMyItems(
- context.read().userData['email'] ?? ""),
+ child: context.read().isGuestUser ? const GuestRestrictAccess()
+ : FutureBuilder(
+ future: APIService().getBnsMyItems(
+ LoginStore.userData['outlookEmail']!),
builder: (context, snapshot) {
if (snapshot.hasData) {
List models =
@@ -199,7 +203,7 @@ class _BuySellHomeState extends State {
),
floatingActionButtonLocation:
FloatingActionButtonLocation.centerFloat,
- floatingActionButton: AddItemButton(
+ floatingActionButton: context.read().isGuestUser ? Container() : AddItemButton(
type: commonStore.bnsIndex,
),
);
diff --git a/lib/pages/buy_sell/buy_form.dart b/lib/pages/buy_sell/buy_form.dart
index a3da796d..9cae3b5b 100644
--- a/lib/pages/buy_sell/buy_form.dart
+++ b/lib/pages/buy_sell/buy_form.dart
@@ -67,7 +67,7 @@ class _BuySellFormState extends State {
children: [
isLoading
? const LinearProgressIndicator()
- : const ProgressBar(blue: 2, grey: 0),
+ : widget.category == "Found" ? const ProgressBar(blue: 3, grey: 0): const ProgressBar(blue: 2, grey: 0),
Container(
margin: const EdgeInsets.only(
top: 40, left: 15, right: 5, bottom: 15),
@@ -155,22 +155,22 @@ class _BuySellFormState extends State {
data['location'] = _price.text.trim();
data['contact'] = _contactNumber.text.trim();
data['image'] = widget.imageString;
- data['name'] = context.read().userData["name"]!;
- data['email'] = context.read().userData["email"]!;
+ data['name'] = LoginStore.userData["name"]!;
+ data['email'] = LoginStore.userData["outlookEmail"]!;
data['total_price'] = "${_price.text}-${_price2.text}";
try {
if (widget.category == "Sell") {
- res = await APIService.postSellData(data);
+ res = await APIService().postSellData(data);
}
if (widget.category == "Buy") {
- res = await APIService.postBuyData(data);
+ res = await APIService().postBuyData(data);
}
if (widget.category == "Lost") {
- res = await APIService.postLostData(data);
+ res = await APIService().postLostData(data);
}
if (widget.category == "Found") {
- res = await APIService.postFoundData(data);
+ res = await APIService().postFoundData(data);
}
// ignore: empty_catches
} catch (e) {
diff --git a/lib/pages/contact/contact.dart b/lib/pages/contact/contact.dart
index 01ea0264..5ea38e57 100644
--- a/lib/pages/contact/contact.dart
+++ b/lib/pages/contact/contact.dart
@@ -154,7 +154,7 @@ class _ContactPageState extends State {
});
for (var e in alphabets) {
people["$e ADONOTUSE"] = ContactModel(
- name: "Random", contacts: [], group: "");
+ sectionName: "Random", contacts: []);
}
return AlphabetScrollView(
list: people.keys.map((e) => AlphaModel(e)).toList(),
diff --git a/lib/pages/contact/contact_detail.dart b/lib/pages/contact/contact_detail.dart
index 0fde93f0..2c60dc89 100644
--- a/lib/pages/contact/contact_detail.dart
+++ b/lib/pages/contact/contact_detail.dart
@@ -51,18 +51,18 @@ class _ContactDetailsPageState extends State {
Padding(
padding: const EdgeInsets.only(left: 8.0),
child: Text(
- widget.contact!.name,
+ widget.contact!.sectionName,
style: MyFonts.w600.size(16).setColor(kWhite),
),
),
- const Expanded(child: SizedBox()),
- Padding(
- padding: const EdgeInsets.only(right: 8.0),
- child: Text(
- widget.contact!.group,
- style: MyFonts.w400.size(14).setColor(kGrey2),
- ),
- )
+ // const Expanded(child: SizedBox()),
+ // Padding(
+ // padding: const EdgeInsets.only(right: 8.0),
+ // child: Text(
+ // widget.contact!.group,
+ // style: MyFonts.w400.size(14).setColor(kGrey2),
+ // ),
+ // )
],
),
Row(
diff --git a/lib/pages/home/home_tab.dart b/lib/pages/home/home_tab.dart
index 1dee8775..83c55aca 100644
--- a/lib/pages/home/home_tab.dart
+++ b/lib/pages/home/home_tab.dart
@@ -25,8 +25,10 @@ class _HomeTabState extends State {
@override
void initState() {
super.initState();
- context.read().setTimetable(
- context.read().userData["rollno"] ?? "190101109");
+ if (!LoginStore.isGuest) {
+ context.read().setTimetable(
+ LoginStore.userData["rollNo"]!, context);
+ }
}
@override
@@ -45,10 +47,17 @@ class _HomeTabState extends State {
const SizedBox(
height: 10,
),
- const DateCourse(),
- const SizedBox(
- height: 10,
- ),
+ LoginStore.isGuest
+ ? Container()
+ : const Column(
+ mainAxisSize: MainAxisSize.min,
+ children: [
+ const DateCourse(),
+ SizedBox(
+ height: 10,
+ )
+ ],
+ ),
HomeLinks(title: 'Services', links: serviceLinks),
const SizedBox(
height: 10,
diff --git a/lib/pages/login/login.dart b/lib/pages/login/login.dart
index 1d9d3c05..45b98795 100644
--- a/lib/pages/login/login.dart
+++ b/lib/pages/login/login.dart
@@ -1,12 +1,16 @@
import 'dart:async';
import 'dart:io';
+import 'package:fluentui_system_icons/fluentui_system_icons.dart';
import 'package:flutter/material.dart';
import 'package:onestop_dev/globals/size_config.dart';
import 'package:onestop_dev/pages/login/welcome.dart';
import 'package:onestop_dev/widgets/login/login_webview.dart';
import 'package:webview_flutter/webview_flutter.dart';
+import '../../globals/my_colors.dart';
+import '../../globals/my_fonts.dart';
+
class LoginPage extends StatefulWidget {
static String id = "/login";
@@ -16,7 +20,7 @@ class LoginPage extends StatefulWidget {
}
class _LoginPageState extends State {
- bool loading = false;
+ // bool loading = false;
final Completer _controller =
Completer();
@@ -30,12 +34,16 @@ class _LoginPageState extends State {
Widget build(BuildContext context) {
SizeConfig().init(context);
return Scaffold(
- body: loading
- ? SafeArea(child: LoginWebView(controller: _controller))
- : WelcomePage(setLoading: () {
- setState(() {
- loading = true;
- });
- }));
+ body:
+ // loading
+ // ?
+ SafeArea(child: LoginWebView(controller: _controller))
+ // : WelcomePage(setLoading: () {
+ // setState(() {
+ // loading = true;
+ // });
+ // })
+
+ );
}
}
diff --git a/lib/pages/login/welcome.dart b/lib/pages/login/welcome.dart
index e61e7d2e..e509fac6 100644
--- a/lib/pages/login/welcome.dart
+++ b/lib/pages/login/welcome.dart
@@ -3,35 +3,47 @@ import 'package:onestop_dev/globals/my_spaces.dart';
import 'package:onestop_dev/widgets/login/login_button.dart';
import 'package:onestop_dev/widgets/login/welcome_header.dart';
+import '../../globals/size_config.dart';
+
class WelcomePage extends StatelessWidget {
- final Function setLoading;
- const WelcomePage({Key? key, required this.setLoading}) : super(key: key);
+ static String id = "/login2";
+ // final Function setLoading;
+ const WelcomePage({Key? key,
+ // required this.setLoading
+ }) : super(key: key);
@override
Widget build(BuildContext context) {
- return Column(
- mainAxisAlignment: MainAxisAlignment.center,
- children: [
- Expanded(
- flex: 4,
- child: Container(
- decoration: const BoxDecoration(
- image: DecorationImage(
- image: AssetImage('assets/images/bg_triangle.png'),
- fit: BoxFit.fill,
- )),
- child: const WelcomeHeader(),
- ),
- ),
- Expanded(
- flex: 1,
- child: Padding(
- padding: EdgeInsets.symmetric(
- horizontal: MySpaces.horizontalScreenPadding),
- child: LoginButton(setLoading: setLoading),
- ),
+ SizeConfig().init(context);
+ return Scaffold(
+ body:
+ SafeArea(
+ child: Column(
+ mainAxisAlignment: MainAxisAlignment.center,
+ children: [
+ Expanded(
+ flex: 4,
+ child: Container(
+ decoration: const BoxDecoration(
+ image: DecorationImage(
+ image: AssetImage('assets/images/bg_triangle.png'),
+ fit: BoxFit.fill,
+ )),
+ child: const WelcomeHeader(),
+ ),
+ ),
+ Expanded(
+ flex: 1,
+ child: Padding(
+ padding: EdgeInsets.symmetric(
+ horizontal: MySpaces.horizontalScreenPadding
+ ),
+ child: const LoginButton(),
+ ),
+ ),
+ ],
),
- ],
+ ),
);
}
}
diff --git a/lib/pages/lost_found/lnf_home.dart b/lib/pages/lost_found/lnf_home.dart
index 718cc03f..1a7da6e5 100644
--- a/lib/pages/lost_found/lnf_home.dart
+++ b/lib/pages/lost_found/lnf_home.dart
@@ -13,6 +13,7 @@ import 'package:onestop_dev/widgets/lostfound/ads_tile.dart';
import 'package:onestop_dev/widgets/lostfound/lost_found_button.dart';
import 'package:onestop_dev/widgets/lostfound/add_item_button.dart';
import 'package:onestop_dev/widgets/lostfound/lost_found_tile.dart';
+import 'package:onestop_dev/widgets/ui/guest_restrict.dart';
import 'package:onestop_dev/widgets/ui/list_shimmer.dart';
import 'package:provider/provider.dart';
@@ -34,10 +35,10 @@ class _LostFoundHomeState extends State {
void initState() {
super.initState();
_lostController.addPageRequestListener((pageKey) async {
- await listener(_lostController, APIService.getLostPage, pageKey);
+ await listener(_lostController, APIService().getLostPage, pageKey);
});
_foundController.addPageRequestListener((pageKey) async {
- await listener(_foundController, APIService.getFoundPage, pageKey);
+ await listener(_foundController, APIService().getFoundPage, pageKey);
});
}
@@ -64,6 +65,8 @@ class _LostFoundHomeState extends State {
@override
Widget build(BuildContext context) {
var commonStore = context.read();
+
+
return Observer(builder: (context) {
return Scaffold(
appBar: AppBar(
@@ -169,9 +172,10 @@ class _LostFoundHomeState extends State {
)
else
Expanded(
- child: FutureBuilder(
- future: APIService.getLnfMyItems(
- context.read().userData['email'] ?? ""),
+ child: context.read().isGuestUser ? const GuestRestrictAccess()
+ : FutureBuilder(
+ future: APIService().getLnfMyItems(
+ LoginStore.userData['outlookEmail'] ?? ""),
builder: (context, snapshot) {
if (snapshot.hasData) {
List models = snapshot.data! as List;
@@ -200,7 +204,7 @@ class _LostFoundHomeState extends State {
],
),
floatingActionButtonLocation: FloatingActionButtonLocation.centerFloat,
- floatingActionButton: AddItemButton(
+ floatingActionButton: context.read().isGuestUser ? Container() : AddItemButton(
type: commonStore.lnfIndex,
),
);
diff --git a/lib/pages/notifications/notifications.dart b/lib/pages/notifications/notifications.dart
new file mode 100644
index 00000000..89a98d32
--- /dev/null
+++ b/lib/pages/notifications/notifications.dart
@@ -0,0 +1,134 @@
+import 'dart:convert';
+
+import 'package:fluentui_system_icons/fluentui_system_icons.dart';
+import 'package:flutter/material.dart';
+import 'package:onestop_dev/functions/notifications/get_notifications.dart';
+import 'package:onestop_dev/globals/my_colors.dart';
+import 'package:onestop_dev/globals/my_fonts.dart';
+import 'package:onestop_dev/widgets/ui/list_shimmer.dart';
+import 'package:onestop_dev/widgets/ui/notification_tile.dart';
+import 'package:shared_preferences/shared_preferences.dart';
+
+class NotifsModel {
+ String? title;
+ String? body;
+ String category;
+ bool read;
+ DateTime time;
+ String messageId;
+
+ NotifsModel(
+ this.title,
+ this.body,
+ this.read,
+ this.category,
+ this.time,
+ this.messageId
+ );
+}
+
+class NotificationPage extends StatefulWidget {
+ static String id = "notifications";
+ const NotificationPage({Key? key}) : super(key: key);
+
+ @override
+ State createState() => _NotificationPageState();
+}
+
+class _NotificationPageState extends State {
+
+ IconData getIcon(bool readNotif) {
+ if (!readNotif) {
+ return FluentIcons.circle_24_filled;
+ }
+ return Icons.brightness_1_outlined;
+ }
+
+ @override
+ void initState() {
+ super.initState();
+ }
+
+ @override
+ Widget build(BuildContext context) {
+ return Scaffold(
+ appBar: AppBar(
+ backgroundColor: kAppBarGrey,
+ actions: [
+ ElevatedButton.icon(
+ onPressed: () async {
+ final SharedPreferences prefs =
+ await SharedPreferences.getInstance();
+ await prefs.reload();
+ prefs.remove('notifications');
+ setState(() {});
+ },
+ icon: const Icon(FluentIcons.delete_12_regular),
+ label: Text(
+ 'Clear All',
+ style: MyFonts.w300,
+ ),
+ style: ElevatedButton.styleFrom(
+ backgroundColor: Colors.transparent, elevation: 0),
+ )
+ ],
+ leading: IconButton(
+ onPressed: () {
+ Navigator.of(context).pop();
+ },
+ icon: const Icon(FluentIcons.arrow_left_24_regular)),
+ title: Text(
+ 'Notifications',
+ style: MyFonts.w500,
+ ),
+ ),
+ body: FutureBuilder>(
+ future: getSavedNotifications(true),
+ builder: (context, snapshot) {
+ if (snapshot.hasData) {
+ if (snapshot.data!.isEmpty) {
+ return Center(
+ child: Text(
+ 'No notifications found',
+ style: MyFonts.w300.setColor(kWhite),
+ ),
+ );
+ }
+ return Padding(
+ padding: const EdgeInsets.symmetric(horizontal: 16),
+ child: ListView.builder(
+ itemCount: snapshot.data!.length,
+ itemBuilder: (context, index) {
+ return Padding(
+ padding: const EdgeInsets.symmetric(vertical: 4.0),
+ child: NotificationTile(
+ notifModel: snapshot.data![index],
+ ),
+ );
+ },
+ ),
+ );
+ }
+ if (snapshot.connectionState == ConnectionState.waiting) {
+ return Column(
+ children: [
+ const SizedBox(
+ height: 10,
+ ),
+ Expanded(
+ child: ListShimmer(
+ count: 5,
+ )),
+ ],
+ );
+ }
+ return Center(
+ child: Text(
+ 'No notifications found',
+ style: MyFonts.w300.setColor(kWhite),
+ ),
+ );
+ }),
+ );
+ }
+}
diff --git a/lib/pages/profile.dart b/lib/pages/profile.dart
index bbf3d8fb..3abdfb38 100644
--- a/lib/pages/profile.dart
+++ b/lib/pages/profile.dart
@@ -42,12 +42,12 @@ class _ProfilePageState extends State {
width: MediaQuery.of(context).size.width,
),
Text(
- "${context.read().userData['name']}",
+ "${LoginStore.userData['name']}",
textAlign: TextAlign.center,
style: MyFonts.w800.setColor(kWhite).size(20),
),
Text(
- '${context.read().userData['rollno']}',
+ '${LoginStore.userData['rollNo']}',
textAlign: TextAlign.center,
style: MyFonts.w500.setColor(kWhite).size(20),
),
@@ -69,7 +69,7 @@ class _ProfilePageState extends State {
// padding: const EdgeInsets.symmetric(horizontal: 16),
// child: BarcodeWidget(
// barcode: Barcode.code128(),
- // data: "${context.read().userData['rollno']}",
+ // data: "${context.read().userData['rollNo']}",
// height: 150,
// color: kBlack,
// backgroundColor: kWhite,
@@ -99,7 +99,9 @@ class _ProfilePageState extends State {
'/', (Route route) => false));
},
style: ElevatedButton.styleFrom(
- elevation: 0, backgroundColor: kAppBarGrey),
+ elevation: 0,
+ backgroundColor: kAppBarGrey,
+ ),
child: Text(
'Log Out',
style: MyFonts.w500.setColor(kBlue),
diff --git a/lib/pages/profile/edit_profile.dart b/lib/pages/profile/edit_profile.dart
new file mode 100644
index 00000000..b0a33360
--- /dev/null
+++ b/lib/pages/profile/edit_profile.dart
@@ -0,0 +1,515 @@
+import 'dart:convert';
+import 'dart:io';
+
+import 'package:flutter/material.dart';
+import 'package:flutter/services.dart';
+import 'package:image_picker/image_picker.dart';
+import 'package:intl/intl.dart';
+import 'package:onestop_dev/globals/database_strings.dart';
+import 'package:onestop_dev/services/api.dart';
+import 'package:onestop_dev/services/local_storage.dart';
+import 'package:provider/provider.dart';
+import 'package:shared_preferences/shared_preferences.dart';
+
+import '../../functions/utility/show_snackbar.dart';
+import '../../functions/utility/validator.dart';
+import '../../globals/my_colors.dart';
+import '../../globals/my_fonts.dart';
+import '../../models/profile/profile_model.dart';
+import '../../stores/login_store.dart';
+import '../../widgets/profile/custom_date_picker.dart';
+import '../../widgets/profile/custom_dropdown.dart';
+import '../../widgets/profile/custom_text_field.dart';
+import 'profile_page.dart';
+
+class EditProfile extends StatefulWidget {
+ final ProfileModel profileModel;
+ const EditProfile({Key? key, required this.profileModel}) : super(key: key);
+
+ @override
+ State createState() => _EditProfileState();
+}
+
+class _EditProfileState extends State {
+ final TextEditingController _nameController = TextEditingController();
+ final TextEditingController _outlookEmailController = TextEditingController();
+ final TextEditingController _rollController = TextEditingController();
+ final TextEditingController _altEmailController = TextEditingController();
+ final TextEditingController _phoneController = TextEditingController();
+ final TextEditingController _emergencyController = TextEditingController();
+ final TextEditingController _roomNoController = TextEditingController();
+ final TextEditingController _homeAddressController = TextEditingController();
+ final TextEditingController _dobController = TextEditingController();
+ final TextEditingController _linkedinController = TextEditingController();
+ String? hostel;
+ String? gender;
+ DateTime? selectedDob;
+ // String? imageString;
+ final List genders = ["Male", "Female", "Others"];
+ final List hostels = [
+ "Kameng",
+ "Barak",
+ "Lohit",
+ "Brahma",
+ "Disang",
+ "Manas",
+ "Dihing",
+ "Umiam",
+ "Siang",
+ "Kapili",
+ "Dhansiri",
+ "Subhansiri"
+ ];
+ final _formKey = GlobalKey();
+
+ @override
+ void initState() {
+ super.initState();
+ ProfileModel p = widget.profileModel!;
+ _nameController.text = p.name;
+ _rollController.text = p.rollNo;
+ _outlookEmailController.text = p.outlookEmail;
+ _altEmailController.text = p.altEmail ?? "";
+ _phoneController.text =
+ p.phoneNumber == null ? "" : p.phoneNumber.toString();
+ _emergencyController.text =
+ p.emergencyPhoneNumber == null ? "" : p.emergencyPhoneNumber.toString();
+ _roomNoController.text = p.roomNo ?? "";
+ _homeAddressController.text = p.homeAddress ?? "";
+ _dobController.text = DateFormat('dd-MMM-yyyy')
+ .format(DateTime.parse(p.dob ?? DateTime.now().toIso8601String()));
+ _linkedinController.text = p.linkedin ?? "";
+ hostel = p.hostel;
+ gender = p.gender;
+ selectedDob = p.dob != null ? DateTime.parse(p.dob!) : DateTime.now();
+ // imageString = p.image;
+ }
+
+ @override
+ Widget build(BuildContext context) {
+ Widget? counterBuilder(context,
+ {required currentLength, required isFocused, required maxLength}) {
+ if (currentLength == 0) {
+ return null;
+ }
+ return Text("$currentLength/$maxLength",
+ style: MyFonts.w500.size(12).setColor(kWhite));
+ }
+
+ Future onFormSubmit() async {
+ if (!_formKey.currentState!.validate()) {
+ showSnackBar('Please give all the inputs correctly');
+ return;
+ } else {
+ DateTime date =
+ DateTime(selectedDob!.year, selectedDob!.month, selectedDob!.day);
+ var data = {
+ 'name': _nameController.text,
+ 'rollNo': _rollController.text,
+ 'outlookEmail': _outlookEmailController.text,
+ 'altEmail': _altEmailController.text,
+ 'dob': date.toIso8601String(),
+ 'gender': gender,
+ 'phoneNumber': _phoneController.text,
+ 'emergencyPhoneNumber': _emergencyController.text,
+ 'hostel': hostel,
+ 'roomNo': _roomNoController.text,
+ 'homeAddress': _homeAddressController.text,
+ 'linkedin': _linkedinController.text
+ };
+ print(data);
+ try {
+ await APIService().updateUserProfile(data, null);
+ } catch (e) {
+ showSnackBar(e.toString());
+ return;
+ }
+ Map userInfo = await APIService().getUserProfile();
+ SharedPreferences prefs = await SharedPreferences.getInstance();
+ await prefs.setString('hostel', hostel ?? "");
+ await prefs.setString("userInfo", jsonEncode(userInfo));
+ await context.read().saveToUserInfo(
+ prefs); // automatically updates token & other user info
+ await prefs.setBool("isProfileComplete", true); // profile is complete
+ await LocalStorage.instance.deleteRecord(DatabaseRecords.timetable);
+ print("PROFILE COMPLETED");
+ Navigator.of(context)
+ .pushNamedAndRemoveUntil('/', (Route route) => false);
+
+ // Navigator.of(context).pushAndRemoveUntil(
+ // MaterialPageRoute(
+ // builder: (context) => Profile(
+ // profileModel: ProfileModel.fromJson(data),
+ // )),
+ // ((route) => false));
+ }
+ }
+
+ return GestureDetector(
+ onTap: () {
+ FocusScope.of(context).requestFocus(new FocusNode());
+ },
+ child: Scaffold(
+ backgroundColor: kBackground,
+ appBar: AppBar(
+ backgroundColor: kAppBarGrey,
+ iconTheme: const IconThemeData(color: kAppBarGrey),
+ automaticallyImplyLeading: false,
+ centerTitle: false,
+ title: Text(
+ "Profile Setup",
+ textAlign: TextAlign.left,
+ style: MyFonts.w500.size(23).setColor(kWhite),
+ ),
+ ),
+ body: SafeArea(
+ child: SingleChildScrollView(
+ child: Container(
+ padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 8),
+ width: double.infinity,
+ child: Column(
+ crossAxisAlignment: CrossAxisAlignment.start,
+ children: [
+ RichText(
+ text: TextSpan(
+ children: [
+ TextSpan(
+ text: 'Fields marked with',
+ style: MyFonts.w500.setColor(kWhite3).size(12)),
+ TextSpan(
+ text: ' * ',
+ style: MyFonts.w500.setColor(kRed).size(12)),
+ TextSpan(
+ text: 'are compulsory',
+ style: MyFonts.w500.setColor(kWhite3).size(12)),
+ ],
+ ),
+ ),
+ const SizedBox(
+ height: 24,
+ ),
+ // For now image will not be stored
+ // Center(
+ // child: Stack(alignment: Alignment.bottomRight, children: [
+ //
+ // ClipRRect(
+ // borderRadius: BorderRadius.circular(75.0),
+ //
+ // child: Image(
+ // image: imageString==null?const ResizeImage(AssetImage('assets/images/profile_placeholder.png'),width: 150,height: 150): ResizeImage(
+ // MemoryImage(base64Decode(imageString!))
+ // ,width: 150,
+ // height: 150,),
+ // fit: BoxFit.fill,
+ // )
+ // ),
+ // Padding(
+ // padding: const EdgeInsets.all(8.0),
+ // child: GestureDetector(
+ // onTap: () async {
+ // XFile? xFile;
+ // await showDialog(
+ // context: context,
+ // builder: (BuildContext context) {
+ // return AlertDialog(
+ // shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(28)),
+ // backgroundColor: kBlueGrey,
+ // title: Text(
+ // "Do you want to change your profile photo?",style: MyFonts.w500.size(16).setColor(kWhite2),),
+ // content: SingleChildScrollView(
+ // child: ListBody(
+ // children: [
+ // GestureDetector(
+ // child: Text("Take Photo",style: MyFonts.w500.size(14).setColor(kWhite),),
+ // onTap: () async {
+ // xFile = await ImagePicker().pickImage(
+ // source: ImageSource.camera);
+ // if (!mounted) return;
+ // Navigator.of(context).pop();
+ // },
+ // ),
+ // const Padding(
+ // padding: EdgeInsets.all(8.0)),
+ // GestureDetector(
+ // child: Text("Choose Photo",style: MyFonts.w500.size(14).setColor(kWhite),),
+ // onTap: () async {
+ // xFile = await ImagePicker().pickImage(
+ // source: ImageSource.gallery);
+ // if (!mounted) return;
+ // Navigator.of(context).pop();
+ // },
+ // ),
+ // const Padding(
+ // padding: EdgeInsets.all(8.0)),
+ //
+ // GestureDetector(
+ // child: Text("Remove Photo",style: MyFonts.w500.size(14).setColor(kRed),),
+ // onTap: () async {
+ // setState(() {
+ // imageString=null;
+ // });
+ // return
+ // Navigator.of(context).pop();
+ // },
+ // ),
+ // ],
+ // ),
+ // ));
+ // });
+ //
+ // if (!mounted) return;
+ // if (xFile != null) {
+ // var bytes = File(xFile!.path).readAsBytesSync();
+ // var imageSize = (bytes.lengthInBytes /
+ // (1048576)); // dividing by 1024*1024
+ // if (imageSize > 2.5) {
+ // ScaffoldMessenger.of(context).showSnackBar(SnackBar(
+ // content: Text(
+ // "Maximum image size can be 2.5 MB",
+ // style: MyFonts.w500,
+ // )));
+ // return;
+ // }
+ // setState(() {
+ // imageString = base64Encode(bytes);
+ // });
+ // return;
+ // }
+ // },
+ // child: Container(
+ // height: 30,
+ // width: 30,
+ // decoration: const BoxDecoration(
+ // borderRadius: BorderRadius.all(Radius.circular(75)),
+ // color: kWhite),
+ // child: const Icon(Icons.edit_outlined),
+ // ),
+ // ),
+ // ),
+ // ])),
+ // const SizedBox(
+ // height: 24,
+ // ),
+ Text('Basic Information',
+ style: MyFonts.w600.size(16).setColor(kWhite)),
+ const SizedBox(
+ height: 18,
+ ),
+ Form(
+ key: _formKey,
+ child: Column(
+ children: [
+ CustomTextField(
+ hintText: 'name',
+ // validator: validatefield,
+ isNecessary: false,
+ controller: _nameController,
+ isEnabled: false,
+ ),
+ const SizedBox(
+ height: 12,
+ ),
+ CustomTextField(
+ hintText: 'Roll Number',
+ validator: (String? value) {
+ if (value == null || value.isEmpty) {
+ return 'Field cannot be empty';
+ } else if (value.length != 9) {
+ return 'Enter valid roll number';
+ }
+ return null;
+ },
+ inputFormatters: [
+ FilteringTextInputFormatter.digitsOnly,
+ ],
+ isNecessary: true,
+ controller: _rollController,
+ maxLength: 9,
+ maxLines: 1,
+ counter: true,
+ ),
+ const SizedBox(
+ height: 12,
+ ),
+ CustomTextField(
+ isEnabled: false,
+ hintText: 'outlookEmail ID',
+ // validator: validatefield,
+ isNecessary: false,
+ controller: _outlookEmailController,
+ ),
+ const SizedBox(
+ height: 12,
+ ),
+ CustomTextField(
+ hintText: 'Alt Email',
+ validator: validatefield,
+ isNecessary: true,
+ controller: _altEmailController,
+ maxLength: 50,
+ maxLines: 1,
+ counter: true,
+ ),
+ const SizedBox(
+ height: 12,
+ ),
+ CustomTextField(
+ hintText: 'Phone Number',
+ validator: (String? value) {
+ if (value == null || value.isEmpty) {
+ return 'Field cannot be empty';
+ } else if (value.length != 10) {
+ return 'Enter valid 10 digit phone number';
+ }
+ return null;
+ },
+ isNecessary: true,
+ controller: _phoneController,
+ inputType: TextInputType.phone,
+ inputFormatters: [
+ FilteringTextInputFormatter.digitsOnly,
+ ],
+ maxLength: 10,
+ maxLines: 1,
+ counter: true,
+ ),
+ const SizedBox(
+ height: 12,
+ ),
+ CustomTextField(
+ hintText: 'Emergency Contact Number',
+ validator: (String? value) {
+ if (value == null || value.isEmpty) {
+ return 'Field cannot be empty';
+ } else if (value.length != 10) {
+ return 'Enter valid 10 digit phone number';
+ }
+ return null;
+ },
+ inputFormatters: [
+ FilteringTextInputFormatter.digitsOnly,
+ ],
+ isNecessary: true,
+ controller: _emergencyController,
+ inputType: TextInputType.phone,
+ maxLength: 10,
+ maxLines: 1,
+ counter: true,
+ ),
+ const SizedBox(
+ height: 12,
+ ),
+ CustomDropDown(
+ value: gender,
+ items: genders,
+ hintText: 'Your Gender',
+ onChanged: (g) => gender = g,
+ validator: validatefield),
+ const SizedBox(
+ height: 12,
+ ),
+ CustomDropDown(
+ value: hostel,
+ items: hostels,
+ hintText: 'Hostel',
+ onChanged: (h) => hostel = h,
+ validator: validatefield,
+ ),
+ const SizedBox(
+ height: 12,
+ ),
+ CustomTextField(
+ hintText: 'Date of Birth',
+ validator: validatefield,
+ controller: _dobController,
+ onTap: () async {
+ FocusScope.of(context).requestFocus(FocusNode());
+ DateTime? pickedDate = await showDatePicker(
+ context: context,
+ initialDate: selectedDob ?? DateTime.now(),
+ firstDate: DateTime(1990),
+ //DateTime.now() - not to allow to choose before today.
+ lastDate: DateTime(2101),
+ builder: (context, child) => CustomDatePicker(
+ child: child,
+ ));
+ if (pickedDate != null) {
+ if (!mounted) return;
+ selectedDob = pickedDate;
+ String formattedDate =
+ DateFormat('dd-MMM-yyyy').format(pickedDate);
+ setState(() {
+ _dobController.text =
+ formattedDate; //set output date to TextField value.
+ });
+ }
+ },
+ isNecessary: true,
+ ),
+ const SizedBox(
+ height: 12,
+ ),
+ CustomTextField(
+ hintText: 'Hostel room no',
+ validator: validatefield,
+ isNecessary: true,
+ controller: _roomNoController,
+ maxLength: 5,
+ maxLines: 1,
+ counter: true,
+ ),
+ const SizedBox(
+ height: 12,
+ ),
+ CustomTextField(
+ hintText: 'Home Address',
+ validator: validatefield,
+ isNecessary: true,
+ controller: _homeAddressController,
+ maxLength: 400,
+ // maxLines: 1,
+ counter: true,
+ ),
+ const SizedBox(
+ height: 12,
+ ),
+ CustomTextField(
+ hintText: 'LinkedIn Profile',
+ // validator: validatefield,
+ isNecessary: false,
+ controller: _linkedinController,
+ maxLength: 50,
+ maxLines: 1,
+ counter: true,
+ ),
+ const SizedBox(
+ height: 24,
+ ),
+ ],
+ )),
+ GestureDetector(
+ onTap: onFormSubmit,
+ child: Container(
+ width: double.infinity,
+ height: 48,
+ alignment: Alignment.center,
+ decoration: const BoxDecoration(
+ borderRadius: BorderRadius.all(Radius.circular(4)),
+ color: lBlue2),
+ child: const Text(
+ 'Submit',
+ textAlign: TextAlign.center,
+ ),
+ ),
+ ),
+ const SizedBox(
+ height: 24,
+ ),
+ ],
+ ),
+ )),
+ ),
+ ),
+ );
+ }
+}
diff --git a/lib/pages/profile/profile_page.dart b/lib/pages/profile/profile_page.dart
new file mode 100644
index 00000000..2ab56a4c
--- /dev/null
+++ b/lib/pages/profile/profile_page.dart
@@ -0,0 +1,176 @@
+import 'dart:convert';
+
+import 'package:flutter/material.dart';
+import 'package:intl/intl.dart';
+import 'package:provider/provider.dart';
+
+import '../../globals/my_colors.dart';
+import '../../globals/my_fonts.dart';
+import '../../models/profile/profile_model.dart';
+import '../../stores/login_store.dart';
+import '../../widgets/profile/data_tile.dart';
+import '../../widgets/profile/feedback.dart';
+import 'edit_profile.dart';
+
+class Profile extends StatefulWidget {
+ final ProfileModel profileModel;
+ const Profile({super.key, required this.profileModel});
+
+ @override
+ State createState() => _ProfileState();
+}
+
+class _ProfileState extends State {
+ @override
+ Widget build(BuildContext context) {
+ print(widget.profileModel!.toJson());
+ return Scaffold(
+ backgroundColor: kBackground,
+ appBar: AppBar(
+ backgroundColor: kAppBarGrey,
+ iconTheme: const IconThemeData(color: kAppBarGrey),
+ automaticallyImplyLeading: false,
+ centerTitle: false,
+ title: Text(
+ "Profile",
+ textAlign: TextAlign.left,
+ style: MyFonts.w500.size(23).setColor(kWhite),
+ ),
+ actions: [
+ if (!context.read().isGuestUser)
+ IconButton(
+ onPressed: (() {
+ showModalBottomSheet(
+ context: context,
+ shape: const RoundedRectangleBorder(
+ borderRadius: BorderRadius.vertical(
+ top: Radius.circular(20),
+ ),
+ ),
+ clipBehavior: Clip.antiAliasWithSaveLayer,
+ isScrollControlled: true,
+ builder: (BuildContext context) {
+ return const FeedBack();
+ });
+ }),
+ icon: const Icon(
+ Icons.bug_report_outlined,
+ color: kWhite,
+ )),
+ IconButton(
+ onPressed: (() {
+ context.read().logOut(() => Navigator.of(context)
+ .pushNamedAndRemoveUntil(
+ '/', (Route route) => false));
+ }),
+ icon: const Icon(
+ Icons.logout_outlined,
+ color: kWhite,
+ ))
+ ],
+ ),
+ body: SafeArea(
+ child: SingleChildScrollView(
+ child: Container(
+ padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 8),
+ width: double.infinity,
+ child: Column(
+ crossAxisAlignment: CrossAxisAlignment.start,
+ children: [
+ const SizedBox(
+ height: 12,
+ ),
+ // Center(
+ // child: Stack(alignment: Alignment.bottomRight, children: [
+ // ClipRRect(
+ // borderRadius: BorderRadius.circular(75.0),
+ // child: Image(
+ // image: widget.profileModel?.image == null
+ // ? const ResizeImage(
+ // AssetImage(
+ // 'assets/images/profile_placeholder.png'),
+ // width: 150,
+ // height: 150)
+ // : ResizeImage(
+ // MemoryImage(
+ // base64Decode(widget.profileModel!.image!)),
+ // width: 150,
+ // height: 150,
+ // ),
+ // fit: BoxFit.fill,
+ // )),
+ // ])),
+ // const SizedBox(
+ // height: 24,
+ // ),
+ Text('Basic Information',
+ style: MyFonts.w600.size(16).setColor(kWhite)),
+ const SizedBox(
+ height: 6,
+ ),
+ DataTile(
+ title: 'Username',
+ semiTitle: widget.profileModel.name,
+ ),
+ DataTile(
+ title: 'Roll Number',
+ semiTitle: widget.profileModel.rollNo,
+ ),
+ DataTile(
+ title: 'Outlook ID',
+ semiTitle: widget.profileModel.outlookEmail,
+ ),
+ DataTile(
+ title: 'Alt Email',
+ semiTitle: widget.profileModel.altEmail,
+ ),
+ DataTile(
+ title: 'Contact Number',
+ semiTitle: widget.profileModel.phoneNumber!=null ? widget.profileModel.phoneNumber.toString() : null,
+ ),
+ DataTile(
+ title: 'Emergency Contact Number',
+ semiTitle: widget.profileModel.emergencyPhoneNumber!=null ? widget.profileModel.emergencyPhoneNumber.toString() : null,
+ ),
+ DataTile(
+ title: 'Hostel',
+ semiTitle: widget.profileModel.hostel,
+ ),
+ widget.profileModel.dob==null
+ ? Container()
+ : DataTile(
+ title: 'Date of Birth',
+ semiTitle: DateFormat('dd-MMM-yyyy')
+ .format(DateTime.parse(widget.profileModel.dob!)),
+ ),
+ DataTile(
+ title: 'LinkedIn Profile',
+ semiTitle: widget.profileModel.linkedin,
+ ),
+ const SizedBox(
+ height: 24,
+ ),
+ ],
+ ),
+ )),
+ ),
+ floatingActionButton: LoginStore.isGuest ? Container() : GestureDetector(
+ onTap: (() {
+ Navigator.of(context).push(MaterialPageRoute(
+ builder: (context) => EditProfile(
+ profileModel: widget.profileModel,
+ )));
+ }),
+ child: Container(
+ width: 48,
+ height: 48,
+ alignment: Alignment.center,
+ decoration: const BoxDecoration(
+ borderRadius: BorderRadius.all(Radius.circular(16)),
+ color: lBlue2),
+ child: const Icon(Icons.edit_outlined),
+ ),
+ ),
+ );
+ }
+}
diff --git a/lib/pages/quick_links/cab_share.dart b/lib/pages/quick_links/cab_share.dart
index 33733419..0ac2437b 100644
--- a/lib/pages/quick_links/cab_share.dart
+++ b/lib/pages/quick_links/cab_share.dart
@@ -9,10 +9,7 @@ class CabShare extends StatelessWidget {
@override
Widget build(BuildContext context) {
- return CabSharingScreen(userData: {
- 'name': context.read().userData["name"]!,
- 'email': context.read().userData["email"]!,
- 'security-key': const String.fromEnvironment('SECURITY-KEY')
- });
+ print(LoginStore.userData);
+ return CabSharingSplashScreen();
}
}
diff --git a/lib/pages/quick_links/gc_scoreboard.dart b/lib/pages/quick_links/gc_scoreboard.dart
index 9d2785c6..27e7aa9c 100644
--- a/lib/pages/quick_links/gc_scoreboard.dart
+++ b/lib/pages/quick_links/gc_scoreboard.dart
@@ -9,6 +9,6 @@ class Scoreboard extends StatelessWidget {
@override
Widget build(BuildContext context) {
- return GCScoreBoard(userInfo: context.read().userData);
+ return GCScoreBoard(userInfo: {"name": LoginStore.userData["name"],"rollno": LoginStore.userData["rollNo"],"email" : LoginStore.userData["outlookEmail"]});
}
}
diff --git a/lib/pages/splash.dart b/lib/pages/splash.dart
index 82bcd613..048d075d 100644
--- a/lib/pages/splash.dart
+++ b/lib/pages/splash.dart
@@ -1,4 +1,7 @@
import 'package:flutter/material.dart';
+import 'package:onestop_dev/functions/utility/show_snackbar.dart';
+import 'package:onestop_dev/models/profile/profile_model.dart';
+import 'package:onestop_dev/pages/profile/edit_profile.dart';
import 'package:onestop_dev/stores/login_store.dart';
import 'package:provider/provider.dart';
@@ -18,12 +21,12 @@ class _SplashPageState extends State {
Provider.of(context, listen: false)
.isAlreadyAuthenticated()
.then((result) {
- if (result) {
+ if (result && LoginStore.isProfileComplete){
Navigator.of(context)
.pushNamedAndRemoveUntil('/home2', (Route route) => false);
} else {
Navigator.of(context)
- .pushNamedAndRemoveUntil('/login', (Route route) => false);
+ .pushNamedAndRemoveUntil('/login2', (Route route) => false);
}
});
}
diff --git a/lib/pages/timetable/timetable.dart b/lib/pages/timetable/timetable.dart
index 88ffbad3..e9c0c98b 100644
--- a/lib/pages/timetable/timetable.dart
+++ b/lib/pages/timetable/timetable.dart
@@ -1,12 +1,15 @@
import 'package:flutter/material.dart';
import 'package:flutter_mobx/flutter_mobx.dart';
+import 'package:onestop_dev/pages/lost_found/lnf_home.dart';
+import 'package:onestop_dev/stores/login_store.dart';
import 'package:onestop_dev/stores/timetable_store.dart';
import 'package:onestop_dev/widgets/timetable/date_slider.dart';
import 'package:onestop_dev/widgets/ui/list_shimmer.dart';
import 'package:provider/provider.dart';
+import 'package:onestop_dev/widgets/ui/guest_restrict.dart';
class TimeTableTab extends StatefulWidget {
- static const String id = 'time';
+ static const String id = '/time';
const TimeTableTab({Key? key}) : super(key: key);
@override
State createState() => _TimeTableTabState();
@@ -16,7 +19,7 @@ class _TimeTableTabState extends State {
List