info_section_widget.dart 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. import 'package:expandable/expandable.dart';
  2. import 'package:flutter/material.dart';
  3. import 'package:photos/services/update_service.dart';
  4. import 'package:photos/ui/common/web_page.dart';
  5. import 'package:photos/ui/settings/app_update_dialog.dart';
  6. import 'package:photos/ui/settings/common_settings.dart';
  7. import 'package:photos/ui/settings/settings_section_title.dart';
  8. import 'package:photos/ui/settings/settings_text_item.dart';
  9. import 'package:photos/utils/dialog_util.dart';
  10. import 'package:photos/utils/toast_util.dart';
  11. import 'package:url_launcher/url_launcher.dart';
  12. class InfoSectionWidget extends StatelessWidget {
  13. const InfoSectionWidget({Key key}) : super(key: key);
  14. @override
  15. Widget build(BuildContext context) {
  16. return ExpandablePanel(
  17. header: SettingsSectionTitle("About"),
  18. collapsed: Container(),
  19. expanded: _getSectionOptions(context),
  20. theme: getExpandableTheme(context),
  21. );
  22. }
  23. Widget _getSectionOptions(BuildContext context) {
  24. return Column(
  25. children: [
  26. GestureDetector(
  27. behavior: HitTestBehavior.translucent,
  28. onTap: () async {
  29. Navigator.of(context).push(
  30. MaterialPageRoute(
  31. builder: (BuildContext context) {
  32. return WebPage("FAQ", "https://ente.io/faq");
  33. },
  34. ),
  35. );
  36. },
  37. child: SettingsTextItem(text: "FAQ", icon: Icons.navigate_next),
  38. ),
  39. sectionOptionDivider,
  40. GestureDetector(
  41. behavior: HitTestBehavior.translucent,
  42. onTap: () {
  43. Navigator.of(context).push(
  44. MaterialPageRoute(
  45. builder: (BuildContext context) {
  46. return WebPage("terms", "https://ente.io/terms");
  47. },
  48. ),
  49. );
  50. },
  51. child: SettingsTextItem(text: "Terms", icon: Icons.navigate_next),
  52. ),
  53. sectionOptionDivider,
  54. GestureDetector(
  55. behavior: HitTestBehavior.translucent,
  56. onTap: () {
  57. Navigator.of(context).push(
  58. MaterialPageRoute(
  59. builder: (BuildContext context) {
  60. return WebPage("privacy", "https://ente.io/privacy");
  61. },
  62. ),
  63. );
  64. },
  65. child: SettingsTextItem(text: "Privacy", icon: Icons.navigate_next),
  66. ),
  67. sectionOptionDivider,
  68. GestureDetector(
  69. behavior: HitTestBehavior.translucent,
  70. onTap: () async {
  71. launchUrl(Uri.parse("https://github.com/ente-io/frame"));
  72. },
  73. child:
  74. SettingsTextItem(text: "Source code", icon: Icons.navigate_next),
  75. ),
  76. sectionOptionDivider,
  77. UpdateService.instance.isIndependent()
  78. ? Column(
  79. children: [
  80. GestureDetector(
  81. behavior: HitTestBehavior.translucent,
  82. onTap: () async {
  83. final dialog =
  84. createProgressDialog(context, "Checking...");
  85. await dialog.show();
  86. final shouldUpdate =
  87. await UpdateService.instance.shouldUpdate();
  88. await dialog.hide();
  89. if (shouldUpdate) {
  90. showDialog(
  91. context: context,
  92. builder: (BuildContext context) {
  93. return AppUpdateDialog(
  94. UpdateService.instance.getLatestVersionInfo(),
  95. );
  96. },
  97. barrierColor: Colors.black.withOpacity(0.85),
  98. );
  99. } else {
  100. showToast(context, "You are on the latest version");
  101. }
  102. },
  103. child: SettingsTextItem(
  104. text: "Check for updates",
  105. icon: Icons.navigate_next,
  106. ),
  107. ),
  108. ],
  109. )
  110. : const SizedBox.shrink(),
  111. ],
  112. );
  113. }
  114. }