ente/lib/ui/settings/info_section_widget.dart

124 lines
4.2 KiB
Dart
Raw Normal View History

import 'package:expandable/expandable.dart';
import 'package:flutter/material.dart';
2021-05-22 18:29:09 +00:00
import 'package:photos/services/update_service.dart';
import 'package:photos/ui/common/web_page.dart';
import 'package:photos/ui/settings/app_update_dialog.dart';
import 'package:photos/ui/settings/common_settings.dart';
import 'package:photos/ui/settings/settings_section_title.dart';
import 'package:photos/ui/settings/settings_text_item.dart';
2021-05-22 18:29:09 +00:00
import 'package:photos/utils/dialog_util.dart';
import 'package:photos/utils/toast_util.dart';
import 'package:url_launcher/url_launcher.dart';
class InfoSectionWidget extends StatelessWidget {
const InfoSectionWidget({Key key}) : super(key: key);
@override
Widget build(BuildContext context) {
return ExpandablePanel(
2022-07-04 06:02:17 +00:00
header: const SettingsSectionTitle("About"),
collapsed: Container(),
expanded: _getSectionOptions(context),
theme: getExpandableTheme(context),
);
}
Widget _getSectionOptions(BuildContext context) {
2021-07-28 15:41:45 +00:00
return Column(
children: [
GestureDetector(
behavior: HitTestBehavior.translucent,
onTap: () async {
Navigator.of(context).push(
MaterialPageRoute(
builder: (BuildContext context) {
2022-07-04 06:02:17 +00:00
return const WebPage("FAQ", "https://ente.io/faq");
2021-07-28 15:41:45 +00:00
},
),
);
},
2022-07-04 06:02:17 +00:00
child: const SettingsTextItem(text: "FAQ", icon: Icons.navigate_next),
2021-07-28 15:41:45 +00:00
),
sectionOptionDivider,
2021-07-28 15:41:45 +00:00
GestureDetector(
behavior: HitTestBehavior.translucent,
onTap: () {
Navigator.of(context).push(
MaterialPageRoute(
builder: (BuildContext context) {
2022-07-04 06:02:17 +00:00
return const WebPage("terms", "https://ente.io/terms");
2021-07-28 15:41:45 +00:00
},
),
);
},
2022-07-04 06:02:17 +00:00
child:
const SettingsTextItem(text: "Terms", icon: Icons.navigate_next),
2021-07-28 15:41:45 +00:00
),
sectionOptionDivider,
2021-07-28 15:41:45 +00:00
GestureDetector(
behavior: HitTestBehavior.translucent,
onTap: () {
Navigator.of(context).push(
MaterialPageRoute(
builder: (BuildContext context) {
2022-07-04 06:02:17 +00:00
return const WebPage("privacy", "https://ente.io/privacy");
2021-07-28 15:41:45 +00:00
},
),
);
},
2022-07-04 06:02:17 +00:00
child: const SettingsTextItem(
text: "Privacy",
icon: Icons.navigate_next,
),
2021-07-28 15:41:45 +00:00
),
sectionOptionDivider,
2021-07-28 15:41:45 +00:00
GestureDetector(
behavior: HitTestBehavior.translucent,
onTap: () async {
2022-06-22 07:40:09 +00:00
launchUrl(Uri.parse("https://github.com/ente-io/frame"));
2021-07-28 15:41:45 +00:00
},
2022-07-04 06:02:17 +00:00
child: const SettingsTextItem(
text: "Source code",
icon: Icons.navigate_next,
),
2021-07-28 15:41:45 +00:00
),
sectionOptionDivider,
2021-07-28 15:41:45 +00:00
UpdateService.instance.isIndependent()
2022-03-08 07:04:53 +00:00
? Column(
children: [
GestureDetector(
behavior: HitTestBehavior.translucent,
onTap: () async {
final dialog =
2022-06-18 12:23:51 +00:00
createProgressDialog(context, "Checking...");
2022-03-08 07:04:53 +00:00
await dialog.show();
final shouldUpdate =
await UpdateService.instance.shouldUpdate();
await dialog.hide();
if (shouldUpdate) {
showDialog(
context: context,
builder: (BuildContext context) {
return AppUpdateDialog(
2022-06-11 08:23:52 +00:00
UpdateService.instance.getLatestVersionInfo(),
);
2022-03-08 07:04:53 +00:00
},
barrierColor: Colors.black.withOpacity(0.85),
);
} else {
2022-06-10 14:29:56 +00:00
showToast(context, "You are on the latest version");
2022-03-08 07:04:53 +00:00
}
},
2022-07-04 06:02:17 +00:00
child: const SettingsTextItem(
2022-06-11 08:23:52 +00:00
text: "Check for updates",
icon: Icons.navigate_next,
),
2022-03-08 07:04:53 +00:00
),
],
2021-07-28 15:41:45 +00:00
)
: const SizedBox.shrink(),
2021-07-28 15:41:45 +00:00
],
);
}
}