advanced_settings_screen.dart 8.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200
  1. import "dart:async";
  2. import 'package:flutter/material.dart';
  3. import "package:photos/core/error-reporting/super_logging.dart";
  4. import "package:photos/generated/l10n.dart";
  5. import "package:photos/services/memories_service.dart";
  6. import "package:photos/services/user_remote_flag_service.dart";
  7. import 'package:photos/theme/ente_theme.dart';
  8. import 'package:photos/ui/components/buttons/icon_button_widget.dart';
  9. import 'package:photos/ui/components/captioned_text_widget.dart';
  10. import 'package:photos/ui/components/menu_item_widget/menu_item_widget.dart';
  11. import 'package:photos/ui/components/title_bar_title_widget.dart';
  12. import 'package:photos/ui/components/title_bar_widget.dart';
  13. import "package:photos/ui/components/toggle_switch_widget.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. GestureDetector(
  65. onTap: () {
  66. routeToPage(
  67. context,
  68. const PhotoGridSizePickerPage(),
  69. ).then((value) {
  70. setState(() {
  71. _photoGridSize = LocalSettings.instance
  72. .getPhotoGridSize();
  73. });
  74. });
  75. },
  76. child: MenuItemWidget(
  77. captionedTextWidget: CaptionedTextWidget(
  78. title: S.of(context).photoGridSize,
  79. subTitle: _photoGridSize.toString(),
  80. ),
  81. menuItemColor: colorScheme.fillFaint,
  82. trailingWidget: Icon(
  83. Icons.chevron_right_outlined,
  84. color: colorScheme.strokeBase,
  85. ),
  86. singleBorderRadius: 8,
  87. alignCaptionedTextToLeft: true,
  88. isGestureDetectorDisabled: true,
  89. ),
  90. ),
  91. const SizedBox(
  92. height: 24,
  93. ),
  94. MenuItemWidget(
  95. captionedTextWidget: CaptionedTextWidget(
  96. title: S.of(context).showMemories,
  97. ),
  98. menuItemColor: colorScheme.fillFaint,
  99. singleBorderRadius: 8,
  100. alignCaptionedTextToLeft: true,
  101. trailingWidget: ToggleSwitchWidget(
  102. value: () =>
  103. MemoriesService.instance.showMemories,
  104. onChanged: () async {
  105. unawaited(
  106. MemoriesService.instance.setShowMemories(
  107. !MemoriesService.instance.showMemories,
  108. ),
  109. );
  110. },
  111. ),
  112. ),
  113. const SizedBox(
  114. height: 24,
  115. ),
  116. MenuItemWidget(
  117. captionedTextWidget: CaptionedTextWidget(
  118. title: S.of(context).manageDeviceStorage,
  119. ),
  120. menuItemColor: colorScheme.fillFaint,
  121. trailingWidget: Icon(
  122. Icons.chevron_right_outlined,
  123. color: colorScheme.strokeBase,
  124. ),
  125. singleBorderRadius: 8,
  126. alignCaptionedTextToLeft: true,
  127. onTap: () async {
  128. routeToPage(context, const AppStorageViewer());
  129. },
  130. ),
  131. const SizedBox(
  132. height: 24,
  133. ),
  134. MenuItemWidget(
  135. captionedTextWidget: CaptionedTextWidget(
  136. title: S.of(context).maps,
  137. ),
  138. menuItemColor: colorScheme.fillFaint,
  139. singleBorderRadius: 8,
  140. alignCaptionedTextToLeft: true,
  141. trailingWidget: ToggleSwitchWidget(
  142. value: () => UserRemoteFlagService.instance
  143. .getCachedBoolValue(
  144. UserRemoteFlagService.mapEnabled,
  145. ),
  146. onChanged: () async {
  147. final isEnabled = UserRemoteFlagService
  148. .instance
  149. .getCachedBoolValue(
  150. UserRemoteFlagService.mapEnabled,
  151. );
  152. await UserRemoteFlagService.instance
  153. .setBoolValue(
  154. UserRemoteFlagService.mapEnabled,
  155. !isEnabled,
  156. );
  157. },
  158. ),
  159. ),
  160. const SizedBox(
  161. height: 24,
  162. ),
  163. MenuItemWidget(
  164. captionedTextWidget: CaptionedTextWidget(
  165. title: S.of(context).crashReporting,
  166. ),
  167. menuItemColor: colorScheme.fillFaint,
  168. singleBorderRadius: 8,
  169. alignCaptionedTextToLeft: true,
  170. trailingWidget: ToggleSwitchWidget(
  171. value: () => SuperLogging.shouldReportCrashes(),
  172. onChanged: () async {
  173. await SuperLogging.setShouldReportCrashes(
  174. !SuperLogging.shouldReportCrashes(),
  175. );
  176. },
  177. ),
  178. ),
  179. ],
  180. ),
  181. ],
  182. ),
  183. ),
  184. );
  185. },
  186. childCount: 1,
  187. ),
  188. ),
  189. ],
  190. ),
  191. );
  192. }
  193. }