ente/mobile/lib/ui/settings/about_section_widget.dart

132 lines
4.5 KiB
Dart
Raw Normal View History

import 'package:flutter/material.dart';
import "package:photos/generated/l10n.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';
import 'package:photos/ui/common/web_page.dart';
import 'package:photos/ui/components/captioned_text_widget.dart';
import 'package:photos/ui/components/expandable_menu_item_widget.dart';
2023-01-31 12:21:57 +00:00
import 'package:photos/ui/components/menu_item_widget/menu_item_widget.dart';
import 'package:photos/ui/settings/app_update_dialog.dart';
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';
import 'package:url_launcher/url_launcher.dart';
class AboutSectionWidget extends StatelessWidget {
2022-12-27 18:01:23 +00:00
const AboutSectionWidget({Key? key}) : super(key: key);
@override
Widget build(BuildContext context) {
return ExpandableMenuItemWidget(
title: S.of(context).about,
selectionOptionsWidget: _getSectionOptions(context),
leadingIcon: Icons.info_outline,
);
}
Widget _getSectionOptions(BuildContext context) {
2021-07-28 15:41:45 +00:00
return Column(
children: [
sectionOptionSpacing,
MenuItemWidget(
captionedTextWidget: CaptionedTextWidget(
title: S.of(context).weAreOpenSource,
),
2022-10-21 13:37:57 +00:00
pressedColor: getEnteColorScheme(context).fillFaint,
trailingIcon: Icons.chevron_right_outlined,
trailingIconIsMuted: true,
2021-07-28 15:41:45 +00:00
onTap: () async {
2023-12-21 07:34:06 +00:00
// ignore: unawaited_futures
launchUrl(Uri.parse("https://github.com/ente-io/ente"));
2021-07-28 15:41:45 +00:00
},
),
sectionOptionSpacing,
AboutMenuItemWidget(
title: S.of(context).privacy,
2022-12-07 05:44:15 +00:00
url: "https://ente.io/privacy",
),
sectionOptionSpacing,
AboutMenuItemWidget(
title: S.of(context).termsOfServicesTitle,
2022-12-07 05:44:15 +00:00
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: [
MenuItemWidget(
captionedTextWidget: CaptionedTextWidget(
title: S.of(context).checkForUpdates,
),
2022-10-21 13:37:57 +00:00
pressedColor: getEnteColorScheme(context).fillFaint,
trailingIcon: Icons.chevron_right_outlined,
trailingIconIsMuted: true,
2022-03-08 07:04:53 +00:00
onTap: () async {
final dialog =
createProgressDialog(context, S.of(context).checking);
2022-03-08 07:04:53 +00:00
await dialog.show();
final shouldUpdate =
await UpdateService.instance.shouldUpdate();
await dialog.hide();
if (shouldUpdate) {
2023-12-21 07:34:06 +00:00
// ignore: unawaited_futures
2022-03-08 07:04:53 +00:00
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 {
showShortToast(
2022-12-30 03:29:48 +00:00
context,
S.of(context).youAreOnTheLatestVersion,
2022-12-30 03:29:48 +00:00
);
2022-03-08 07:04:53 +00:00
}
},
),
sectionOptionSpacing,
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
],
);
}
}
class AboutMenuItemWidget extends StatelessWidget {
final String title;
final String url;
2022-12-27 18:01:23 +00:00
final String? webPageTitle;
const AboutMenuItemWidget({
2022-12-27 18:01:23 +00:00
required this.title,
required this.url,
this.webPageTitle,
2022-12-27 18:01:23 +00:00
Key? key,
}) : super(key: key);
@override
Widget build(BuildContext context) {
return MenuItemWidget(
captionedTextWidget: CaptionedTextWidget(
2022-10-05 13:57:32 +00:00
title: title,
),
2022-10-21 13:37:57 +00:00
pressedColor: getEnteColorScheme(context).fillFaint,
trailingIcon: Icons.chevron_right_outlined,
trailingIconIsMuted: true,
onTap: () async {
2023-12-21 07:34:06 +00:00
// ignore: unawaited_futures
Navigator.of(context).push(
MaterialPageRoute(
builder: (BuildContext context) {
return WebPage(webPageTitle ?? title, url);
},
),
);
},
);
}
}