info_section_widget.dart 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152
  1. // @dart=2.9
  2. import 'package:expandable/expandable.dart';
  3. import 'package:flutter/material.dart';
  4. import 'package:photos/ente_theme_data.dart';
  5. import 'package:photos/services/update_service.dart';
  6. import 'package:photos/ui/common/web_page.dart';
  7. import 'package:photos/ui/components/captioned_text_widget.dart';
  8. import 'package:photos/ui/components/menu_item_widget.dart';
  9. import 'package:photos/ui/settings/app_update_dialog.dart';
  10. import 'package:photos/ui/settings/common_settings.dart';
  11. import 'package:photos/ui/settings/settings_text_item.dart';
  12. import 'package:photos/utils/dialog_util.dart';
  13. import 'package:photos/utils/toast_util.dart';
  14. import 'package:url_launcher/url_launcher.dart';
  15. class InfoSectionWidget extends StatefulWidget {
  16. const InfoSectionWidget({Key key}) : super(key: key);
  17. @override
  18. State<InfoSectionWidget> createState() => _InfoSectionWidgetState();
  19. }
  20. class _InfoSectionWidgetState extends State<InfoSectionWidget> {
  21. final expandableController = ExpandableController(initialExpanded: false);
  22. @override
  23. void dispose() {
  24. expandableController.dispose();
  25. super.dispose();
  26. }
  27. @override
  28. Widget build(BuildContext context) {
  29. return ExpandablePanel(
  30. header: MenuItemWidget(
  31. captionedTextWidget: const CaptionedTextWidget(
  32. text: "About",
  33. ),
  34. isHeaderOfExpansion: true,
  35. leadingIcon: Icons.info_outlined,
  36. trailingIcon: Icons.expand_more,
  37. menuItemColor:
  38. Theme.of(context).colorScheme.enteTheme.colorScheme.fillFaint,
  39. expandableController: expandableController,
  40. ),
  41. collapsed: const SizedBox.shrink(),
  42. expanded: _getSectionOptions(context),
  43. theme: getExpandableTheme(context),
  44. controller: expandableController,
  45. );
  46. }
  47. Widget _getSectionOptions(BuildContext context) {
  48. return Column(
  49. children: [
  50. sectionOptionDivider,
  51. GestureDetector(
  52. behavior: HitTestBehavior.translucent,
  53. onTap: () async {
  54. Navigator.of(context).push(
  55. MaterialPageRoute(
  56. builder: (BuildContext context) {
  57. return const WebPage("FAQ", "https://ente.io/faq");
  58. },
  59. ),
  60. );
  61. },
  62. child: const SettingsTextItem(text: "FAQ", icon: Icons.navigate_next),
  63. ),
  64. sectionOptionDivider,
  65. GestureDetector(
  66. behavior: HitTestBehavior.translucent,
  67. onTap: () {
  68. Navigator.of(context).push(
  69. MaterialPageRoute(
  70. builder: (BuildContext context) {
  71. return const WebPage("terms", "https://ente.io/terms");
  72. },
  73. ),
  74. );
  75. },
  76. child:
  77. const SettingsTextItem(text: "Terms", icon: Icons.navigate_next),
  78. ),
  79. sectionOptionDivider,
  80. GestureDetector(
  81. behavior: HitTestBehavior.translucent,
  82. onTap: () {
  83. Navigator.of(context).push(
  84. MaterialPageRoute(
  85. builder: (BuildContext context) {
  86. return const WebPage("privacy", "https://ente.io/privacy");
  87. },
  88. ),
  89. );
  90. },
  91. child: const SettingsTextItem(
  92. text: "Privacy",
  93. icon: Icons.navigate_next,
  94. ),
  95. ),
  96. sectionOptionDivider,
  97. GestureDetector(
  98. behavior: HitTestBehavior.translucent,
  99. onTap: () async {
  100. launchUrl(Uri.parse("https://github.com/ente-io/frame"));
  101. },
  102. child: const SettingsTextItem(
  103. text: "Source code",
  104. icon: Icons.navigate_next,
  105. ),
  106. ),
  107. sectionOptionDivider,
  108. UpdateService.instance.isIndependent()
  109. ? Column(
  110. children: [
  111. GestureDetector(
  112. behavior: HitTestBehavior.translucent,
  113. onTap: () async {
  114. final dialog =
  115. createProgressDialog(context, "Checking...");
  116. await dialog.show();
  117. final shouldUpdate =
  118. await UpdateService.instance.shouldUpdate();
  119. await dialog.hide();
  120. if (shouldUpdate) {
  121. showDialog(
  122. context: context,
  123. builder: (BuildContext context) {
  124. return AppUpdateDialog(
  125. UpdateService.instance.getLatestVersionInfo(),
  126. );
  127. },
  128. barrierColor: Colors.black.withOpacity(0.85),
  129. );
  130. } else {
  131. showToast(context, "You are on the latest version");
  132. }
  133. },
  134. child: const SettingsTextItem(
  135. text: "Check for updates",
  136. icon: Icons.navigate_next,
  137. ),
  138. ),
  139. ],
  140. )
  141. : const SizedBox.shrink(),
  142. ],
  143. );
  144. }
  145. }