Skip to content

Commit

Permalink
created settings page (PalisadoesFoundation#2299)
Browse files Browse the repository at this point in the history
* created settings page

* formatted the code

* fixed failing tests

* resolved requested changes

* fixed failing tests
  • Loading branch information
Azad99-9 authored and palisadian committed Jan 10, 2024
1 parent 9b34466 commit fdee105
Show file tree
Hide file tree
Showing 19 changed files with 716 additions and 240 deletions.
7 changes: 7 additions & 0 deletions android/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,13 @@
<uses-permission android:name="android.permission.VIBRATE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"
tools:ignore="ScopedStorage" />
<queries>
<intent>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="https" />
</intent>
</queries>
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
Expand Down
5 changes: 5 additions & 0 deletions ios/Runner/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -57,5 +57,10 @@
<true/>
<key>NSCameraUsageDescription</key>
<string>This app needs camera access to scan QR codes</string>
<key>LSApplicationQueriesSchemes</key>
<array>
<string>sms</string>
<string>tel</string>
</array>
</dict>
</plist>
2 changes: 2 additions & 0 deletions lib/locator.dart
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import 'package:talawa/view_model/after_auth_view_models/event_view_models/explo
import 'package:talawa/view_model/after_auth_view_models/feed_view_models/organization_feed_view_model.dart';
import 'package:talawa/view_model/after_auth_view_models/profile_view_models/edit_profile_view_model.dart';
import 'package:talawa/view_model/after_auth_view_models/profile_view_models/profile_page_view_model.dart';
import 'package:talawa/view_model/after_auth_view_models/settings_view_models/app_setting_view_model.dart';
import 'package:talawa/view_model/after_auth_view_models/task_view_models/create_task_view_model.dart';
import 'package:talawa/view_model/after_auth_view_models/task_view_models/explore_tasks_view_model.dart';
import 'package:talawa/view_model/lang_view_model.dart';
Expand Down Expand Up @@ -135,6 +136,7 @@ void setupLocator() {
locator.registerFactory(() => EditEventViewModel());
locator.registerFactory(() => AddPostViewModel());
locator.registerFactory(() => EventInfoViewModel());
locator.registerFactory(() => AppSettingViewModel());

//Widgets viewModels
locator.registerFactory(() => ProgressDialogViewModel());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@ import 'package:talawa/services/user_config.dart';
import 'package:talawa/utils/app_localization.dart';
import 'package:talawa/view_model/base_view_model.dart';
import 'package:talawa/view_model/lang_view_model.dart';
import 'package:talawa/widgets/custom_alert_dialog.dart';
import 'package:talawa/widgets/talawa_error_dialog.dart';

/// ProfilePageViewModel class helps to interact with model to serve data and react to user's input in Profile Page view.
///
Expand Down Expand Up @@ -78,18 +76,6 @@ class ProfilePageViewModel extends BaseModel {
setState(ViewState.idle);
}

/// This method destroys the user's session or sign out the user from app, The function asks for the confimation in Custom Alert Dialog.
///
/// **params**:
/// * `context`: BuildContext of the widget
///
/// **returns**:
/// * `Future<void>`: Resolves when user logout
Future<void> logout(BuildContext context) async {
// push custom alert dialog with the confirmation message.
navigationService.pushDialog(logoutDialog());
}

/// This method changes the currency of the user for donation purpose.
///
/// **params**:
Expand Down Expand Up @@ -185,33 +171,6 @@ class ProfilePageViewModel extends BaseModel {
);
}

Widget logoutDialog() {
return CustomAlertDialog(
reverse: true,
dialogSubTitle: 'Are you sure you want to logout?',
successText: 'Logout',
success: () async {
await userConfig.userLogOut();
navigationService.pop();
if (userConfig.loggedIn) {
navigationService.pushDialog(
const TalawaErrorDialog(
'Unable to logout, please try again.',
key: Key('TalawaError'),
messageType: MessageType.error,
),
);
} else {
navigationService.removeAllAndPush(
'/selectLang',
'/',
arguments: '0',
);
}
},
);
}

/// This widget returns the button for social media sharing option.
///
/// **params**:
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
import 'package:flutter/material.dart';
import 'package:talawa/enums/enums.dart';
import 'package:talawa/locator.dart';
import 'package:talawa/services/navigation_service.dart';
import 'package:talawa/view_model/base_view_model.dart';
import 'package:talawa/widgets/custom_alert_dialog.dart';
import 'package:talawa/widgets/talawa_error_dialog.dart';
import 'package:url_launcher/url_launcher_string.dart';

/// ViewModel for the App Settings functionality.
///
/// This ViewModel handles the logic and data for the application settings.
class AppSettingViewModel extends BaseModel {
// Services
final _navigationService = locator<NavigationService>();
// final _appLanguageService = locator<AppLanguage>();

/// This method destroys the user's session or sign out the user from app, The function asks for the confimation in Custom Alert Dialog.
///
/// **params**:
/// * `context`: BuildContext of the widget
///
/// **returns**:
/// * `Future<void>`: Resolves when user logout
Future<void> logout(BuildContext context) async {
// push custom alert dialog with the confirmation message.
_navigationService.pushDialog(logoutDialog());
}

/// Launches a website using the provided URL.
///
/// **params**:
/// * `url`: A [String] representing the URL of the website to be launched.
///
/// **returns**:
/// * `Future<bool>`: A [Future] that resolves to a [bool] value indicating
/// whether the website launch was successful.
Future<bool> launchWebsite(String url) async => await launchUrlString(url);

/// Creates a custom alert dialog for the logout confirmation.
///
/// This dialog prompts the user with a confirmation message for logout.
/// The dialog provides options to logout or cancel the operation.
///
/// **params**:
/// None
///
/// **returns**:
/// * `Widget`: A [Widget] representing the custom logout confirmation dialog.
Widget logoutDialog() {
return CustomAlertDialog(
reverse: true,
dialogSubTitle: 'Are you sure you want to logout?',
successText: 'Logout',
success: () async {
await userConfig.userLogOut();
navigationService.pop();
if (userConfig.loggedIn) {
navigationService.pushDialog(
const TalawaErrorDialog(
'Unable to logout, please try again.',
key: Key('TalawaError'),
messageType: MessageType.error,
),
);
} else {
navigationService.removeAllAndPush(
'/selectLang',
'/',
arguments: '0',
);
}
},
);
}
}
Loading

0 comments on commit fdee105

Please sign in to comment.