advanced_settings_screen.dart 9.7 KB

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