-
-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add Privacy Policy and Open-Source Licenses
- Loading branch information
1 parent
ba56f2f
commit 62a6e92
Showing
6 changed files
with
290 additions
and
227 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
112 changes: 112 additions & 0 deletions
112
lib/settingsComponent/views/appearance_settings_view.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,112 @@ | ||
import 'dart:io'; | ||
|
||
import 'package:campus_flutter/base/enums/appearance.dart'; | ||
import 'package:campus_flutter/base/extensions/context.dart'; | ||
import 'package:campus_flutter/base/helpers/icon_text.dart'; | ||
import 'package:campus_flutter/base/views/seperated_list.dart'; | ||
import 'package:campus_flutter/gradeComponent/viewModels/grade_viewmodel.dart'; | ||
import 'package:campus_flutter/homeComponent/widgetComponent/views/widget_frame_view.dart'; | ||
import 'package:campus_flutter/main.dart'; | ||
import 'package:campus_flutter/settingsComponent/viewModels/user_preferences_viewmodel.dart'; | ||
import 'package:campus_flutter/settingsComponent/views/default_maps_picker_view.dart'; | ||
import 'package:campus_flutter/settingsComponent/views/settings_view.dart'; | ||
import 'package:flutter/foundation.dart'; | ||
import 'package:flutter/material.dart'; | ||
import 'package:flutter_riverpod/flutter_riverpod.dart'; | ||
import 'package:map_launcher/map_launcher.dart'; | ||
|
||
class AppearanceSettingsView extends ConsumerWidget { | ||
const AppearanceSettingsView({super.key}); | ||
|
||
@override | ||
Widget build(BuildContext context, WidgetRef ref) { | ||
return WidgetFrameView( | ||
title: context.localizations.appearance, | ||
child: Card( | ||
child: SeparatedList.widgets( | ||
widgets: [ | ||
_appearanceSelection(context, ref), | ||
if (!kIsWeb && Platform.isIOS) _useWebView(context, ref), | ||
_hideFailedGrades(context, ref), | ||
if (!kIsWeb && getIt.get<List<AvailableMap>>().isNotEmpty) | ||
const DefaultMapsPickerView(), | ||
], | ||
), | ||
), | ||
); | ||
} | ||
|
||
Widget _appearanceSelection(BuildContext context, WidgetRef ref) { | ||
return ListTile( | ||
dense: true, | ||
title: Text( | ||
context.localizations.theme, | ||
style: Theme.of(context).textTheme.bodyMedium, | ||
), | ||
trailing: DropdownButton( | ||
onChanged: (Appearance? newAppearance) { | ||
if (newAppearance != null) { | ||
ref.read(appearance.notifier).state = newAppearance; | ||
ref | ||
.read(userPreferencesViewModel) | ||
.saveUserPreference(UserPreference.theme, newAppearance); | ||
} | ||
}, | ||
value: ref.watch(appearance), | ||
items: Appearance.values | ||
.map( | ||
(e) => DropdownMenuItem( | ||
value: e, | ||
child: IconText( | ||
iconData: e.icon, | ||
iconColor: Theme.of(context).primaryColor, | ||
label: ref.read(locale).languageCode == "de" | ||
? e.german | ||
: e.english, | ||
), | ||
), | ||
) | ||
.toList(), | ||
), | ||
); | ||
} | ||
|
||
Widget _useWebView(BuildContext context, WidgetRef ref) { | ||
return ListTile( | ||
dense: true, | ||
title: Text( | ||
context.localizations.useWebView, | ||
style: Theme.of(context).textTheme.bodyMedium, | ||
), | ||
trailing: Switch( | ||
value: ref.watch(useWebView), | ||
onChanged: (showWebView) { | ||
ref | ||
.read(userPreferencesViewModel) | ||
.saveUserPreference(UserPreference.webView, showWebView); | ||
ref.read(useWebView.notifier).state = showWebView; | ||
}, | ||
), | ||
); | ||
} | ||
|
||
Widget _hideFailedGrades(BuildContext context, WidgetRef ref) { | ||
return ListTile( | ||
dense: true, | ||
title: Text( | ||
context.localizations.hideFailedGrades, | ||
style: Theme.of(context).textTheme.bodyMedium, | ||
), | ||
trailing: Switch( | ||
value: ref.watch(hideFailedGrades), | ||
onChanged: (value) { | ||
ref | ||
.read(userPreferencesViewModel) | ||
.saveUserPreference(UserPreference.hideFailedGrades, value); | ||
ref.read(hideFailedGrades.notifier).state = value; | ||
ref.read(gradeViewModel).fetch(false); | ||
}, | ||
), | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
import 'dart:io'; | ||
|
||
import 'package:campus_flutter/base/extensions/context.dart'; | ||
import 'package:campus_flutter/base/helpers/hyperlink_text.dart'; | ||
import 'package:campus_flutter/base/views/seperated_list.dart'; | ||
import 'package:campus_flutter/feedbackComponent/views/feedback_form_view.dart'; | ||
import 'package:campus_flutter/homeComponent/widgetComponent/views/widget_frame_view.dart'; | ||
import 'package:flutter/foundation.dart'; | ||
import 'package:flutter/material.dart'; | ||
import 'package:flutter_riverpod/flutter_riverpod.dart'; | ||
|
||
class ContactView extends ConsumerWidget { | ||
const ContactView({super.key}); | ||
|
||
@override | ||
Widget build(BuildContext context, WidgetRef ref) { | ||
return WidgetFrameView( | ||
title: context.localizations.contactMore, | ||
child: Card( | ||
child: SeparatedList.widgets( | ||
widgets: [ | ||
if (!kIsWeb) | ||
HyperLinkListTile( | ||
dense: true, | ||
link: _betaTester(), | ||
label: context.localizations.becomeABetaTester, | ||
), | ||
HyperLinkListTile( | ||
dense: true, | ||
link: "https://github.com/TUM-Dev", | ||
label: context.localizations.usOnGitHub, | ||
), | ||
const HyperLinkListTile( | ||
dense: true, | ||
link: "https://app.tum.de", | ||
label: "TUM Dev Website", | ||
), | ||
HyperLinkListTile( | ||
dense: true, | ||
link: "https://www.tum.app/privacy", | ||
label: context.localizations.privacyPolicy, | ||
), | ||
_licensesButton(context), | ||
_feedbackButton(context), | ||
], | ||
), | ||
), | ||
); | ||
} | ||
|
||
String _betaTester() { | ||
if (Platform.isAndroid) { | ||
return "https://play.google.com/store/apps/details?id=de.tum.tca_flutter"; | ||
} else { | ||
return "https://testflight.apple.com/join/4Ddi6f2f"; | ||
} | ||
} | ||
|
||
Widget _feedbackButton(BuildContext context) { | ||
return ListTile( | ||
dense: true, | ||
title: Text( | ||
"Feedback", | ||
style: Theme.of(context).textTheme.bodyMedium, | ||
), | ||
onTap: () => Navigator.push( | ||
context, | ||
MaterialPageRoute( | ||
builder: (context) => const FeedbackFormScaffold(), | ||
), | ||
), | ||
); | ||
} | ||
|
||
Widget _licensesButton(BuildContext context) { | ||
return ListTile( | ||
dense: true, | ||
title: Text( | ||
context.localizations.licenses, | ||
style: Theme.of(context).textTheme.bodyMedium, | ||
), | ||
onTap: () => showLicensePage(context: context), | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
import 'package:campus_flutter/base/extensions/context.dart'; | ||
import 'package:campus_flutter/base/views/seperated_list.dart'; | ||
import 'package:campus_flutter/homeComponent/widgetComponent/views/widget_frame_view.dart'; | ||
import 'package:campus_flutter/loginComponent/views/permission_check_view.dart'; | ||
import 'package:campus_flutter/base/extensions/locale_fullname.dart'; | ||
import 'package:campus_flutter/main.dart'; | ||
import 'package:campus_flutter/settingsComponent/viewModels/user_preferences_viewmodel.dart'; | ||
import 'package:flutter_gen/gen_l10n/app_localizations.dart'; | ||
import 'package:flutter/material.dart'; | ||
import 'package:flutter_riverpod/flutter_riverpod.dart'; | ||
|
||
class GeneralSettingsView extends ConsumerWidget { | ||
const GeneralSettingsView({super.key}); | ||
|
||
@override | ||
Widget build(BuildContext context, WidgetRef ref) { | ||
return WidgetFrameView( | ||
title: context.localizations.generalSettings, | ||
child: Card( | ||
child: SeparatedList.widgets( | ||
widgets: [ | ||
_tokenPermission(context), | ||
_localeSelection(context, ref), | ||
], | ||
), | ||
), | ||
); | ||
} | ||
|
||
Widget _tokenPermission(BuildContext context) { | ||
return ListTile( | ||
dense: true, | ||
leading: Icon(Icons.key, size: 20, color: Theme.of(context).primaryColor), | ||
title: Text( | ||
context.localizations.tokenPermissions, | ||
style: Theme.of(context).textTheme.bodyMedium, | ||
), | ||
trailing: const Icon(Icons.arrow_forward_ios, size: 15), | ||
onTap: () => Navigator.of(context).push( | ||
MaterialPageRoute( | ||
builder: (context) => const PermissionCheckView(isSettingsView: true), | ||
), | ||
), | ||
); | ||
} | ||
|
||
Widget _localeSelection(BuildContext context, WidgetRef ref) { | ||
return ListTile( | ||
dense: true, | ||
leading: Icon( | ||
Icons.language, | ||
size: 20, | ||
color: Theme.of(context).primaryColor, | ||
), | ||
title: Text( | ||
context.localizations.language, | ||
style: Theme.of(context).textTheme.bodyMedium, | ||
), | ||
trailing: DropdownButton( | ||
onChanged: (Locale? newLocale) { | ||
if (newLocale != null) { | ||
ref | ||
.read(userPreferencesViewModel) | ||
.saveUserPreference(UserPreference.locale, newLocale); | ||
ref.read(locale.notifier).state = newLocale; | ||
} | ||
}, | ||
value: ref.watch(locale), | ||
items: AppLocalizations.supportedLocales | ||
.map((e) => DropdownMenuItem(value: e, child: Text(e.fullName()))) | ||
.toList(), | ||
), | ||
); | ||
} | ||
} |
Oops, something went wrong.