mirror of
https://github.com/ente-io/ente.git
synced 2025-05-29 05:51:19 +00:00
113 lines
3.2 KiB
Dart
113 lines
3.2 KiB
Dart
import "dart:io";
|
|
|
|
import 'package:flutter/material.dart';
|
|
import "package:photos/generated/l10n.dart";
|
|
import 'package:photos/services/update_service.dart';
|
|
import 'package:photos/theme/ente_theme.dart';
|
|
import 'package:photos/ui/components/captioned_text_widget.dart';
|
|
import 'package:photos/ui/components/expandable_menu_item_widget.dart';
|
|
import 'package:photos/ui/components/menu_item_widget/menu_item_widget.dart';
|
|
import 'package:photos/ui/settings/common_settings.dart';
|
|
import 'package:url_launcher/url_launcher_string.dart';
|
|
|
|
class SocialSectionWidget extends StatelessWidget {
|
|
const SocialSectionWidget({Key? key}) : super(key: key);
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return ExpandableMenuItemWidget(
|
|
title: S.of(context).social,
|
|
selectionOptionsWidget: _getSectionOptions(context),
|
|
leadingIcon: Icons.interests_outlined,
|
|
);
|
|
}
|
|
|
|
Widget _getSectionOptions(BuildContext context) {
|
|
final List<Widget> options = [];
|
|
final result = UpdateService.instance.getRateDetails();
|
|
final String ratePlace = result.item1;
|
|
final String rateUrl = result.item2;
|
|
options.addAll(
|
|
[
|
|
sectionOptionSpacing,
|
|
SocialsMenuItemWidget(S.of(context).rateUsOnStore(ratePlace), rateUrl),
|
|
sectionOptionSpacing,
|
|
],
|
|
);
|
|
options.addAll(
|
|
[
|
|
SocialsMenuItemWidget(
|
|
S.of(context).blog,
|
|
"https://ente.io/blog",
|
|
launchInExternalApp: !Platform.isAndroid,
|
|
),
|
|
sectionOptionSpacing,
|
|
SocialsMenuItemWidget(
|
|
S.of(context).merchandise,
|
|
"https://shop.ente.io",
|
|
launchInExternalApp: !Platform.isAndroid,
|
|
),
|
|
sectionOptionSpacing,
|
|
SocialsMenuItemWidget(
|
|
S.of(context).twitter,
|
|
"https://twitter.com/enteio",
|
|
),
|
|
sectionOptionSpacing,
|
|
SocialsMenuItemWidget(
|
|
S.of(context).mastodon,
|
|
"https://fosstodon.org/@ente",
|
|
),
|
|
sectionOptionSpacing,
|
|
SocialsMenuItemWidget(
|
|
S.of(context).matrix,
|
|
"https://ente.io/matrix/",
|
|
),
|
|
sectionOptionSpacing,
|
|
SocialsMenuItemWidget(S.of(context).discord, "https://ente.io/discord"),
|
|
sectionOptionSpacing,
|
|
SocialsMenuItemWidget(
|
|
S.of(context).reddit,
|
|
"https://reddit.com/r/enteio",
|
|
),
|
|
sectionOptionSpacing,
|
|
],
|
|
);
|
|
|
|
return Column(children: options);
|
|
}
|
|
}
|
|
|
|
class SocialsMenuItemWidget extends StatelessWidget {
|
|
final String text;
|
|
final String url;
|
|
final bool launchInExternalApp;
|
|
|
|
const SocialsMenuItemWidget(
|
|
this.text,
|
|
this.url, {
|
|
Key? key,
|
|
this.launchInExternalApp = true,
|
|
}) : super(key: key);
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return MenuItemWidget(
|
|
captionedTextWidget: CaptionedTextWidget(
|
|
title: text,
|
|
),
|
|
pressedColor: getEnteColorScheme(context).fillFaint,
|
|
trailingIcon: Icons.chevron_right_outlined,
|
|
trailingIconIsMuted: true,
|
|
onTap: () async {
|
|
// ignore: unawaited_futures
|
|
launchUrlString(
|
|
url,
|
|
mode: launchInExternalApp
|
|
? LaunchMode.externalApplication
|
|
: LaunchMode.platformDefault,
|
|
);
|
|
},
|
|
);
|
|
}
|
|
}
|