From 591c6a11cd85e2ffdcbb226839454500b5100c9a Mon Sep 17 00:00:00 2001 From: Siddhesh Bhupendra Kuakde Date: Mon, 13 Mar 2023 23:38:06 +0530 Subject: [PATCH] Ignoring file that are generated during talawa testing and firebase initialization closes #1573 and Documentation for lib/main.dart and Fixing the TypeError in Linting #1654 (#1632) * Create .gitpod.yml * Create .gitpod.Dockerfile * Add/temp-file * Add/temp-plugin gives sample demo for `TalawaPluginProvider ` * remove/unecessary-files#1 * remove/unecessary-files#2 * Add/TalwaPluginProvider * Add/queries `getPluginsList` * Docs for 'TalawaPluginProvider' * `Add/fetch_plugin_list` * Refractoring & adding `fetchPlugins` in main * Delete sa.dart * Delete tempPlugin.dart * Test/ `Tawla Plugin Provider` * Refractor : Added `Braintree` config in AndroidManifest.xml * Refractor : Added `Talawa_plugin_provider_nav` to control plugins visibility in navbar * Update : Main file setState fix * Changed ios version from `10.0` to `12.0` * Add : `Donation` feature as Plugin with braintree API * Add : `createDonation` Mutation * Fix : `Plugin` render bug * Chores : Formatted files * Add : `navBarItems` (features) as plugins * Chores : Formatting * Update : Profile removed key * Chores : Add `Flutter_Braintree` * Chores : Fix `Lint errors` * Fix : Formatting Errors * Delete talawa_plugin_provider_nav.dart * Update pull-request.yml * Added a empty line in main * Update pull-request.yml * Fix : Faling tests * Fix : Failing test #2 commented out `teste.pumpAndSetttle` * Remove : all the changes done in the `custom_drawer_test.dart` Removed everthing that I've added to check if it will pass the test or not. * PR Fail Fix Attempt #1 : Added `fetchPluginLIst` in `main.dart` * PR Fail Fix Attempt #2 : Commenting test cases to check furthur problems * Chores : Commented Imports * Deleted : Test file * Fix: Trigger workflow * Add : Faling test back `custom_drawer_test.dart` * Add Test for `utils/query.dart` * Add : Tests `queries_test.dart` * Add : Tests `chat_queries_test.dart` * Add : Test for `comment_queries_test.dart` * Add : test for `event_queries_test` * Add : test for `post_qurie..dart` * Add : test for `post_query.dart` * Add : test for `task_queries.dart` * Add : test for `utils/validator.dart` * Fix : failing tests * Test : Failing test uncommented `custom_drawer_test.dart` * Fix : Commented `custom_drawer_test.dart` * removed utils tests * Removed Commented Code * add/table of contents and link to installation file. * Update/ gitignore fixes #1573 * Added try catch in firebase options * Docs/main.dart * remove ignore from main.dart * remove ignore from main.dart 2 * remove ignore from main.dart 3 * remove ignore from main.dart 4 * Error fix on lint doc. * Error fix on lint doc. 2 * Error fix on lint doc. 3 * Fix Doc error: 5 * main.dart comments * Updated docs for :main.dart * Updated docs for :main.dart 2 --- .gitignore | 4 ++ lib/main.dart | 103 ++++++++++++++++++++++----- talawa_lint/lib/talawa_good_doc.dart | 12 ++-- 3 files changed, 97 insertions(+), 22 deletions(-) diff --git a/.gitignore b/.gitignore index 7d9c8f3b88..d0cd2ee334 100644 --- a/.gitignore +++ b/.gitignore @@ -240,3 +240,7 @@ dmypy.json test/fixtures/core # End of https://www.gitignore.io/api/python + +# Ignoring file that are generated during talawa testing and firebase initialization +genhtml.perl +test_img.png diff --git a/lib/main.dart b/lib/main.dart index be137a5d5d..2247d6f7bd 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -1,6 +1,3 @@ -// ignore_for_file: talawa_api_doc -// ignore_for_file: talawa_good_doc_comments - import 'dart:io'; import 'package:firebase_core/firebase_core.dart'; @@ -28,10 +25,14 @@ import 'package:talawa/view_model/lang_view_model.dart'; import 'package:talawa/view_model/theme_view_model.dart'; import 'package:talawa/views/base_view.dart'; -/// Define a top-level named handler which background/terminated messages will -/// call. +/// Define a top-level named handler which background/terminated messages will call. /// /// To verify things are working, check out the native platform logs. +/// params: +/// * `message`: incoming messsage. +/// +/// returns: +/// * `Future`: promise that will be fulfilled message background activities are successful. Future _firebaseMessagingBackgroundHandler(RemoteMessage message) async { // If you're going to use other Firebase services in the background, such as Firestore, // make sure you call `initializeApp` before using other Firebase services. @@ -41,6 +42,13 @@ Future _firebaseMessagingBackgroundHandler(RemoteMessage message) async { await setUpFirebase(); } +/// Initializes the firebase in the app according to the userplatform (android/iOS). +/// +/// params: +/// None +/// +/// returns: +/// * `Future`: promise that will be fulfilled Firebase is setted up in app. Future setUpFirebase() async { await Firebase.initializeApp( options: DefaultFirebaseOptions.currentPlatform( @@ -50,16 +58,25 @@ Future setUpFirebase() async { ); } +/// HashMap of Firebase options for android. late Map androidFirebaseOptions; + +/// HashMap of Firebase options for android. late Map iosFirebaseOptions; -/// Create a [AndroidNotificationChannel] for heads up notifications +/// Create a [AndroidNotificationChannel] for heads up notifications. late AndroidNotificationChannel channel; /// Initialize the [FlutterLocalNotificationsPlugin] package. late FlutterLocalNotificationsPlugin flutterLocalNotificationsPlugin; -/// This is the main function +/// First function to initialize the application, invoked automatically. +/// +/// params: +/// None +/// +/// returns: +/// * `Future`: resolves if the application was successfully initialized. Future main() async { // Returns an instance of the binding that implements WidgetsBinding. WidgetsFlutterBinding.ensureInitialized(); @@ -99,11 +116,15 @@ Future main() async { final urlBox = await Hive.openBox('url'); - if (urlBox.get('url') != null) { - await setUpFirebaseKeys(); + try { + if (urlBox.get('url') != null) { + await setUpFirebaseKeys(); - await setUpFirebase(); - await setUpFirebaseMessaging(); + await setUpFirebase(); + await setUpFirebaseMessaging(); + } + } catch (e) { + print("Firebase not working"); } setupLocator(); @@ -111,6 +132,13 @@ Future main() async { runApp(MyApp()); } +/// Initializes the firebase keys in the app according to the userplatform (android/iOS). +/// +/// params: +/// None +/// +/// returns: +/// * `Future`: promise that will be fulfilled Firebase keys are setted up. Future setUpFirebaseKeys() async { final androidFirebaseOptionsBox = await Hive.openBox('androidFirebaseOptions'); @@ -132,6 +160,7 @@ Future setUpFirebaseKeys() async { } } +/// Main widget that sets up the quick actions, internationalization, routing , notifications. class MyApp extends StatefulWidget { // This widget is the root of your application. @override @@ -139,9 +168,13 @@ class MyApp extends StatefulWidget { } /// The _MyAppState class extends the State. +/// /// All the coding related to state updation is inside this class. class _MyAppState extends State { + /// Initializing the Quickactions to enable them on long press of app icon in device. final quickActions = const QuickActions(); + + /// Initializing the mainScreen window to 1 to show the events by default after app in opened. late int mainScreenQuickActionindex = 0; @override void initState() { @@ -160,8 +193,15 @@ class _MyAppState extends State { ); } - // It allows to manage and interact with the application’s home screen quick actions. - initQuickActions() async { + /// It allows to manage and interact with the application’s home screen quick actions. + /// + /// params: + /// None + /// returns: + /// None + +// ignore: avoid_void_async + void initQuickActions() async { final bool userLoggedIn = await userConfig.userLoggedIn(); if (userLoggedIn && userConfig.currentUser.joinedOrganizations!.isNotEmpty) { @@ -174,12 +214,12 @@ class _MyAppState extends State { mainScreenQuickActionindex = 3; } }); + + /// Registering quick action list in the app.zx quickActions.setShortcutItems(ShortCutMenu.quickActionsList); } } - // The build method is called any time you call setState ,your widget's - // dependencies update, or any of the parent widgets are rebuilt. @override Widget build(BuildContext context) { return BaseView( @@ -246,10 +286,18 @@ class _MyAppState extends State { } /// PageView is a scrollable list that works page by page. +/// /// DemoPageView is demo PageView of Talawa Mobile App. class DemoPageView extends StatelessWidget { const DemoPageView({required Key key}) : super(key: key); + /// Builds the UI enabling plugins and localization. + /// + /// params: + /// * `context`: object containing data of the entire UI of the app. + /// + /// returns: + /// * `Widget`: UI of the app. @override Widget build(BuildContext context) { FetchPluginList(); @@ -267,20 +315,39 @@ class DemoPageView extends StatelessWidget { } } -/// ViewModel uses property-based data binding to establish a connection +/// ViewModel uses property-based data binding to establish a connection. +/// /// between the ViewModel and the View, and drives the View changes /// through the ViewModel. DemoViewModel is the ViewModel for DemoPageView. +/// params: +/// None +/// returns: +/// None class DemoViewModel extends BaseModel { + /// Demo title to be used. final String _title = "Title from the viewMode GSoC branch"; + + /// Getter function of the title. + /// + /// params: + /// None + /// returns: + /// * `String`: title of the model String get title => _title; } +/// Set up firebase instance, enbables messaging,listens to icoming messages. +/// +/// params: +/// None +/// +/// returns: +/// * `Future`: promise that will be fulfilled Firebase is setted up. Future setUpFirebaseMessaging() async { /// Set the background messaging handler early on, as a named top-level function FirebaseMessaging.onBackgroundMessage(_firebaseMessagingBackgroundHandler); - /// Update the iOS foreground notification presentation options to allow - /// heads up notifications. + // Update the iOS foreground notification presentation options to allow heads up notifications. await FirebaseMessaging.instance.setForegroundNotificationPresentationOptions( alert: true, badge: true, diff --git a/talawa_lint/lib/talawa_good_doc.dart b/talawa_lint/lib/talawa_good_doc.dart index 62069f6d1d..f899abb15e 100644 --- a/talawa_lint/lib/talawa_good_doc.dart +++ b/talawa_lint/lib/talawa_good_doc.dart @@ -353,9 +353,11 @@ class _Visitor extends SimpleAstVisitor { bool isVoid = false; if (node is FunctionDeclaration) { - isVoid = node.returnType!.type!.isVoid; + final nodeReturnTypeLocal = node.returnType; + isVoid = nodeReturnTypeLocal?.type!.isVoid == true; } else if (node is MethodDeclaration) { - isVoid = node.returnType!.type!.isVoid; + final nodeReturnTypeLocal = node.returnType; + isVoid = nodeReturnTypeLocal?.type!.isVoid == true; } if (!containsReturn && !isVoid) { @@ -422,9 +424,11 @@ class _Visitor extends SimpleAstVisitor { late final returnType; if (node is FunctionDeclaration) { - returnType = node.returnType!.type; + final nodeReturnTypeLocal = node.returnType; + returnType = nodeReturnTypeLocal?.type; } else if (node is MethodDeclaration) { - returnType = node.returnType!.type; + final nodeReturnTypeLocal = node.returnType; + returnType = nodeReturnTypeLocal?.type; } // If return type is not [void] and doc doesn't end with [return_type] or