advanced_settings_screen.dart 7.5 KB

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