Merge branch 'claude/festive-einstein-384c45'

Ego-centric trust replaces the global Duniter WoT, plus Wallapop-style
ratings v1 (kind 30778). Conflicts resolved: pubspec assets (kept
seed_saving, dropped trust referents), chat_screen (avatars/no-links
from main + rating strip and simplified TrustCubit from the branch),
strings.g.dart regenerated from merged sources.
This commit is contained in:
vjrj 2026-07-11 13:25:51 +02:00
commit 15511ee761
40 changed files with 1777 additions and 876 deletions

View file

@ -15,12 +15,12 @@ import '../services/profile_cache.dart';
import '../services/profile_store.dart';
import '../services/social_connection.dart';
import '../services/social_service.dart';
import '../services/trust_referents.dart';
import '../services/unread_service.dart';
import '../services/wot_settings.dart';
import '../state/messages_cubit.dart';
import '../state/peer_rating_cubit.dart';
import '../state/trust_cubit.dart';
import 'peer_avatar.dart';
import 'rating_sheet.dart';
import 'theme.dart';
/// A 1:1 encrypted chat with one peer (redesign screen 10). Private and
@ -33,8 +33,6 @@ class ChatScreen extends StatefulWidget {
required this.peerPubkey,
this.messageStore,
this.profileCache,
this.trustReferents,
this.wotSettings,
super.key,
});
@ -51,10 +49,6 @@ class ChatScreen extends StatefulWidget {
/// Optional cache of peer display names; null in tests.
final ProfileCache? profileCache;
/// Web-of-trust bootstrap referents + parameters, for the membership verdict.
final TrustReferents? trustReferents;
final WotSettings? wotSettings;
@override
State<ChatScreen> createState() => _ChatScreenState();
}
@ -62,6 +56,7 @@ class ChatScreen extends StatefulWidget {
class _ChatScreenState extends State<ChatScreen> {
MessagesCubit? _messages;
TrustCubit? _trust;
PeerRatingCubit? _rating;
bool _loading = true;
String? _peerName;
String? _selfName;
@ -95,8 +90,6 @@ class _ChatScreenState extends State<ChatScreen> {
final selfName = getIt.isRegistered<ProfileStore>()
? await getIt<ProfileStore>().name()
: '';
final referents = await widget.trustReferents?.all() ?? const <String>{};
final wotParams = await widget.wotSettings?.params() ?? WotParams.duniter;
if (!mounted) return; // shared session is owned by the connection, not us
final self = widget.social.publicKeyHex;
final messages = MessagesCubit(
@ -109,13 +102,19 @@ class _ChatScreenState extends State<ChatScreen> {
session?.trust,
peerPubkey: widget.peerPubkey,
selfPubkey: self,
referents: referents,
params: wotParams,
);
unawaited(trust.load());
final rating = PeerRatingCubit(
session?.ratings,
peerPubkey: widget.peerPubkey,
selfPubkey: self,
trust: session?.trust,
);
unawaited(rating.load());
setState(() {
_messages = messages;
_trust = trust;
_rating = rating;
_peerName = cachedName;
_selfName = selfName.isEmpty ? null : selfName;
_loading = false;
@ -193,6 +192,7 @@ class _ChatScreenState extends State<ChatScreen> {
unawaited(_unread?.markRead(widget.peerPubkey));
_messages?.close();
_trust?.close();
_rating?.close();
// The session belongs to the shared connection don't close it here.
_input.dispose();
super.dispose();
@ -202,6 +202,7 @@ class _ChatScreenState extends State<ChatScreen> {
Widget build(BuildContext context) {
final messages = _messages;
final trust = _trust;
final rating = _rating;
final t = context.t;
return Scaffold(
appBar: AppBar(
@ -216,12 +217,13 @@ class _ChatScreenState extends State<ChatScreen> {
),
],
),
body: _loading || messages == null || trust == null
body: _loading || messages == null || trust == null || rating == null
? const Center(child: CircularProgressIndicator())
: MultiBlocProvider(
providers: [
BlocProvider.value(value: messages),
BlocProvider.value(value: trust),
BlocProvider.value(value: rating),
],
child: _ChatBody(
controller: _input,
@ -274,6 +276,7 @@ class _ChatBody extends StatelessWidget {
child: Column(
children: [
const _TrustBanner(),
const _RatingStrip(),
Expanded(
child: ChatMessageList(peerName: peerName, selfName: selfName),
),
@ -348,10 +351,9 @@ class _TrustBanner extends StatelessWidget {
builder: (context, state) {
final cubit = context.read<TrustCubit>();
if (!cubit.isOnline || state.loading) return const SizedBox.shrink();
// Strongest applicable signal decides the badge (member > circle >
// vouched > unknown).
// Strongest applicable signal decides the badge (circle > vouched >
// unknown).
final (IconData icon, String label, bool strong) = switch (state.tier) {
TrustTier.networkMember => (Icons.verified, t.trust.member, true),
TrustTier.inYourCircle => (Icons.verified_user, t.trust.circle, true),
TrustTier.vouched => (
Icons.people_outline,
@ -391,6 +393,56 @@ class _TrustBanner extends StatelessWidget {
}
}
/// A slim reputation strip under the trust banner: everyone's stars for this
/// peer (highlighting how many come from people you know) and, once you've
/// actually talked with them, a button to leave or edit your own rating.
class _RatingStrip extends StatelessWidget {
const _RatingStrip();
@override
Widget build(BuildContext context) {
final t = context.t;
return BlocBuilder<PeerRatingCubit, PeerRatingState>(
builder: (context, state) {
final cubit = context.read<PeerRatingCubit>();
if (!cubit.isOnline || state.loading) return const SizedBox.shrink();
// Soft anchor: you can only rate someone you've talked with.
final canRate = context.select<MessagesCubit, bool>(
(m) => m.state.messages.isNotEmpty,
);
if (!state.hasRatings && !canRate) return const SizedBox.shrink();
return Container(
width: double.infinity,
color: seedPrimaryContainer.withValues(alpha: 0.3),
padding: const EdgeInsetsDirectional.fromSTEB(16, 4, 8, 4),
child: Row(
children: [
Expanded(
child: state.hasRatings
? RatingStars(
average: state.average,
count: state.count,
circleCount: state.circleCount,
)
: const SizedBox.shrink(),
),
if (canRate)
TextButton(
key: const Key('chat.rate'),
onPressed: state.busy
? null
: () => showRatingSheet(context, cubit),
child:
Text(state.iRated ? t.ratings.edit : t.ratings.rate),
),
],
),
);
},
);
}
}
/// A centered pill introducing a new day ("Today", "Yesterday", or a
/// locale-formatted date). Localized via [chatDayLabel].
class _DaySeparator extends StatelessWidget {

View file

@ -8,7 +8,10 @@ import 'package:go_router/go_router.dart';
import '../i18n/strings.g.dart';
import '../services/profile_cache.dart';
import '../services/social_connection.dart';
import '../services/social_service.dart';
import '../state/peer_rating_cubit.dart';
import 'market_widgets.dart';
import 'rating_sheet.dart';
import 'theme.dart';
/// Read-only "product page" for one discovered [Offer] (the Wallapop-style
@ -22,6 +25,7 @@ class MarketOfferDetailScreen extends StatefulWidget {
required this.connection,
this.mine = false,
this.profileCache,
this.selfPubkey,
super.key,
});
@ -36,6 +40,10 @@ class MarketOfferDetailScreen extends StatefulWidget {
/// Optional cache of peers' published display names; null in tests.
final ProfileCache? profileCache;
/// This user's key (hex), to weigh the author's ratings by your own circle;
/// null in tests (circle weighting then stays off).
final String? selfPubkey;
@override
State<MarketOfferDetailScreen> createState() =>
_MarketOfferDetailScreenState();
@ -46,6 +54,7 @@ class _MarketOfferDetailScreenState extends State<MarketOfferDetailScreen> {
String? _sellerAbout;
String? _sellerG1;
bool _profileLoading = true;
PeerRatingState? _sellerRating;
@override
void initState() {
@ -65,6 +74,7 @@ class _MarketOfferDetailScreenState extends State<MarketOfferDetailScreen> {
setState(() => _profileLoading = false);
return;
}
unawaited(_loadSellerRating(session));
try {
final profile = await session.profile.fetch(widget.offer.authorPubkeyHex);
if (profile != null && profile.name.isNotEmpty) {
@ -86,6 +96,25 @@ class _MarketOfferDetailScreenState extends State<MarketOfferDetailScreen> {
}
}
/// Best-effort summary of the author's ratings, circle-weighted when we know
/// who this user is. Reuses the cubit's aggregation without providing it.
Future<void> _loadSellerRating(SocialSession session) async {
final cubit = PeerRatingCubit(
session.ratings,
peerPubkey: widget.offer.authorPubkeyHex,
selfPubkey: widget.selfPubkey ?? '',
trust: widget.selfPubkey == null ? null : session.trust,
);
try {
await cubit.load();
if (mounted) setState(() => _sellerRating = cubit.state);
} catch (_) {
// offline / unreachable the seller section simply shows no stars.
} finally {
await cubit.close();
}
}
// No dispose of the session it belongs to the shared connection.
Future<void> _copyId() async {
@ -167,6 +196,7 @@ class _MarketOfferDetailScreenState extends State<MarketOfferDetailScreen> {
title: t.market.sharedBy,
name: _sellerName ?? shortPubkey(o.authorPubkeyHex),
about: _sellerAbout,
rating: _sellerRating,
loading: _profileLoading,
hasProfile:
_sellerName != null || _sellerAbout != null || _sellerG1 != null,
@ -227,11 +257,16 @@ class _SellerSection extends StatelessWidget {
required this.noProfileLabel,
required this.onCopyId,
required this.copyIdTooltip,
this.rating,
});
final String title;
final String name;
final String? about;
/// Circle-weighted summary of the author's ratings; stars show only when
/// someone actually rated them (absence is never a reproach).
final PeerRatingState? rating;
final bool loading;
final bool hasProfile;
final String noProfileLabel;
@ -261,13 +296,26 @@ class _SellerSection extends StatelessWidget {
),
const SizedBox(width: 12),
Expanded(
child: Text(
name,
style: const TextStyle(
fontSize: 16,
fontWeight: FontWeight.w500,
color: seedOnSurface,
),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
name,
style: const TextStyle(
fontSize: 16,
fontWeight: FontWeight.w500,
color: seedOnSurface,
),
),
if (rating != null && rating!.hasRatings) ...[
const SizedBox(height: 2),
RatingStars(
average: rating!.average,
count: rating!.count,
circleCount: rating!.circleCount,
),
],
],
),
),
IconButton(

View file

@ -22,7 +22,7 @@ class ProfileScreen extends StatefulWidget {
required this.connection,
required this.profileStore,
required this.accounts,
this.trustNetworkEnabled = false,
this.yourPeopleEnabled = false,
super.key,
});
@ -33,8 +33,8 @@ class ProfileScreen extends StatefulWidget {
final ProfileStore profileStore;
final SocialAccountStore accounts;
/// Whether to offer the "Network of trust" entry (needs the WoT services).
final bool trustNetworkEnabled;
/// Whether to offer the "Your people" entry (needs the social layer).
final bool yourPeopleEnabled;
@override
State<ProfileScreen> createState() => _ProfileScreenState();
@ -210,16 +210,17 @@ class _ProfileScreenState extends State<ProfileScreen> {
onSwitch: (a) => _switchTo(a),
onNew: _newIdentity,
),
if (widget.trustNetworkEnabled) ...[
if (widget.yourPeopleEnabled) ...[
const SizedBox(height: 12),
const Divider(),
ListTile(
key: const Key('profile.trustNetwork'),
key: const Key('profile.yourPeople'),
contentPadding: EdgeInsets.zero,
leading: const Icon(Icons.hub_outlined, color: seedGreen),
title: Text(t.wot.open),
leading:
const Icon(Icons.people_alt_outlined, color: seedGreen),
title: Text(t.yourPeople.title),
trailing: const Icon(Icons.chevron_right, color: seedMuted),
onTap: () => context.push('/trust'),
onTap: () => context.push('/your-people'),
),
],
],

View file

@ -0,0 +1,180 @@
import 'package:flutter/material.dart';
import 'package:intl/intl.dart';
import '../i18n/strings.g.dart';
import '../state/peer_rating_cubit.dart';
import 'theme.dart';
/// A compact "★ 4,5 (12)" pill, plus how many ratings come from people you
/// know the signal that makes strangers' reviews easy to weigh.
class RatingStars extends StatelessWidget {
const RatingStars({
required this.average,
required this.count,
this.circleCount = 0,
super.key,
});
final double average;
final int count;
final int circleCount;
@override
Widget build(BuildContext context) {
final t = context.t;
final locale = Localizations.localeOf(context).toString();
final avg = NumberFormat('0.#', locale).format(average);
return Wrap(
crossAxisAlignment: WrapCrossAlignment.center,
spacing: 6,
children: [
const Icon(Icons.star_rounded, size: 18, color: seedGreen),
Text(
'$avg ($count)',
style: const TextStyle(
color: seedOnSurface,
fontSize: 13,
fontWeight: FontWeight.w600,
),
),
if (circleCount > 0)
Text(
t.ratings.fromYourCircle(n: circleCount),
style: const TextStyle(color: seedGreen, fontSize: 13),
),
],
);
}
}
/// Opens the bottom sheet to leave, edit or take back your rating of the
/// peer behind [cubit]. Pre-filled when you already rated.
Future<void> showRatingSheet(BuildContext context, PeerRatingCubit cubit) {
return showModalBottomSheet<void>(
context: context,
isScrollControlled: true,
builder: (context) => Padding(
padding: EdgeInsets.only(
bottom: MediaQuery.of(context).viewInsets.bottom,
),
child: _RatingForm(cubit: cubit),
),
);
}
class _RatingForm extends StatefulWidget {
const _RatingForm({required this.cubit});
final PeerRatingCubit cubit;
@override
State<_RatingForm> createState() => _RatingFormState();
}
class _RatingFormState extends State<_RatingForm> {
late int _stars;
late final TextEditingController _comment;
bool _saving = false;
@override
void initState() {
super.initState();
final state = widget.cubit.state;
_stars = state.myStars ?? 0;
_comment = TextEditingController(text: state.myComment);
}
@override
void dispose() {
_comment.dispose();
super.dispose();
}
Future<void> _save() async {
final messenger = ScaffoldMessenger.of(context);
final navigator = Navigator.of(context);
final saved = context.t.ratings.saved;
setState(() => _saving = true);
await widget.cubit.rate(_stars, comment: _comment.text.trim());
navigator.pop();
messenger.showSnackBar(SnackBar(content: Text(saved)));
}
Future<void> _retract() async {
final navigator = Navigator.of(context);
setState(() => _saving = true);
await widget.cubit.retract();
navigator.pop();
}
@override
Widget build(BuildContext context) {
final t = context.t;
final iRated = widget.cubit.state.iRated;
return Padding(
padding: const EdgeInsets.fromLTRB(24, 20, 24, 24),
child: Column(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
iRated ? t.ratings.edit : t.ratings.rate,
style: const TextStyle(
fontSize: 18,
fontWeight: FontWeight.w600,
color: seedTitle,
),
),
const SizedBox(height: 16),
Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
for (var s = 1; s <= 5; s++)
IconButton(
key: Key('rating.star.$s'),
iconSize: 36,
onPressed:
_saving ? null : () => setState(() => _stars = s),
icon: Icon(
s <= _stars
? Icons.star_rounded
: Icons.star_outline_rounded,
color: s <= _stars ? seedGreen : seedMuted,
),
),
],
),
const SizedBox(height: 8),
TextField(
key: const Key('rating.comment'),
controller: _comment,
enabled: !_saving,
maxLength: 280,
maxLines: 2,
decoration: InputDecoration(
hintText: t.ratings.commentHint,
border: const OutlineInputBorder(),
),
),
const SizedBox(height: 8),
Row(
children: [
if (iRated)
TextButton(
key: const Key('rating.retract'),
onPressed: _saving ? null : _retract,
child: Text(t.ratings.retract),
),
const Spacer(),
FilledButton(
key: const Key('rating.save'),
onPressed: _saving || _stars == 0 ? null : _save,
child: Text(t.common.save),
),
],
),
],
),
);
}
}

View file

@ -1,228 +0,0 @@
import 'package:commons_core/commons_core.dart';
import 'package:flutter/material.dart';
import '../i18n/strings.g.dart';
import '../services/profile_cache.dart' show shortPubkey;
import '../services/trust_referents.dart';
import '../services/wot_settings.dart';
import 'theme.dart';
/// Manage the web of trust: the bootstrap "roots" (Duniter seeds) membership is
/// measured from, and the advanced parameters (sigQty / stepMax / validity).
/// This is where a young network is seeded and tuned progressive disclosure,
/// reached from the profile.
class TrustNetworkScreen extends StatefulWidget {
const TrustNetworkScreen({
required this.referents,
required this.wotSettings,
super.key,
});
final TrustReferents referents;
final WotSettings wotSettings;
@override
State<TrustNetworkScreen> createState() => _TrustNetworkScreenState();
}
class _TrustNetworkScreenState extends State<TrustNetworkScreen> {
final _input = TextEditingController();
Set<String> _roots = {};
WotParams _params = WotParams.duniter;
bool _loading = true;
String? _error;
@override
void initState() {
super.initState();
_load();
}
Future<void> _load() async {
final roots = await widget.referents.userAdded();
final params = await widget.wotSettings.params();
if (!mounted) return;
setState(() {
_roots = roots;
_params = params;
_loading = false;
});
}
Future<void> _addRoot() async {
final t = context.t;
final messenger = ScaffoldMessenger.of(context);
try {
await widget.referents.add(_input.text);
_input.clear();
await _load();
messenger.showSnackBar(SnackBar(content: Text(t.wot.rootAdded)));
} on FormatException {
setState(() => _error = t.wot.rootInvalid);
}
}
Future<void> _removeRoot(String hex) async {
await widget.referents.remove(hex);
await _load();
}
Future<void> _saveParams(WotParams next) async {
await widget.wotSettings.save(next);
if (!mounted) return;
setState(() => _params = next);
ScaffoldMessenger.of(context)
.showSnackBar(SnackBar(content: Text(context.t.wot.saved)));
}
@override
void dispose() {
_input.dispose();
super.dispose();
}
@override
Widget build(BuildContext context) {
final t = context.t;
return Scaffold(
appBar: AppBar(title: Text(t.wot.title)),
body: _loading
? const Center(child: CircularProgressIndicator())
: ListView(
padding: const EdgeInsets.all(20),
children: [
Text(t.wot.help,
style: const TextStyle(color: seedMuted, fontSize: 13)),
const SizedBox(height: 20),
Text(t.wot.roots,
style: const TextStyle(
fontWeight: FontWeight.w600, color: seedOnSurface)),
const SizedBox(height: 4),
Text(t.wot.rootsHelp,
style: const TextStyle(color: seedMuted, fontSize: 12)),
const SizedBox(height: 8),
if (_roots.isEmpty)
Padding(
padding: const EdgeInsets.symmetric(vertical: 8),
child: Text(t.wot.noRoots,
style:
const TextStyle(color: seedMuted, fontSize: 13)),
),
for (final hex in _roots)
ListTile(
contentPadding: EdgeInsets.zero,
leading: const Icon(Icons.hub_outlined, color: seedGreen),
title: Text(shortPubkey(hex),
style: const TextStyle(
fontFamily: 'monospace', fontSize: 13)),
trailing: IconButton(
icon: const Icon(Icons.close, size: 20),
tooltip: t.wot.remove,
onPressed: () => _removeRoot(hex),
),
),
const SizedBox(height: 8),
TextField(
key: const Key('wot.rootInput'),
controller: _input,
onChanged: (_) {
if (_error != null) setState(() => _error = null);
},
decoration: InputDecoration(
labelText: t.wot.addRoot,
hintText: t.wot.rootHint,
errorText: _error,
suffixIcon: IconButton(
key: const Key('wot.addRoot'),
icon: const Icon(Icons.add),
onPressed: _addRoot,
),
),
),
const SizedBox(height: 12),
const Divider(),
ExpansionTile(
tilePadding: EdgeInsets.zero,
title: Text(t.wot.params),
subtitle: Text(t.wot.paramsHelp,
style: const TextStyle(fontSize: 12)),
children: [
_Stepper(
label: t.wot.sigQty,
value: _params.sigQty,
min: 1,
onChanged: (v) =>
_saveParams(_params.copyWith(sigQty: v)),
),
_Stepper(
label: t.wot.stepMax,
value: _params.stepMax,
min: 1,
onChanged: (v) =>
_saveParams(_params.copyWith(stepMax: v)),
),
_Stepper(
label: t.wot.validityDays,
value: _params.sigValidity.inDays,
min: 1,
step: 30,
onChanged: (v) => _saveParams(
_params.copyWith(sigValidity: Duration(days: v))),
),
const SizedBox(height: 8),
Align(
alignment: AlignmentDirectional.centerStart,
child: TextButton(
onPressed: () => _saveParams(WotParams.duniter),
child: Text(t.wot.reset),
),
),
],
),
],
),
);
}
}
/// A "- value +" row for an integer parameter, clamped to [min].
class _Stepper extends StatelessWidget {
const _Stepper({
required this.label,
required this.value,
required this.onChanged,
this.min = 0,
this.step = 1,
});
final String label;
final int value;
final int min;
final int step;
final ValueChanged<int> onChanged;
@override
Widget build(BuildContext context) {
return Padding(
padding: const EdgeInsets.symmetric(vertical: 4),
child: Row(
children: [
Expanded(child: Text(label)),
IconButton(
icon: const Icon(Icons.remove_circle_outline),
onPressed:
value - step >= min ? () => onChanged(value - step) : null,
),
SizedBox(
width: 44,
child: Text('$value', textAlign: TextAlign.center),
),
IconButton(
icon: const Icon(Icons.add_circle_outline),
onPressed: () => onChanged(value + step),
),
],
),
);
}
}

View file

@ -0,0 +1,240 @@
import 'dart:async';
import 'package:commons_core/commons_core.dart';
import 'package:flutter/material.dart';
import 'package:go_router/go_router.dart';
import '../i18n/strings.g.dart';
import '../services/profile_cache.dart';
import '../services/social_connection.dart';
import '../services/social_service.dart';
import 'theme.dart';
/// "Your people": who you vouch for and who vouches for you, in human
/// language. Ego-centric by design no roots, no parameters, no graph talk.
/// Reached from the profile; rows open the 1:1 chat.
class YourPeopleScreen extends StatefulWidget {
const YourPeopleScreen({
required this.social,
required this.connection,
this.profileCache,
super.key,
});
final SocialService social;
/// The shared relay connection (one per identity), carrying trust.
final SocialConnection connection;
/// Optional cache of peer display names; null in tests.
final ProfileCache? profileCache;
@override
State<YourPeopleScreen> createState() => _YourPeopleScreenState();
}
class _YourPeopleScreenState extends State<YourPeopleScreen> {
TrustTransport? _transport;
bool _loading = true;
bool _busy = false;
List<String> _youVouchFor = const [];
List<String> _vouchForYou = const [];
final Map<String, String> _names = {};
@override
void initState() {
super.initState();
_init();
}
Future<void> _init() async {
final session = await widget.connection.session();
if (!mounted) return; // shared session is owned by the connection, not us
_transport = session?.trust;
await _load();
}
Future<void> _load() async {
final transport = _transport;
if (transport == null) {
if (mounted) setState(() => _loading = false);
return;
}
final self = widget.social.publicKeyHex;
final now = DateTime.now();
final certs = (await transport.allCertifications())
.where((c) => c.isValidAt(now))
.toList();
final given = [
for (final c in certs)
if (c.issuer == self) c.subject,
]..sort();
final received = [
for (final c in certs)
if (c.subject == self) c.issuer,
]..sort();
final cache = widget.profileCache;
if (cache != null) {
for (final peer in {...given, ...received}) {
final name = await cache.name(peer);
if (name != null) _names[peer] = name;
}
}
if (!mounted) return;
setState(() {
_youVouchFor = given;
_vouchForYou = received;
_loading = false;
});
}
Future<void> _revoke(String peer) async {
final t = context.t;
final confirmed = await showDialog<bool>(
context: context,
builder: (context) => AlertDialog(
title: Text(t.yourPeople.revokeConfirm),
actions: [
TextButton(
onPressed: () => Navigator.pop(context, false),
child: Text(t.common.cancel),
),
FilledButton(
onPressed: () => Navigator.pop(context, true),
child: Text(t.yourPeople.revoke),
),
],
),
);
final transport = _transport;
if (confirmed != true || transport == null || !mounted) return;
setState(() => _busy = true);
await transport.revoke(subjectPubkey: peer);
await _load();
if (mounted) setState(() => _busy = false);
}
@override
Widget build(BuildContext context) {
final t = context.t;
return Scaffold(
appBar: AppBar(title: Text(t.yourPeople.title)),
body: _loading
? const Center(child: CircularProgressIndicator())
: _transport == null
? Center(
child: Padding(
padding: const EdgeInsets.all(32),
child: Text(
t.yourPeople.offline,
textAlign: TextAlign.center,
style: const TextStyle(color: seedMuted, fontSize: 15),
),
),
)
: ListView(
padding: const EdgeInsets.symmetric(vertical: 8),
children: [
Padding(
padding: const EdgeInsetsDirectional.fromSTEB(
16, 8, 16, 8),
child: Text(
t.yourPeople.help,
style:
const TextStyle(color: seedMuted, fontSize: 14),
),
),
_SectionHeader(label: t.yourPeople.youVouchFor),
if (_youVouchFor.isEmpty)
_EmptyNote(text: t.yourPeople.youVouchForEmpty)
else
for (final peer in _youVouchFor)
_PersonTile(
key: Key('yourPeople.given.$peer'),
name: _names[peer] ?? shortPubkey(peer),
onOpen: () => context.push('/chat/$peer'),
trailing: TextButton(
onPressed: _busy ? null : () => _revoke(peer),
child: Text(t.yourPeople.revoke),
),
),
const SizedBox(height: 12),
_SectionHeader(label: t.yourPeople.vouchesForYou),
if (_vouchForYou.isEmpty)
_EmptyNote(text: t.yourPeople.vouchesForYouEmpty)
else
for (final peer in _vouchForYou)
_PersonTile(
key: Key('yourPeople.received.$peer'),
name: _names[peer] ?? shortPubkey(peer),
onOpen: () => context.push('/chat/$peer'),
),
],
),
);
}
}
class _SectionHeader extends StatelessWidget {
const _SectionHeader({required this.label});
final String label;
@override
Widget build(BuildContext context) {
return Padding(
padding: const EdgeInsetsDirectional.fromSTEB(16, 12, 16, 4),
child: Text(
label,
style: const TextStyle(
color: seedGreen,
fontSize: 13,
fontWeight: FontWeight.w600,
),
),
);
}
}
class _EmptyNote extends StatelessWidget {
const _EmptyNote({required this.text});
final String text;
@override
Widget build(BuildContext context) {
return Padding(
padding: const EdgeInsetsDirectional.fromSTEB(16, 4, 16, 4),
child: Text(
text,
style: const TextStyle(color: seedMuted, fontSize: 14),
),
);
}
}
class _PersonTile extends StatelessWidget {
const _PersonTile({
required this.name,
required this.onOpen,
this.trailing,
super.key,
});
final String name;
final VoidCallback onOpen;
final Widget? trailing;
@override
Widget build(BuildContext context) {
return ListTile(
leading: const CircleAvatar(
backgroundColor: seedAvatar,
child: Icon(Icons.person, color: seedOnAvatar),
),
title: Text(name),
trailing: trailing,
onTap: onOpen,
);
}
}