diff --git a/lib/l10n/app_en.arb b/lib/l10n/app_en.arb new file mode 100644 index 0000000000..a12b5f2667 --- /dev/null +++ b/lib/l10n/app_en.arb @@ -0,0 +1,45 @@ +{ + "friday": "Friday", + "@friday": { + "description": "App's name" + }, + "hellosir": "Hello, Sir!", + "recentalerts": "Recent Alerts", + "viewall": "View all", + "seefavourites": "SEE FAVOURITES", + "search": "search", + "recenthomework": "Recent Homework", + "favourites": "Favourites", + "clearallfavourites": "CLEAR ALL FAVOURITES", + "hoursleft": "hours left", + "addnewclass": "Add New Class", + "mode": "Mode", + "teachername": "Teacher Name", + "date": "Date", + "time": "Time", + "joinlink": "Join Link", + "subject": "वSubject", + "save": "Save", + "yourprofile": "Your Profile", + "loading": "Loading...", + "email": "Email", + "bio": "Bio", + "college": "College", + "course": "Course", + "departmentmajor": "Department/Major", + "currentacademicyear": "Current Academic Year", + "gender": "Gender", + "age": "Age", + "settings": "Settings", + "common": "Common", + "language": "Language", + "lightmode": "Light Mode", + "notifications": "Notifications", + "notificationsdesc": "Turn your app notifications on or off", + "help": "Help", + "helpdesc": "See our help modules for queries", + "faqs": "FAQs", + "faqsdesc": "Basic usage guidelines", + "supportdevelopment": "Support Development", + "supportdevelopmentdesc": "See latest issues and contribute to the project!" +} \ No newline at end of file diff --git a/lib/l10n/app_hi.arb b/lib/l10n/app_hi.arb new file mode 100644 index 0000000000..338f469d9a --- /dev/null +++ b/lib/l10n/app_hi.arb @@ -0,0 +1,43 @@ +{ + "friday": "शुक्रवार", + "hellosir": "नमस्ते महोदय!", + "recentalerts": "हालिया अलर्ट", + "viewall": "सभी देखें", + "seefavourites": "पसंदीदा देखें", + "search": "खोजो", + "recenthomework": "हालिया होमवर्क", + "favourites": "पसंदीदा", + "clearallfavourites": "सभी पसंदीदा साफ़ करें", + "hoursleft": "घंटे बाकी है", + "addnewclass": "नई कक्षा जोड़ें", + "mode": "प्रकार", + "teachername": "शिक्षक का नाम", + "date": "तारीख", + "time": "समय", + "joinlink": "लिंक से जुड़ें", + "subject": "विषय", + "save": "इसे जोड़ें", + "yourprofile": "आपकी प्रोफ़ाइल", + "loading": "लोड हो रहा है...", + "email": "ईमेल", + "bio": "बायो", + "college": "कॉलेज", + "course": "पाठ्यक्रम प्रकार", + "departmentmajor": "विभाग", + "currentacademicyear": "वर्तमान शैक्षणिक वर्ष", + "gender": "लिंग", + "age": "आयु", + "logout": "लॉग आउट", + "settings": "सेटिंग", + "common": "सामान्य", + "language": "भाषा", + "lightmode": "प्रकाश मोड", + "notifications": "सूचनाएं", + "notificationsdesc": "ऐप के नोटिफिकेशन को चालू या बंद करें", + "help": "मदद", + "helpdesc": "प्रश्नों के लिए हमारे सहायता मॉड्यूल देखें", + "faqs": "सामान्य प्रश्न", + "faqsdesc": "बुनियादी उपयोग दिशानिर्देश", + "supportdevelopment": "ऐप के विकास का समर्थन करें", + "supportdevelopmentdesc": "समस्याओं का समाधान करें, बग की रिपोर्ट करें, इत्यादि|" +} \ No newline at end of file diff --git a/lib/main.dart b/lib/main.dart index e6a5ae075e..be52d4ca95 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -1,4 +1,7 @@ import 'package:firebase_core/firebase_core.dart'; +import 'package:flutter_local_notifications/flutter_local_notifications.dart'; +import 'package:flutter_localizations/flutter_localizations.dart'; +import 'package:flutter_gen/gen_l10n/app_localizations.dart'; import 'package:friday/models/alert.dart'; import 'package:friday/screens/faqs_screen.dart'; import 'package:friday/screens/onboarding_page.dart'; @@ -27,9 +30,12 @@ import 'screens/help_screen.dart'; import 'screens/contact_us_screen.dart'; import 'screens/app_info_screen.dart'; import 'onboarding/introslider.dart'; +import 'utils/notifications.dart'; void main() async { WidgetsFlutterBinding.ensureInitialized(); + NotificationService().initNotification(); + NotificationService().showNotification(title: 'olalalaaa', body: 'it works'); await Firebase.initializeApp(); runApp(MyApp()); } @@ -48,6 +54,8 @@ class _MyAppState extends State { void initState() { super.initState(); checkFirstRun(); + + loadpref(); } @@ -116,6 +124,17 @@ class _MyAppState extends State { child: WillPopScope( onWillPop:onWillPop, child: MaterialApp( + localizationsDelegates: [ + AppLocalizations.delegate, + GlobalMaterialLocalizations.delegate, + GlobalWidgetsLocalizations.delegate, + GlobalCupertinoLocalizations.delegate, + ], + locale: Locale('en'), + supportedLocales: [ + Locale('en'), // English + Locale('hi'), // Hindi + ], debugShowCheckedModeBanner: false, title: 'Friday', theme: ThemeData( diff --git a/lib/screens/alert_screen.dart b/lib/screens/alert_screen.dart index b9e22f8b5d..8d4c6daca4 100644 --- a/lib/screens/alert_screen.dart +++ b/lib/screens/alert_screen.dart @@ -1,5 +1,6 @@ import 'package:flutter/material.dart'; import 'package:friday/widgets/recents_alerts.dart'; +import 'package:flutter_gen/gen_l10n/app_localizations.dart'; class AlertScreen extends StatefulWidget { @override @@ -17,7 +18,7 @@ class _AlertScreenState extends State { children: [ SizedBox(height: 30.0), Text( - "Recent Alerts", + AppLocalizations.of(context).recentalerts, style: TextStyle( color: Colors.white, fontSize: 30.0, diff --git a/lib/screens/favourites_screen.dart b/lib/screens/favourites_screen.dart index f91e34e68f..14d10e72f9 100644 --- a/lib/screens/favourites_screen.dart +++ b/lib/screens/favourites_screen.dart @@ -2,6 +2,7 @@ import 'package:flutter/material.dart'; import 'package:flutter_icons_null_safety/flutter_icons_null_safety.dart'; import 'package:intl/intl.dart'; import 'package:shared_preferences/shared_preferences.dart'; +import 'package:flutter_gen/gen_l10n/app_localizations.dart'; import '../constants.dart'; import '../models/alert.dart'; import '../widgets/countdown_painter.dart'; @@ -42,7 +43,7 @@ class _FavouritesScreenState extends State { SizedBox(height: 30.0), Text( - "Favourites", + AppLocalizations.of(context).favourites, style: TextStyle( color: Colors.white, fontSize: 30.0, @@ -53,7 +54,7 @@ class _FavouritesScreenState extends State { Center(child: TextButton(onPressed: () { removeall(); }, - child: Text('CLEAR ALL FAVOURITES')),), + child: Text(AppLocalizations.of(context).clearallfavourites)),), SizedBox(height: 30.0), Container( padding: EdgeInsets.all(35.0), diff --git a/lib/screens/home_screen.dart b/lib/screens/home_screen.dart index ba610d70c2..e60a80ffd8 100644 --- a/lib/screens/home_screen.dart +++ b/lib/screens/home_screen.dart @@ -2,6 +2,7 @@ import 'package:flutter_icons_null_safety/flutter_icons_null_safety.dart'; import 'package:friday/models/alert.dart'; import 'package:friday/models/homework.dart'; import 'package:friday/screens/favourites_screen.dart'; +import 'package:flutter_gen/gen_l10n/app_localizations.dart'; import 'package:friday/widgets/countdown_painter.dart'; import 'package:flutter/material.dart'; import 'package:friday/constants.dart'; @@ -112,7 +113,7 @@ class _HomeScreenState extends State with WidgetsBindingObserver { border: InputBorder.none, fillColor: Theme.of(context).primaryColor, filled: true, - hintText: "Search", + hintText: AppLocalizations.of(context).search, hintStyle: TextStyle(color: kTextColor), prefixIcon: Icon(Icons.search, color: kTextColor, size: 26.0), enabledBorder: OutlineInputBorder( @@ -129,7 +130,7 @@ class _HomeScreenState extends State with WidgetsBindingObserver { SizedBox(height: 10,), Center(child: TextButton(onPressed: () { Navigator.of(context).push(MaterialPageRoute(builder: (context) => FavouritesScreen())); - },child: Text('SEE FAVOURITES', style: TextStyle(color: Theme.of(context).colorScheme.secondary),),),), + },child: Text( AppLocalizations.of(context).seefavourites, style: TextStyle(color: Theme.of(context).colorScheme.secondary),),),), SizedBox(height: 15.0), Container( padding: EdgeInsets.all(35.0), @@ -144,7 +145,7 @@ class _HomeScreenState extends State with WidgetsBindingObserver { crossAxisAlignment: CrossAxisAlignment.start, children: [ Text( - "Recent Alerts", + AppLocalizations.of(context).recentalerts, style: TextStyle( color: Colors.white, fontSize: 20.0, @@ -155,7 +156,7 @@ class _HomeScreenState extends State with WidgetsBindingObserver { RecentsAlerts(), Center( child: Text( - "View all", + AppLocalizations.of(context).viewall, style: TextStyle( color: Theme.of(context).colorScheme.secondary, fontSize: 15.0), @@ -163,7 +164,7 @@ class _HomeScreenState extends State with WidgetsBindingObserver { ), SizedBox(height: 20.0), Text( - "Recent Homework", + AppLocalizations.of(context).recenthomework, style: TextStyle( color: Colors.white, fontSize: 20.0, diff --git a/lib/screens/homework_screen.dart b/lib/screens/homework_screen.dart index 79c566eb29..891eeb7536 100644 --- a/lib/screens/homework_screen.dart +++ b/lib/screens/homework_screen.dart @@ -1,5 +1,6 @@ import 'package:flutter/material.dart'; import 'package:friday/widgets/recents_homeworks.dart'; +import 'package:flutter_gen/gen_l10n/app_localizations.dart'; class HomeworkScreen extends StatefulWidget { @override @@ -17,7 +18,7 @@ class _HomeworkScreenState extends State { children: [ SizedBox(height: 30.0), Text( - "Recent Homework", + AppLocalizations.of(context).recenthomework, style: TextStyle( color: Colors.white, fontSize: 30.0, diff --git a/lib/screens/profile_screen.dart b/lib/screens/profile_screen.dart index 7c1949a2b5..6389c578d8 100644 --- a/lib/screens/profile_screen.dart +++ b/lib/screens/profile_screen.dart @@ -4,6 +4,7 @@ import 'package:flutter_share/flutter_share.dart'; import 'package:friday/constants.dart'; import 'package:friday/models/users.dart'; import 'package:friday/screens/onboarding_page.dart'; +import 'package:flutter_gen/gen_l10n/app_localizations.dart'; import 'package:friday/screens/settings_screen.dart'; import 'package:friday/services/authentication.dart'; import 'package:friday/services/facebookAuthentication.dart'; @@ -133,7 +134,7 @@ class _ProfileScreenState extends State { Column( children: [ Text( - "Your Profile", + AppLocalizations.of(context).yourprofile, style: TextStyle( color: Colors.white, fontSize: 30.0, @@ -164,7 +165,7 @@ class _ProfileScreenState extends State { child: Text( userInfo.hasData ? currentUser['name'] - : "Loading...", + : AppLocalizations.of(context).loading, style: TextStyle( fontSize: 20, color: Colors.blue[200], @@ -175,17 +176,17 @@ class _ProfileScreenState extends State { ), SizedBox(height: 20), buildDetails( - "Email", + AppLocalizations.of(context).email, userInfo.hasData ? currentUser['email'] - : "Loading...", + : AppLocalizations.of(context).loading, true), SizedBox(height: 20), buildDetails( - "Bio", + AppLocalizations.of(context).bio, userInfo.hasData ? currentUser['bio'] - ?? 'No bio available' : "Loading...", + ?? 'No bio available' : AppLocalizations.of(context).loading, true), SizedBox(height: 20), Visibility( @@ -226,50 +227,50 @@ class _ProfileScreenState extends State { ), ), buildDetails( - "College", + AppLocalizations.of(context).college, userInfo.hasData ? currentUser['university'] - : "Loading...", + : AppLocalizations.of(context).loading, true), SizedBox(height: 20), buildDetails( - "Course", + AppLocalizations.of(context).course, userInfo.hasData ? currentUser['course'] - : "Loading...", + : AppLocalizations.of(context).loading, true), SizedBox(height: 20), buildDetails( - "Deptartment/Major", + AppLocalizations.of(context).departmentmajor, userInfo.hasData ? currentUser['department'] - : "Loading...", + : AppLocalizations.of(context).loading, true), SizedBox(height: 20), buildDetails( - "Current Academic Year", + AppLocalizations.of(context).currentacademicyear, userInfo.hasData ? currentUser['year'].toString() - : "Loading...", + : AppLocalizations.of(context).loading, true), SizedBox(height: 20), Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ buildDetails( - "Gender", + AppLocalizations.of(context).gender, userInfo.hasData ? enumToString(currentUser['gender']) - : "Loading...", + : AppLocalizations.of(context).loading, true), SizedBox(width: 20), Visibility( visible: !visibilityFields, child: buildDetails( - "Age", + AppLocalizations.of(context).age, userInfo.hasData ? currentUser['age'].toString() - : "Loading...", + : AppLocalizations.of(context).loading, visibilityName), ), Visibility( diff --git a/lib/screens/settings_screen.dart b/lib/screens/settings_screen.dart index 5fe35e5b48..3c68c1bc01 100644 --- a/lib/screens/settings_screen.dart +++ b/lib/screens/settings_screen.dart @@ -3,8 +3,10 @@ import 'package:flutter/rendering.dart'; import 'package:friday/screens/faqs_screen.dart'; import 'package:friday/screens/help_screen.dart'; import 'package:friday/screens/themes.dart'; +import 'package:friday/utils/notifications.dart'; import 'package:open_url/open_url.dart'; import 'package:provider/provider.dart'; +import 'package:flutter_gen/gen_l10n/app_localizations.dart'; import '../models/users.dart'; import '../services/user_info_services.dart'; import 'package:settings_ui/settings_ui.dart'; @@ -90,7 +92,7 @@ class _SettingsScreenState extends State { Column( children: [ Text( - "Settings", + AppLocalizations.of(context).settings, style: TextStyle( color: Colors.white, fontSize: 30.0, @@ -117,7 +119,7 @@ class _SettingsScreenState extends State { ,sections: [ SettingsSection( - title: Text('Common'), + title: Text(AppLocalizations.of(context).common), tiles: [ SettingsTile.navigation( leading: Icon(Icons.language), @@ -126,7 +128,7 @@ class _SettingsScreenState extends State { content: Text("Currently support is for Single language only. Stay tuned!"), )); }, - title: Text('Language'), + title: Text(AppLocalizations.of(context).language), value: Text('English'), ), SettingsTile.switchTile(initialValue: ThemeMode.system == ThemeMode.light ? !modeval : modeval, onToggle: (s) { @@ -144,53 +146,56 @@ class _SettingsScreenState extends State { }); } - }, title: Text('Light mode'), enabled: true, leading: Icon(Icons.light_mode),), + }, title: Text(AppLocalizations.of(context).lightmode), enabled: true, leading: Icon(Icons.light_mode),), SettingsTile.navigation( leading: Icon(Icons.notifications_active_outlined), - title: Text('Notifications'), + title: Text(AppLocalizations.of(context).notifications), onPressed: (s) async { - if(notification!){ - await FlutterLocalNotificationsPlugin().cancelAll(); - ScaffoldMessenger.of(context).showSnackBar(SnackBar( - content: Text("Notifications turned off!"), - )); - } - else { - notificationsInitialize(); - ScaffoldMessenger.of(context).showSnackBar(SnackBar( - content: Text("Notifications turned on!"), - )); - } + + NotificationService().showNotification(title: 'olalalaaa', body: 'it works'); + + //if(notification!){ + //await FlutterLocalNotificationsPlugin().cancelAll(); + //ScaffoldMessenger.of(context).showSnackBar(SnackBar( + // content: Text("Notifications turned off!"), + //)); + //} + //else { + //notificationsInitialize(); + //ScaffoldMessenger.of(context).showSnackBar(SnackBar( + // content: Text("Notifications turned on!"), + //)); + //} - notificationsInitialize(); + //notificationsInitialize(); }, - value: Text('Turn app\'s notifications on or off'), + value: Text(AppLocalizations.of(context).notificationsdesc), ), SettingsTile.navigation( leading: Icon(Icons.help_outline), - title: Text('Help'), + title: Text(AppLocalizations.of(context).help), onPressed: (s) { Navigator.of(context).push(MaterialPageRoute(builder: (context) => HelpScreen())); }, - value: Text('See our help modules for queries'), + value: Text(AppLocalizations.of(context).helpdesc), ), SettingsTile.navigation( leading: Icon(Icons.info_outlined), - title: Text('FAQs'), - value: Text('Basic usage guidelines!'), + title: Text(AppLocalizations.of(context).faqs), + value: Text(AppLocalizations.of(context).faqsdesc), onPressed: (s) { Navigator.of(context).push(MaterialPageRoute(builder: (context) => FAQScreen())); }, ), SettingsTile.navigation( leading: Icon(Icons.support), - title: Text('Support Development'), + title: Text(AppLocalizations.of(context).supportdevelopment), onPressed: (s) async { //js.context.callMethod('open', ['https://github.com/avinashkranjan/Friday']); final result = await openUrl('https://github.com/avinashkranjan/Friday'); @@ -202,7 +207,7 @@ class _SettingsScreenState extends State { } }, - value: Text('Resolve issues, report bugs, write documentations, and much more!'), + value: Text(AppLocalizations.of(context).supportdevelopmentdesc), ), ], diff --git a/lib/services/classes_db_services.dart b/lib/services/classes_db_services.dart index fcc3744f23..ed5c17992f 100644 --- a/lib/services/classes_db_services.dart +++ b/lib/services/classes_db_services.dart @@ -21,7 +21,13 @@ class ClassesDBServices { .get(); Map _classesListStored = Map(); - _classesListStored = (documentSnapShot.data() as Map)['classes']; + if(documentSnapShot.exists) { + _classesListStored = + (documentSnapShot.data() as Map)['classe2s']; + } + else { + print(' null class, not added!'); + } if (_classesListStored.isNotEmpty && _classesListStored.containsKey(_todayDate)) { diff --git a/lib/utils/notifications.dart b/lib/utils/notifications.dart new file mode 100644 index 0000000000..b3b9033067 --- /dev/null +++ b/lib/utils/notifications.dart @@ -0,0 +1,37 @@ +import 'package:flutter_local_notifications/flutter_local_notifications.dart'; + +class NotificationService { + final FlutterLocalNotificationsPlugin notificationsPlugin = + FlutterLocalNotificationsPlugin(); + + Future initNotification() async { + AndroidInitializationSettings initializationSettingsAndroid = + const AndroidInitializationSettings('launch_image'); + + var initializationSettingsIOS = DarwinInitializationSettings( + requestAlertPermission: true, + requestBadgePermission: true, + requestSoundPermission: true, + onDidReceiveLocalNotification: + (int id, String? title, String? body, String? payload) async {}); + + var initializationSettings = InitializationSettings( + android: initializationSettingsAndroid, iOS: initializationSettingsIOS); + await notificationsPlugin.initialize(initializationSettings, + onDidReceiveNotificationResponse: + (NotificationResponse notificationResponse) async {}); + } + + notificationDetails() { + return const NotificationDetails( + android: AndroidNotificationDetails('channelId', 'channelName', + importance: Importance.max), + iOS: DarwinNotificationDetails()); + } + + Future showNotification( + {int id = 0, String? title, String? body, String? payLoad}) async { + return notificationsPlugin.show( + id, title, body, await notificationDetails()); + } +} \ No newline at end of file diff --git a/lib/widgets/build_classes.dart b/lib/widgets/build_classes.dart index 0451d4d20d..9314266277 100644 --- a/lib/widgets/build_classes.dart +++ b/lib/widgets/build_classes.dart @@ -129,9 +129,29 @@ class _BuildClassesState extends State { child: Column( children: [ Card(shape: RoundedRectangleBorder( - borderRadius: BorderRadius.all(Radius.circular(20)) - ),color: Colors.white12, + + borderRadius: BorderRadius.all(Radius.circular(20)) + ),color: Colors.white12, child: + TableCalendar( + onFormatChanged: (format) {}, + firstDay: DateTime.utc(2002), + lastDay: DateTime.utc(2024), + focusedDay: _focusedDay, + selectedDayPredicate: (day) => isSameDay(_selectedDay, day), + eventLoader: _getEventsForDay, + onDaySelected: _onDaySelected, + + calendarStyle: CalendarStyle( + disabledTextStyle: TextStyle(color: Colors.white), + weekNumberTextStyle: TextStyle(color: Theme.of(context).primaryColor), + markerDecoration: BoxDecoration( + shape: BoxShape.circle, + color: Colors.amber, + ), + ), + ),), + TableCalendar( onFormatChanged: (format) {}, firstDay: DateTime.utc(2002), @@ -149,7 +169,8 @@ class _BuildClassesState extends State { color: Colors.amber, ), ), - ),), + ), + classesList != null && classesList.isNotEmpty ? Padding( padding: EdgeInsets.only( diff --git a/lib/widgets/header.dart b/lib/widgets/header.dart index 7917b2eab7..034a2f1724 100644 --- a/lib/widgets/header.dart +++ b/lib/widgets/header.dart @@ -2,6 +2,7 @@ import 'package:friday/services/user_info_services.dart'; import 'package:flutter/material.dart'; import 'package:flutter_svg/flutter_svg.dart'; import 'package:provider/provider.dart'; +import 'package:flutter_gen/gen_l10n/app_localizations.dart'; class Header extends StatelessWidget { @override @@ -24,10 +25,10 @@ class Header extends StatelessWidget { FittedBox( fit: BoxFit.fitWidth, child: Text( - "Hello, " + - (_userInfo.user != null - ? _userInfo.user!.name.split(" ")[0] - : "Sir"), + + _userInfo.user != null + ? "Hello, " + _userInfo.user!.name.split(" ")[0] + : AppLocalizations.of(context).hellosir, style: TextStyle( color: Colors.white, fontSize: 25.0, diff --git a/lib/widgets/recents_alerts.dart b/lib/widgets/recents_alerts.dart index e8edf6035f..b8ccc7cf9b 100644 --- a/lib/widgets/recents_alerts.dart +++ b/lib/widgets/recents_alerts.dart @@ -4,6 +4,7 @@ import 'package:intl/intl.dart'; import 'package:friday/constants.dart'; import 'package:friday/models/alert.dart'; import 'dart:convert'; +import 'package:flutter_gen/gen_l10n/app_localizations.dart'; import 'package:friday/widgets/countdown_painter.dart'; import 'package:shared_preferences/shared_preferences.dart'; import 'package:shared_preferences_android/shared_preferences_android.dart'; @@ -171,7 +172,7 @@ class _RecentsAlertsState extends State with WidgetsBindingObserv ), ), Text( - "hours left", + AppLocalizations.of(context).hoursleft, style: TextStyle( color: _getColor(context, percent), fontSize: 13.0, diff --git a/pubspec.lock b/pubspec.lock index 82f13ff111..5897e1b278 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -414,6 +414,11 @@ packages: url: "https://pub.dev" source: hosted version: "7.0.0+1" + flutter_localizations: + dependency: "direct main" + description: flutter + source: sdk + version: "0.0.0" flutter_login_facebook: dependency: "direct main" description: diff --git a/pubspec.yaml b/pubspec.yaml index b9709c2f01..1ddfb7ef25 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -12,7 +12,7 @@ dependencies: flutter: sdk: flutter - intl: + intl: ^0.17.0 provider: fluttertoast: flutter_svg: @@ -44,6 +44,8 @@ dependencies: http: ^0.13.6 flutter_local_notifications: ^15.1.0+1 + flutter_localizations: + sdk: flutter dev_dependencies: @@ -57,6 +59,7 @@ flutter_icons: image_path: "assets/icons/icon.png" flutter: + generate: true uses-material-design: true assets: