import 'package:flutter/material.dart'; import '../i18n/strings.g.dart'; import '../services/onboarding_store.dart'; import '../services/sharing_switch.dart'; import 'market_gate.dart'; import 'theme.dart'; /// Shown when someone taps a social entry (chat, profile, favourites, your /// people) while sharing is still off. /// /// The alternative was hiding those entries until sharing is on, but then /// nobody would ever discover that Tane does any of it. So they stay in the /// drawer, quiet, and tapping one explains what they are and offers to switch /// them on — with the community rules, which is the same single consent step /// the market uses. Returns true when sharing ended up on. Future showSharingInvite( BuildContext context, { required OnboardingStore onboarding, required SharingSwitch sharing, }) async { final wants = await showModalBottomSheet( context: context, isScrollControlled: true, builder: (_) => const SharingInviteSheet(), ); if (wants != true || !context.mounted) return false; return ensureMarketRulesAccepted(context, onboarding, sharing: sharing); } /// The invitation itself: what lights up when you join, and the plain fact that /// it needs a connection. class SharingInviteSheet extends StatelessWidget { const SharingInviteSheet({super.key}); @override Widget build(BuildContext context) { final t = context.t; final theme = Theme.of(context); return SafeArea( child: SingleChildScrollView( padding: EdgeInsets.only( left: 20, right: 20, top: 24, bottom: 16 + MediaQuery.of(context).viewInsets.bottom, ), child: Column( crossAxisAlignment: CrossAxisAlignment.start, mainAxisSize: MainAxisSize.min, children: [ Text( t.sharingInvite.title, style: theme.textTheme.titleLarge?.copyWith( color: seedOnSurface, fontWeight: FontWeight.w600, ), ), const SizedBox(height: 12), _Perk(Icons.chat_bubble_outline, t.sharingInvite.perkChat), _Perk(Icons.favorite_border, t.sharingInvite.perkFavorites), _Perk(Icons.group_outlined, t.sharingInvite.perkPeople), const SizedBox(height: 12), Text( t.sharingInvite.networkNote, style: theme.textTheme.bodySmall?.copyWith( color: seedMuted, height: 1.4, ), ), const SizedBox(height: 12), Row( mainAxisAlignment: MainAxisAlignment.end, children: [ TextButton( key: const Key('sharingInvite.notNow'), onPressed: () => Navigator.of(context).pop(false), child: Text(t.sharingInvite.notNow), ), const SizedBox(width: 8), FilledButton( key: const Key('sharingInvite.start'), onPressed: () => Navigator.of(context).pop(true), child: Text(t.sharingInvite.start), ), ], ), ], ), ), ); } } class _Perk extends StatelessWidget { const _Perk(this.icon, this.text); final IconData icon; final String text; @override Widget build(BuildContext context) { return Padding( padding: const EdgeInsetsDirectional.only(bottom: 8), child: Row( crossAxisAlignment: CrossAxisAlignment.start, children: [ Icon(icon, size: 18, color: seedGreen), const SizedBox(width: 8), Expanded( child: Text( text, style: Theme.of(context).textTheme.bodyMedium?.copyWith( color: seedOnSurface, height: 1.35, ), ), ), ], ), ); } }