2021-04-19 09:35:22 +00:00
|
|
|
import 'package:flutter/material.dart';
|
2021-05-22 18:29:09 +00:00
|
|
|
import 'package:photos/services/update_service.dart';
|
2022-10-21 13:37:57 +00:00
|
|
|
import 'package:photos/theme/ente_theme.dart';
|
2022-07-01 14:18:05 +00:00
|
|
|
import 'package:photos/ui/common/web_page.dart';
|
2022-10-04 04:42:07 +00:00
|
|
|
import 'package:photos/ui/components/captioned_text_widget.dart';
|
2022-10-05 11:48:56 +00:00
|
|
|
import 'package:photos/ui/components/expandable_menu_item_widget.dart';
|
2022-10-04 04:42:07 +00:00
|
|
|
import 'package:photos/ui/components/menu_item_widget.dart';
|
2022-07-01 14:18:05 +00:00
|
|
|
import 'package:photos/ui/settings/app_update_dialog.dart';
|
2022-03-08 19:43:51 +00:00
|
|
|
import 'package:photos/ui/settings/common_settings.dart';
|
2021-05-22 18:29:09 +00:00
|
|
|
import 'package:photos/utils/dialog_util.dart';
|
|
|
|
import 'package:photos/utils/toast_util.dart';
|
2021-04-19 09:35:22 +00:00
|
|
|
import 'package:url_launcher/url_launcher.dart';
|
|
|
|
|
2022-10-06 03:52:05 +00:00
|
|
|
class AboutSectionWidget extends StatelessWidget {
|
2022-12-27 18:01:23 +00:00
|
|
|
const AboutSectionWidget({Key? key}) : super(key: key);
|
2021-04-19 09:35:22 +00:00
|
|
|
|
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
2022-10-05 11:48:56 +00:00
|
|
|
return ExpandableMenuItemWidget(
|
|
|
|
title: "About",
|
|
|
|
selectionOptionsWidget: _getSectionOptions(context),
|
|
|
|
leadingIcon: Icons.info_outline,
|
2022-03-08 19:43:51 +00:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
Widget _getSectionOptions(BuildContext context) {
|
2021-07-28 15:41:45 +00:00
|
|
|
return Column(
|
|
|
|
children: [
|
2022-10-05 07:52:48 +00:00
|
|
|
sectionOptionSpacing,
|
2022-10-05 06:17:55 +00:00
|
|
|
MenuItemWidget(
|
|
|
|
captionedTextWidget: const CaptionedTextWidget(
|
2022-12-07 05:44:15 +00:00
|
|
|
title: "We are open source!",
|
2022-10-05 06:17:55 +00:00
|
|
|
),
|
2022-10-21 13:37:57 +00:00
|
|
|
pressedColor: getEnteColorScheme(context).fillFaint,
|
2022-10-05 06:17:55 +00:00
|
|
|
trailingIcon: Icons.chevron_right_outlined,
|
|
|
|
trailingIconIsMuted: true,
|
2021-07-28 15:41:45 +00:00
|
|
|
onTap: () async {
|
2022-12-15 13:50:20 +00:00
|
|
|
launchUrl(Uri.parse("https://github.com/ente-io/photos-app"));
|
2021-07-28 15:41:45 +00:00
|
|
|
},
|
|
|
|
),
|
2022-10-05 07:52:48 +00:00
|
|
|
sectionOptionSpacing,
|
2022-12-07 05:44:15 +00:00
|
|
|
const AboutMenuItemWidget(
|
|
|
|
title: "Privacy",
|
|
|
|
url: "https://ente.io/privacy",
|
|
|
|
),
|
|
|
|
sectionOptionSpacing,
|
|
|
|
const AboutMenuItemWidget(
|
|
|
|
title: "Terms",
|
|
|
|
url: "https://ente.io/terms",
|
|
|
|
),
|
|
|
|
sectionOptionSpacing,
|
2021-07-28 15:41:45 +00:00
|
|
|
UpdateService.instance.isIndependent()
|
2022-03-08 07:04:53 +00:00
|
|
|
? Column(
|
|
|
|
children: [
|
2022-10-05 06:17:55 +00:00
|
|
|
MenuItemWidget(
|
|
|
|
captionedTextWidget: const CaptionedTextWidget(
|
2022-10-05 13:57:32 +00:00
|
|
|
title: "Check for updates",
|
2022-10-05 06:17:55 +00:00
|
|
|
),
|
2022-10-21 13:37:57 +00:00
|
|
|
pressedColor: getEnteColorScheme(context).fillFaint,
|
2022-10-05 06:17:55 +00:00
|
|
|
trailingIcon: Icons.chevron_right_outlined,
|
|
|
|
trailingIconIsMuted: true,
|
2022-03-08 07:04:53 +00:00
|
|
|
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-12-26 05:14:36 +00:00
|
|
|
showShortToast(
|
|
|
|
context, "You are on the latest version");
|
2022-03-08 07:04:53 +00:00
|
|
|
}
|
|
|
|
},
|
|
|
|
),
|
2022-10-05 07:52:48 +00:00
|
|
|
sectionOptionSpacing,
|
2022-03-08 07:04:53 +00:00
|
|
|
],
|
2021-07-28 15:41:45 +00:00
|
|
|
)
|
2022-06-22 07:21:19 +00:00
|
|
|
: const SizedBox.shrink(),
|
2021-07-28 15:41:45 +00:00
|
|
|
],
|
2021-04-19 09:35:22 +00:00
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
2022-10-05 06:17:55 +00:00
|
|
|
|
|
|
|
class AboutMenuItemWidget extends StatelessWidget {
|
|
|
|
final String title;
|
|
|
|
final String url;
|
2022-12-27 18:01:23 +00:00
|
|
|
final String? webPageTitle;
|
2022-10-05 06:17:55 +00:00
|
|
|
const AboutMenuItemWidget({
|
2022-12-27 18:01:23 +00:00
|
|
|
required this.title,
|
|
|
|
required this.url,
|
2022-10-07 04:59:03 +00:00
|
|
|
this.webPageTitle,
|
2022-12-27 18:01:23 +00:00
|
|
|
Key? key,
|
2022-10-05 06:17:55 +00:00
|
|
|
}) : super(key: key);
|
|
|
|
|
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
return MenuItemWidget(
|
|
|
|
captionedTextWidget: CaptionedTextWidget(
|
2022-10-05 13:57:32 +00:00
|
|
|
title: title,
|
2022-10-05 06:17:55 +00:00
|
|
|
),
|
2022-10-21 13:37:57 +00:00
|
|
|
pressedColor: getEnteColorScheme(context).fillFaint,
|
2022-10-05 06:17:55 +00:00
|
|
|
trailingIcon: Icons.chevron_right_outlined,
|
|
|
|
trailingIconIsMuted: true,
|
2022-11-06 10:16:14 +00:00
|
|
|
onTap: () {
|
2022-10-05 06:17:55 +00:00
|
|
|
Navigator.of(context).push(
|
|
|
|
MaterialPageRoute(
|
|
|
|
builder: (BuildContext context) {
|
2022-10-07 04:59:03 +00:00
|
|
|
return WebPage(webPageTitle ?? title, url);
|
2022-10-05 06:17:55 +00:00
|
|
|
},
|
|
|
|
),
|
|
|
|
);
|
|
|
|
},
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|