ente/lib/ui/settings/info_section_widget.dart

115 lines
4 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/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';
import 'package:photos/ui/web_page.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(
header: 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-05-16 19:56:14 +00:00
return WebPage("FAQ", "https://ente.io/faq");
2021-07-28 15:41:45 +00:00
},
),
);
},
2022-05-16 19:56:14 +00:00
child: 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) {
return WebPage("terms", "https://ente.io/terms");
},
),
);
},
child: 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) {
return WebPage("privacy", "https://ente.io/privacy");
},
),
);
},
child: 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 {
launch("https://github.com/ente-io/frame");
},
child:
SettingsTextItem(text: "Source code", icon: Icons.navigate_next),
2021-07-28 15:41:45 +00:00
),
UpdateService.instance.isIndependent()
2022-03-08 07:04:53 +00:00
? Column(
children: [
Divider(height: 4),
GestureDetector(
behavior: HitTestBehavior.translucent,
onTap: () async {
final dialog =
createProgressDialog(context, "checking...");
await dialog.show();
final shouldUpdate =
await UpdateService.instance.shouldUpdate();
await dialog.hide();
if (shouldUpdate) {
showDialog(
context: context,
builder: (BuildContext context) {
return AppUpdateDialog(
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
}
},
child: SettingsTextItem(
text: "Check for updates", icon: Icons.navigate_next,),
2022-03-08 07:04:53 +00:00
),
],
2021-07-28 15:41:45 +00:00
)
2022-03-08 07:04:53 +00:00
: Container(),
2021-07-28 15:41:45 +00:00
],
);
}
}