π End-to-end encrypted cloud for everything.
Dart 2faandroidauthye2eeencryptionend-to-end-encryptionfluttergolanggoogle-photosgoogle-photos-alternativeiosopensourcephotosprivacyprivacy-toolstypescriptzero-knowledge
[mobile][photos] Share billing controls and FAQ cards
r4khul2f1997b84594
diff --git a/mobile/packages/ui/lib/components/faq/faq_widgets.dart b/mobile/packages/ui/lib/components/faq/faq_widgets.dartnew file mode 100644index 0000000000..cbbf7fcca4--- /dev/null+++ b/mobile/packages/ui/lib/components/faq/faq_widgets.dart@@ -0,0 +1,137 @@+import 'dart:async';++import 'package:ente_components/components/navigation_card_component.dart';+import 'package:ente_components/theme/icon_sizes.dart';+import 'package:ente_components/theme/motion.dart';+import 'package:ente_components/theme/radii.dart';+import 'package:ente_components/theme/spacing.dart';+import 'package:ente_components/theme/text_styles.dart';+import 'package:ente_components/theme/theme.dart';+import 'package:flutter/material.dart';+import 'package:hugeicons/hugeicons.dart';++class FaqCard extends StatelessWidget {+ const FaqCard({+ super.key,+ required this.title,+ required this.subtitle,+ required this.onTap,+ });++ final String title;+ final String subtitle;+ final FutureOr<void> Function() onTap;++ @override+ Widget build(BuildContext context) => NavigationCardComponent(+ title: title,+ subtitle: subtitle,+ leading: HugeIcon(+ icon: HugeIcons.strokeRoundedBubbleChatQuestion,+ size: NavigationCardComponent.leadingSize,+ color: context.componentColors.textLight,+ ),+ onTap: onTap,+ );+}++class FaqSection extends StatelessWidget {+ const FaqSection({super.key, required this.children});++ final List<Widget> children;++ @override+ Widget build(BuildContext context) => Column(+ children: [+ for (var i = 0; i < children.length; i++) ...[+ if (i > 0) const SizedBox(height: Spacing.sm),+ children[i],+ ],+ ],+ );+}++class FaqItemWidget extends StatefulWidget {+ const FaqItemWidget({+ super.key,+ required this.question,+ required this.answer,+ });++ final String question;+ final String answer;++ @override+ State<FaqItemWidget> createState() => _FaqItemWidgetState();+}++class _FaqItemWidgetState extends State<FaqItemWidget> {+ bool _isExpanded = false;++ @override+ Widget build(BuildContext context) {+ final colors = context.componentColors;+ return Material(+ color: colors.fillLight,+ borderRadius: BorderRadius.circular(Radii.button),+ clipBehavior: Clip.antiAlias,+ child: InkWell(+ onTap: () => setState(() => _isExpanded = !_isExpanded),+ child: Column(+ crossAxisAlignment: CrossAxisAlignment.stretch,+ children: [+ Padding(+ padding: const EdgeInsets.fromLTRB(+ Spacing.xl,+ Spacing.lg,+ Spacing.xl,+ Spacing.md,+ ),+ child: Row(+ children: [+ Expanded(+ child: Text(+ widget.question,+ style: TextStyles.bodyBold.copyWith(+ color: colors.textBase,+ ),+ ),+ ),+ const SizedBox(width: Spacing.sm),+ HugeIcon(+ icon: _isExpanded+ ? HugeIcons.strokeRoundedArrowUp01+ : HugeIcons.strokeRoundedArrowDown01,+ size: IconSizes.small,+ color: colors.textBase,+ ),+ ],+ ),+ ),+ AnimatedSize(+ duration: Motion.standard,+ curve: Curves.easeInOutCubic,+ alignment: Alignment.topCenter,+ child: _isExpanded+ ? Padding(+ padding: const EdgeInsets.fromLTRB(+ Spacing.xl,+ 0,+ Spacing.xl,+ Spacing.lg,+ ),+ child: Text(+ widget.answer,+ style: TextStyles.mini.copyWith(+ color: colors.textLight,+ ),+ ),+ )+ : const SizedBox(width: double.infinity),+ ),+ ],+ ),+ ),+ );+ }+}diff --git a/mobile/packages/ui/lib/components/subscription/billing_period_toggle.dart b/mobile/packages/ui/lib/components/subscription/billing_period_toggle.dartnew file mode 100644index 0000000000..2a1d8c4794--- /dev/null+++ b/mobile/packages/ui/lib/components/subscription/billing_period_toggle.dart@@ -0,0 +1,112 @@+import 'package:ente_components/theme/motion.dart';+import 'package:ente_components/theme/spacing.dart';+import 'package:ente_components/theme/text_styles.dart';+import 'package:ente_components/theme/theme.dart';+import 'package:flutter/material.dart';++class BillingPeriodToggle extends StatefulWidget {+ final String monthlyLabel;+ final String yearlyLabel;+ final bool isYearly;+ final ValueChanged<bool> onToggle;+ const BillingPeriodToggle({+ required this.monthlyLabel,+ required this.yearlyLabel,+ required this.isYearly,+ required this.onToggle,+ super.key,+ });++ @override+ State<BillingPeriodToggle> createState() => _BillingPeriodToggleState();+}++class _BillingPeriodToggleState extends State<BillingPeriodToggle> {+ static const double _padding = Spacing.xs;+ static const double _minSegmentHeight = 41;+ static const double _radius = 35;++ late bool _isYearly;++ @override+ void initState() {+ super.initState();+ _isYearly = widget.isYearly;+ }++ @override+ void didUpdateWidget(covariant BillingPeriodToggle oldWidget) {+ super.didUpdateWidget(oldWidget);+ if (oldWidget.isYearly != widget.isYearly) {+ _isYearly = widget.isYearly;+ }+ }++ @override+ Widget build(BuildContext context) {+ final colors = context.componentColors;+ final labelStyle = TextStyles.body.copyWith(color: colors.textBase);+ return Container(+ padding: const EdgeInsets.all(_padding),+ decoration: BoxDecoration(+ color: colors.fillDark,+ borderRadius: BorderRadius.circular(_radius),+ ),+ child: Stack(+ children: [+ Positioned.fill(+ child: AnimatedAlign(+ duration: Motion.slow,+ curve: Curves.easeInOutCubic,+ alignment: _isYearly+ ? Alignment.centerRight+ : Alignment.centerLeft,+ child: FractionallySizedBox(+ widthFactor: 0.5,+ heightFactor: 1,+ child: DecoratedBox(+ decoration: BoxDecoration(+ color: colors.fillLight,+ borderRadius: BorderRadius.circular(_radius),+ ),+ ),+ ),+ ),+ ),+ IntrinsicHeight(+ child: Row(+ crossAxisAlignment: CrossAxisAlignment.stretch,+ children: [+ _segment(widget.monthlyLabel, false, labelStyle),+ _segment(widget.yearlyLabel, true, labelStyle),+ ],+ ),+ ),+ ],+ ),+ );+ }++ Widget _segment(String label, bool isYearly, TextStyle style) {+ return Expanded(+ child: GestureDetector(+ behavior: HitTestBehavior.opaque,+ onTap: () => setIsYearly(isYearly),+ child: ConstrainedBox(+ constraints: const BoxConstraints(minHeight: _minSegmentHeight),+ child: Center(+ child: Text(label, style: style, textAlign: TextAlign.center),+ ),+ ),+ ),+ );+ }++ void setIsYearly(bool isYearly) {+ if (_isYearly == isYearly) return;+ setState(() {+ _isYearly = isYearly;+ });+ widget.onToggle(isYearly);+ }+}diff --git a/mobile/packages/ui/lib/components/subscription/family_card.dart b/mobile/packages/ui/lib/components/subscription/family_card.dartnew file mode 100644index 0000000000..c09217c245--- /dev/null+++ b/mobile/packages/ui/lib/components/subscription/family_card.dart@@ -0,0 +1,31 @@+import 'dart:async';++import 'package:ente_components/components/navigation_card_component.dart';+import 'package:ente_components/theme/theme.dart';+import 'package:flutter/material.dart';+import 'package:hugeicons/hugeicons.dart';++class FamilyCard extends StatelessWidget {+ const FamilyCard({+ super.key,+ required this.title,+ required this.subtitle,+ required this.onTap,+ });++ final String title;+ final String subtitle;+ final FutureOr<void> Function() onTap;++ @override+ Widget build(BuildContext context) => NavigationCardComponent(+ title: title,+ subtitle: subtitle,+ leading: HugeIcon(+ icon: HugeIcons.strokeRoundedHouseHeart,+ size: NavigationCardComponent.leadingSize,+ color: context.componentColors.textLight,+ ),+ onTap: onTap,+ );+}