advanced_settings_screen.dart 8.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196
  1. import 'package:flutter/material.dart';
  2. import "package:photos/core/error-reporting/super_logging.dart";
  3. import "package:photos/generated/l10n.dart";
  4. import "package:photos/services/memories_service.dart";
  5. import "package:photos/services/user_remote_flag_service.dart";
  6. import 'package:photos/theme/ente_theme.dart';
  7. import 'package:photos/ui/components/buttons/icon_button_widget.dart';
  8. import 'package:photos/ui/components/captioned_text_widget.dart';
  9. import 'package:photos/ui/components/menu_item_widget/menu_item_widget.dart';
  10. import 'package:photos/ui/components/title_bar_title_widget.dart';
  11. import 'package:photos/ui/components/title_bar_widget.dart';
  12. import "package:photos/ui/components/toggle_switch_widget.dart";
  13. import 'package:photos/ui/tools/debug/app_storage_viewer.dart';
  14. import 'package:photos/ui/viewer/gallery/photo_grid_size_picker_page.dart';
  15. import 'package:photos/utils/local_settings.dart';
  16. import 'package:photos/utils/navigation_util.dart';
  17. class AdvancedSettingsScreen extends StatefulWidget {
  18. const AdvancedSettingsScreen({super.key});
  19. @override
  20. State<AdvancedSettingsScreen> createState() => _AdvancedSettingsScreenState();
  21. }
  22. class _AdvancedSettingsScreenState extends State<AdvancedSettingsScreen> {
  23. late int _photoGridSize;
  24. @override
  25. void initState() {
  26. _photoGridSize = LocalSettings.instance.getPhotoGridSize();
  27. super.initState();
  28. }
  29. @override
  30. Widget build(BuildContext context) {
  31. final colorScheme = getEnteColorScheme(context);
  32. return Scaffold(
  33. body: CustomScrollView(
  34. primary: false,
  35. slivers: <Widget>[
  36. TitleBarWidget(
  37. flexibleSpaceTitle: TitleBarTitleWidget(
  38. title: S.of(context).advancedSettings,
  39. ),
  40. actionIcons: [
  41. IconButtonWidget(
  42. icon: Icons.close_outlined,
  43. iconButtonType: IconButtonType.secondary,
  44. onTap: () {
  45. Navigator.pop(context);
  46. Navigator.pop(context);
  47. },
  48. ),
  49. ],
  50. ),
  51. SliverList(
  52. delegate: SliverChildBuilderDelegate(
  53. (delegateBuildContext, index) {
  54. return Padding(
  55. padding: const EdgeInsets.symmetric(horizontal: 16),
  56. child: Padding(
  57. padding: const EdgeInsets.symmetric(vertical: 20),
  58. child: Column(
  59. mainAxisSize: MainAxisSize.min,
  60. children: [
  61. Column(
  62. children: [
  63. GestureDetector(
  64. onTap: () {
  65. routeToPage(
  66. context,
  67. const PhotoGridSizePickerPage(),
  68. ).then((value) {
  69. setState(() {
  70. _photoGridSize = LocalSettings.instance
  71. .getPhotoGridSize();
  72. });
  73. });
  74. },
  75. child: MenuItemWidget(
  76. captionedTextWidget: CaptionedTextWidget(
  77. title: S.of(context).photoGridSize,
  78. subTitle: _photoGridSize.toString(),
  79. ),
  80. menuItemColor: colorScheme.fillFaint,
  81. trailingWidget: Icon(
  82. Icons.chevron_right_outlined,
  83. color: colorScheme.strokeBase,
  84. ),
  85. singleBorderRadius: 8,
  86. alignCaptionedTextToLeft: true,
  87. isGestureDetectorDisabled: true,
  88. ),
  89. ),
  90. const SizedBox(
  91. height: 24,
  92. ),
  93. MenuItemWidget(
  94. captionedTextWidget: CaptionedTextWidget(
  95. title: S.of(context).showMemories,
  96. ),
  97. menuItemColor: colorScheme.fillFaint,
  98. singleBorderRadius: 8,
  99. alignCaptionedTextToLeft: true,
  100. trailingWidget: ToggleSwitchWidget(
  101. value: () =>
  102. MemoriesService.instance.showMemories,
  103. onChanged: () async {
  104. MemoriesService.instance.setShowMemories(
  105. !MemoriesService.instance.showMemories,
  106. );
  107. },
  108. ),
  109. ),
  110. const SizedBox(
  111. height: 24,
  112. ),
  113. MenuItemWidget(
  114. captionedTextWidget: CaptionedTextWidget(
  115. title: S.of(context).manageDeviceStorage,
  116. ),
  117. menuItemColor: colorScheme.fillFaint,
  118. trailingWidget: Icon(
  119. Icons.chevron_right_outlined,
  120. color: colorScheme.strokeBase,
  121. ),
  122. singleBorderRadius: 8,
  123. alignCaptionedTextToLeft: true,
  124. onTap: () async {
  125. routeToPage(context, const AppStorageViewer());
  126. },
  127. ),
  128. const SizedBox(
  129. height: 24,
  130. ),
  131. MenuItemWidget(
  132. captionedTextWidget: CaptionedTextWidget(
  133. title: S.of(context).maps,
  134. ),
  135. menuItemColor: colorScheme.fillFaint,
  136. singleBorderRadius: 8,
  137. alignCaptionedTextToLeft: true,
  138. trailingWidget: ToggleSwitchWidget(
  139. value: () => UserRemoteFlagService.instance
  140. .getCachedBoolValue(
  141. UserRemoteFlagService.mapEnabled,
  142. ),
  143. onChanged: () async {
  144. final isEnabled = UserRemoteFlagService
  145. .instance
  146. .getCachedBoolValue(
  147. UserRemoteFlagService.mapEnabled,
  148. );
  149. await UserRemoteFlagService.instance
  150. .setBoolValue(
  151. UserRemoteFlagService.mapEnabled,
  152. !isEnabled,
  153. );
  154. },
  155. ),
  156. ),
  157. const SizedBox(
  158. height: 24,
  159. ),
  160. MenuItemWidget(
  161. captionedTextWidget: CaptionedTextWidget(
  162. title: S.of(context).crashReporting,
  163. ),
  164. menuItemColor: colorScheme.fillFaint,
  165. singleBorderRadius: 8,
  166. alignCaptionedTextToLeft: true,
  167. trailingWidget: ToggleSwitchWidget(
  168. value: () => SuperLogging.shouldReportCrashes(),
  169. onChanged: () async {
  170. await SuperLogging.setShouldReportCrashes(
  171. !SuperLogging.shouldReportCrashes(),
  172. );
  173. },
  174. ),
  175. ),
  176. ],
  177. ),
  178. ],
  179. ),
  180. ),
  181. );
  182. },
  183. childCount: 1,
  184. ),
  185. ),
  186. ],
  187. ),
  188. );
  189. }
  190. }