2022-06-09 07:04:03 +00:00
|
|
|
import 'dart:io';
|
|
|
|
|
2020-09-09 14:04:11 +00:00
|
|
|
import 'package:flutter/foundation.dart';
|
2020-08-28 23:50:34 +00:00
|
|
|
import 'package:flutter/material.dart';
|
2023-02-22 12:53:06 +00:00
|
|
|
import "package:flutter_animate/flutter_animate.dart";
|
2021-07-27 14:51:45 +00:00
|
|
|
import 'package:photos/core/configuration.dart';
|
2022-12-13 12:28:44 +00:00
|
|
|
import 'package:photos/core/event_bus.dart';
|
|
|
|
import 'package:photos/events/opened_settings_event.dart';
|
2023-04-07 04:57:54 +00:00
|
|
|
import "package:photos/generated/l10n.dart";
|
2023-01-09 06:05:27 +00:00
|
|
|
import 'package:photos/services/feature_flag_service.dart';
|
2023-02-17 08:49:11 +00:00
|
|
|
import "package:photos/services/storage_bonus_service.dart";
|
2022-10-07 12:29:53 +00:00
|
|
|
import 'package:photos/theme/colors.dart';
|
2022-10-07 12:43:21 +00:00
|
|
|
import 'package:photos/theme/ente_theme.dart';
|
2023-02-17 09:18:38 +00:00
|
|
|
import "package:photos/ui/components/notification_widget.dart";
|
2023-02-17 08:49:11 +00:00
|
|
|
import "package:photos/ui/growth/referral_screen.dart";
|
2022-10-05 06:19:36 +00:00
|
|
|
import 'package:photos/ui/settings/about_section_widget.dart';
|
2021-04-19 09:35:22 +00:00
|
|
|
import 'package:photos/ui/settings/account_section_widget.dart';
|
2021-10-08 11:40:36 +00:00
|
|
|
import 'package:photos/ui/settings/app_version_widget.dart';
|
2023-06-06 09:57:17 +00:00
|
|
|
import 'package:photos/ui/settings/backup/backup_section_widget.dart';
|
2021-04-19 09:35:22 +00:00
|
|
|
import 'package:photos/ui/settings/debug_section_widget.dart';
|
2022-12-06 17:47:37 +00:00
|
|
|
import 'package:photos/ui/settings/general_section_widget.dart';
|
2022-12-31 18:15:33 +00:00
|
|
|
import 'package:photos/ui/settings/inherited_settings_state.dart';
|
2021-04-19 09:35:22 +00:00
|
|
|
import 'package:photos/ui/settings/security_section_widget.dart';
|
2022-10-10 08:59:54 +00:00
|
|
|
import 'package:photos/ui/settings/settings_title_bar_widget.dart';
|
2022-03-08 07:04:53 +00:00
|
|
|
import 'package:photos/ui/settings/social_section_widget.dart';
|
2022-11-01 10:19:01 +00:00
|
|
|
import 'package:photos/ui/settings/storage_card_widget.dart';
|
2021-04-19 09:35:22 +00:00
|
|
|
import 'package:photos/ui/settings/support_section_widget.dart';
|
2022-05-30 12:33:12 +00:00
|
|
|
import 'package:photos/ui/settings/theme_switch_widget.dart';
|
2023-02-26 05:58:30 +00:00
|
|
|
import "package:photos/ui/sharing/verify_identity_dialog.dart";
|
2023-11-17 10:07:37 +00:00
|
|
|
import "package:photos/utils/black_friday_util.dart";
|
2023-02-17 08:49:11 +00:00
|
|
|
import "package:photos/utils/navigation_util.dart";
|
2023-11-15 12:45:38 +00:00
|
|
|
import "package:url_launcher/url_launcher_string.dart";
|
2020-08-28 23:50:34 +00:00
|
|
|
|
|
|
|
class SettingsPage extends StatelessWidget {
|
2022-12-30 12:10:17 +00:00
|
|
|
final ValueNotifier<String?> emailNotifier;
|
2023-02-17 08:49:11 +00:00
|
|
|
|
2022-12-30 12:10:17 +00:00
|
|
|
const SettingsPage({Key? key, required this.emailNotifier}) : super(key: key);
|
2020-08-28 23:50:34 +00:00
|
|
|
|
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
2022-12-13 12:28:44 +00:00
|
|
|
Bus.instance.fire(OpenedSettingsEvent());
|
2022-10-07 12:43:21 +00:00
|
|
|
final enteColorScheme = getEnteColorScheme(context);
|
2020-08-28 23:50:34 +00:00
|
|
|
return Scaffold(
|
2022-10-05 13:03:33 +00:00
|
|
|
body: Container(
|
2022-12-17 05:18:33 +00:00
|
|
|
color: enteColorScheme.backdropMuted,
|
2022-12-31 18:15:33 +00:00
|
|
|
child: SettingsStateContainer(
|
2022-12-31 14:21:12 +00:00
|
|
|
child: _getBody(context, enteColorScheme),
|
|
|
|
),
|
2022-10-07 04:56:29 +00:00
|
|
|
),
|
2020-08-28 23:50:34 +00:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2022-10-07 12:29:53 +00:00
|
|
|
Widget _getBody(BuildContext context, EnteColorScheme colorScheme) {
|
2022-10-14 15:03:55 +00:00
|
|
|
final hasLoggedIn = Configuration.instance.isLoggedIn();
|
2022-10-07 12:43:21 +00:00
|
|
|
final enteTextTheme = getEnteTextTheme(context);
|
2021-03-21 09:58:55 +00:00
|
|
|
final List<Widget> contents = [];
|
2022-06-09 09:50:57 +00:00
|
|
|
contents.add(
|
2023-02-26 05:26:42 +00:00
|
|
|
GestureDetector(
|
2023-02-25 11:12:35 +00:00
|
|
|
onDoubleTap: () {
|
2023-02-26 05:58:30 +00:00
|
|
|
_showVerifyIdentityDialog(context);
|
2023-02-25 11:12:35 +00:00
|
|
|
},
|
|
|
|
onLongPress: () {
|
2023-02-26 05:58:30 +00:00
|
|
|
_showVerifyIdentityDialog(context);
|
2023-02-25 11:12:35 +00:00
|
|
|
},
|
2023-08-02 11:24:21 +00:00
|
|
|
child: Padding(
|
2023-02-25 11:12:35 +00:00
|
|
|
padding: const EdgeInsets.symmetric(horizontal: 8),
|
|
|
|
child: Align(
|
|
|
|
alignment: Alignment.centerLeft,
|
|
|
|
child: AnimatedBuilder(
|
|
|
|
// [AnimatedBuilder] accepts any [Listenable] subtype.
|
|
|
|
animation: emailNotifier,
|
|
|
|
builder: (BuildContext context, Widget? child) {
|
|
|
|
return Text(
|
|
|
|
emailNotifier.value!,
|
|
|
|
style: enteTextTheme.body.copyWith(
|
|
|
|
color: colorScheme.textMuted,
|
|
|
|
overflow: TextOverflow.ellipsis,
|
|
|
|
),
|
|
|
|
);
|
|
|
|
},
|
|
|
|
),
|
2022-07-14 07:41:03 +00:00
|
|
|
),
|
2022-06-09 09:50:57 +00:00
|
|
|
),
|
|
|
|
),
|
|
|
|
);
|
2022-10-05 12:37:43 +00:00
|
|
|
const sectionSpacing = SizedBox(height: 8);
|
|
|
|
contents.add(const SizedBox(height: 8));
|
2021-04-05 13:39:54 +00:00
|
|
|
if (hasLoggedIn) {
|
2023-11-15 13:09:13 +00:00
|
|
|
final shouldShowBFBanner = shouldShowBfBanner();
|
|
|
|
final showStorageBonusBanner =
|
|
|
|
StorageBonusService.instance.shouldShowStorageBonus();
|
2021-03-21 09:58:55 +00:00
|
|
|
contents.addAll([
|
2022-11-01 10:19:01 +00:00
|
|
|
const StorageCardWidget(),
|
2023-11-15 13:09:13 +00:00
|
|
|
(shouldShowBFBanner || showStorageBonusBanner)
|
2023-02-22 12:53:06 +00:00
|
|
|
? RepaintBoundary(
|
|
|
|
child: Padding(
|
|
|
|
padding: const EdgeInsets.symmetric(vertical: 8.0),
|
2023-11-15 13:09:13 +00:00
|
|
|
child: shouldShowBFBanner
|
2023-11-15 12:45:38 +00:00
|
|
|
? NotificationWidget(
|
|
|
|
isBlackFriday: true,
|
|
|
|
startIcon: Icons.celebration,
|
|
|
|
actionIcon: Icons.arrow_forward_outlined,
|
2023-11-15 13:28:53 +00:00
|
|
|
text: S.of(context).blackFridaySale,
|
|
|
|
subText: S.of(context).upto50OffUntil4thDec,
|
2023-11-15 12:45:38 +00:00
|
|
|
type: NotificationType.goldenBanner,
|
|
|
|
onTap: () async {
|
|
|
|
launchUrlString(
|
2023-11-15 13:09:13 +00:00
|
|
|
"https://ente.io/blackfriday",
|
2023-11-15 12:45:38 +00:00
|
|
|
mode: LaunchMode.platformDefault,
|
|
|
|
);
|
|
|
|
},
|
|
|
|
)
|
|
|
|
: NotificationWidget(
|
|
|
|
startIcon: Icons.auto_awesome,
|
|
|
|
actionIcon: Icons.arrow_forward_outlined,
|
|
|
|
text: S.of(context).doubleYourStorage,
|
|
|
|
subText: S.of(context).referFriendsAnd2xYourPlan,
|
|
|
|
type: NotificationType.goldenBanner,
|
|
|
|
onTap: () async {
|
|
|
|
StorageBonusService.instance
|
|
|
|
.markStorageBonusAsDone();
|
|
|
|
routeToPage(context, const ReferralScreen());
|
|
|
|
},
|
|
|
|
),
|
2023-02-22 15:04:03 +00:00
|
|
|
).animate(onPlay: (controller) => controller.repeat()).shimmer(
|
|
|
|
duration: 1000.ms,
|
|
|
|
delay: 3200.ms,
|
|
|
|
size: 0.6,
|
|
|
|
),
|
2023-02-17 08:49:11 +00:00
|
|
|
)
|
2023-02-18 03:59:23 +00:00
|
|
|
: const SizedBox(height: 12),
|
2022-07-04 08:43:01 +00:00
|
|
|
const BackupSectionWidget(),
|
2022-10-04 04:58:42 +00:00
|
|
|
sectionSpacing,
|
2022-07-04 08:43:01 +00:00
|
|
|
const AccountSectionWidget(),
|
2022-10-04 04:58:42 +00:00
|
|
|
sectionSpacing,
|
2021-03-21 09:58:55 +00:00
|
|
|
]);
|
|
|
|
}
|
|
|
|
contents.addAll([
|
2022-07-04 08:43:01 +00:00
|
|
|
const SecuritySectionWidget(),
|
2022-10-04 04:58:42 +00:00
|
|
|
sectionSpacing,
|
2022-12-07 05:21:47 +00:00
|
|
|
const GeneralSectionWidget(),
|
|
|
|
sectionSpacing,
|
2022-07-14 07:41:03 +00:00
|
|
|
]);
|
|
|
|
|
|
|
|
if (Platform.isAndroid || kDebugMode) {
|
|
|
|
contents.addAll([
|
2022-10-04 09:26:31 +00:00
|
|
|
const ThemeSwitchWidget(),
|
2022-10-04 04:58:42 +00:00
|
|
|
sectionSpacing,
|
2022-07-14 07:41:03 +00:00
|
|
|
]);
|
|
|
|
}
|
|
|
|
|
|
|
|
contents.addAll([
|
2022-07-04 06:02:17 +00:00
|
|
|
const SupportSectionWidget(),
|
2022-10-04 04:58:42 +00:00
|
|
|
sectionSpacing,
|
2022-07-04 06:02:17 +00:00
|
|
|
const SocialSectionWidget(),
|
2022-10-04 04:58:42 +00:00
|
|
|
sectionSpacing,
|
2022-10-05 06:19:36 +00:00
|
|
|
const AboutSectionWidget(),
|
2021-03-21 09:58:55 +00:00
|
|
|
]);
|
2022-05-17 17:23:00 +00:00
|
|
|
|
2023-01-09 06:05:27 +00:00
|
|
|
if (hasLoggedIn &&
|
|
|
|
FeatureFlagService.instance.isInternalUserOrDebugBuild()) {
|
2022-10-04 04:58:42 +00:00
|
|
|
contents.addAll([sectionSpacing, const DebugSectionWidget()]);
|
2021-03-21 09:58:55 +00:00
|
|
|
}
|
2022-07-04 06:02:17 +00:00
|
|
|
contents.add(const AppVersionWidget());
|
2022-06-11 08:23:52 +00:00
|
|
|
contents.add(
|
2022-07-04 06:02:17 +00:00
|
|
|
const Padding(
|
2022-06-11 08:23:52 +00:00
|
|
|
padding: EdgeInsets.only(bottom: 60),
|
|
|
|
),
|
|
|
|
);
|
2022-05-17 17:23:00 +00:00
|
|
|
|
2022-10-12 08:01:08 +00:00
|
|
|
return SafeArea(
|
|
|
|
bottom: false,
|
2022-10-10 08:59:54 +00:00
|
|
|
child: SingleChildScrollView(
|
2023-10-07 12:52:53 +00:00
|
|
|
physics: const BouncingScrollPhysics(),
|
2022-10-10 08:59:54 +00:00
|
|
|
child: Column(
|
|
|
|
mainAxisSize: MainAxisSize.min,
|
|
|
|
children: [
|
|
|
|
const SettingsTitleBarWidget(),
|
|
|
|
Padding(
|
|
|
|
padding: const EdgeInsets.fromLTRB(16, 16, 16, 24),
|
2022-10-12 09:17:47 +00:00
|
|
|
child: Column(
|
|
|
|
children: contents,
|
2022-10-08 07:17:10 +00:00
|
|
|
),
|
2022-06-13 15:14:49 +00:00
|
|
|
),
|
2022-10-08 07:17:10 +00:00
|
|
|
],
|
2022-07-03 06:56:43 +00:00
|
|
|
),
|
|
|
|
),
|
2020-08-28 23:50:34 +00:00
|
|
|
);
|
|
|
|
}
|
2023-02-26 05:58:30 +00:00
|
|
|
|
|
|
|
Future<void> _showVerifyIdentityDialog(BuildContext context) async {
|
|
|
|
await showDialog(
|
|
|
|
context: context,
|
|
|
|
builder: (BuildContext context) {
|
|
|
|
return VerifyIdentifyDialog(self: true);
|
|
|
|
},
|
|
|
|
);
|
|
|
|
}
|
2020-08-28 23:50:34 +00:00
|
|
|
}
|