feat(sharing): make going online opt-in, and show what it unlocks
Tane dialled its four default relays at launch, before anyone had asked for anything — an F-Droid reviewer spotted it, and they were right. The seed book needs no network at all, so the app should not have one until the person joins the sharing side. - SocialSettings gains a three-state `sharingEnabled`. `null` means "never asked", which is what lets `migrateSharingEnabled` keep an existing install exactly as it was: anyone past the intro was on a build that connected at launch, so they keep messaging, device sync and offer alerts. A fresh install starts fully offline. - bootstrap only starts the shared connection when sharing is on. The inbox/sync/plantaré/alert listeners are untouched: they react to a session, and none arrives. - SharingSwitch is the single place that moves the stored choice, the live connection and the flag the UI listens to, so they cannot drift. - Agreeing to the community rules is the opt-in — one consent surface, reached from the market or from the drawer's invitation. - SocialConnection.start is now idempotent and gains stop(), so turning sharing off goes offline immediately instead of at the next launch. - The social drawer entries stay visible but padlocked while sharing is off; tapping one explains what wakes up and offers to join. Hiding them would have kept the tool a secret. "Coming soon" is gone for good — everything it labelled is built. Covered by tests for the migration in both directions, start/stop lifecycle, the gate turning sharing on, the invitation, and the drawer in all three states (no social layer / off / on).
This commit is contained in:
parent
62123582f5
commit
fed0e8200e
35 changed files with 926 additions and 173 deletions
123
apps/app_seeds/lib/ui/sharing_invite_sheet.dart
Normal file
123
apps/app_seeds/lib/ui/sharing_invite_sheet.dart
Normal file
|
|
@ -0,0 +1,123 @@
|
|||
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<bool> showSharingInvite(
|
||||
BuildContext context, {
|
||||
required OnboardingStore onboarding,
|
||||
required SharingSwitch sharing,
|
||||
}) async {
|
||||
final wants = await showModalBottomSheet<bool>(
|
||||
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,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue