info_section_widget.dart 3.7 KB

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