Skip to content

Commit

Permalink
Ignoring file that are generated during talawa testing and firebase i…
Browse files Browse the repository at this point in the history
…nitialization 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
  • Loading branch information
SiddheshKukade authored Mar 13, 2023
1 parent e776b85 commit 591c6a1
Show file tree
Hide file tree
Showing 3 changed files with 97 additions and 22 deletions.
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -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
103 changes: 85 additions & 18 deletions lib/main.dart
Original file line number Diff line number Diff line change
@@ -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';
Expand Down Expand Up @@ -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<void>`: promise that will be fulfilled message background activities are successful.
Future<void> _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.
Expand All @@ -41,6 +42,13 @@ Future<void> _firebaseMessagingBackgroundHandler(RemoteMessage message) async {
await setUpFirebase();
}

/// Initializes the firebase in the app according to the userplatform (android/iOS).
///
/// params:
/// None
///
/// returns:
/// * `Future<void>`: promise that will be fulfilled Firebase is setted up in app.
Future<void> setUpFirebase() async {
await Firebase.initializeApp(
options: DefaultFirebaseOptions.currentPlatform(
Expand All @@ -50,16 +58,25 @@ Future<void> setUpFirebase() async {
);
}

/// HashMap of Firebase options for android.
late Map<String, dynamic> androidFirebaseOptions;

/// HashMap of Firebase options for android.
late Map<String, dynamic> 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<void>`: resolves if the application was successfully initialized.
Future<void> main() async {
// Returns an instance of the binding that implements WidgetsBinding.
WidgetsFlutterBinding.ensureInitialized();
Expand Down Expand Up @@ -99,18 +116,29 @@ Future<void> 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();
// The runApp() function takes the given Widget and makes it the root of the widget tree.
runApp(MyApp());
}

/// Initializes the firebase keys in the app according to the userplatform (android/iOS).
///
/// params:
/// None
///
/// returns:
/// * `Future<void>`: promise that will be fulfilled Firebase keys are setted up.
Future<void> setUpFirebaseKeys() async {
final androidFirebaseOptionsBox =
await Hive.openBox('androidFirebaseOptions');
Expand All @@ -132,16 +160,21 @@ Future<void> 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
_MyAppState createState() => _MyAppState();
}

/// The _MyAppState class extends the State.
///
/// All the coding related to state updation is inside this class.
class _MyAppState extends State<MyApp> {
/// 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() {
Expand All @@ -160,8 +193,15 @@ class _MyAppState extends State<MyApp> {
);
}

// 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) {
Expand All @@ -174,12 +214,12 @@ class _MyAppState extends State<MyApp> {
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<AppLanguage>(
Expand Down Expand Up @@ -246,10 +286,18 @@ class _MyAppState extends State<MyApp> {
}

/// 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();
Expand All @@ -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<void>`: promise that will be fulfilled Firebase is setted up.
Future<void> 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,
Expand Down
12 changes: 8 additions & 4 deletions talawa_lint/lib/talawa_good_doc.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 591c6a1

Please sign in to comment.