🐛 Add realm entry to the account page, close #205
This commit is contained in:
@@ -386,6 +386,17 @@ class AccountScreen extends HookConsumerWidget {
|
|||||||
context.goNamed('files');
|
context.goNamed('files');
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
|
if (!isWideScreen(context))
|
||||||
|
ListTile(
|
||||||
|
minTileHeight: 48,
|
||||||
|
leading: const Icon(Symbols.group),
|
||||||
|
trailing: const Icon(Symbols.chevron_right),
|
||||||
|
contentPadding: EdgeInsets.symmetric(horizontal: 24),
|
||||||
|
title: Text('realms').tr(),
|
||||||
|
onTap: () {
|
||||||
|
context.goNamed('realmList');
|
||||||
|
},
|
||||||
|
),
|
||||||
ListTile(
|
ListTile(
|
||||||
minTileHeight: 48,
|
minTileHeight: 48,
|
||||||
leading: const Icon(Symbols.wallet),
|
leading: const Icon(Symbols.wallet),
|
||||||
@@ -408,7 +419,7 @@ class AccountScreen extends HookConsumerWidget {
|
|||||||
),
|
),
|
||||||
ListTile(
|
ListTile(
|
||||||
minTileHeight: 48,
|
minTileHeight: 48,
|
||||||
leading: const Icon(Symbols.emoji_emotions),
|
leading: const Icon(Symbols.sticker_rounded),
|
||||||
trailing: const Icon(Symbols.chevron_right),
|
trailing: const Icon(Symbols.chevron_right),
|
||||||
contentPadding: EdgeInsets.symmetric(horizontal: 24),
|
contentPadding: EdgeInsets.symmetric(horizontal: 24),
|
||||||
title: Text('stickers').tr(),
|
title: Text('stickers').tr(),
|
||||||
|
|||||||
@@ -63,6 +63,7 @@ class RealmListScreen extends HookConsumerWidget {
|
|||||||
return AppScaffold(
|
return AppScaffold(
|
||||||
isNoBackground: false,
|
isNoBackground: false,
|
||||||
appBar: AppBar(
|
appBar: AppBar(
|
||||||
|
leading: const PageBackButton(backTo: '/account'),
|
||||||
title: const Text('realms').tr(),
|
title: const Text('realms').tr(),
|
||||||
actions: [
|
actions: [
|
||||||
IconButton(
|
IconButton(
|
||||||
@@ -99,33 +100,31 @@ class RealmListScreen extends HookConsumerWidget {
|
|||||||
),
|
),
|
||||||
body: ExtendedRefreshIndicator(
|
body: ExtendedRefreshIndicator(
|
||||||
child: realms.when(
|
child: realms.when(
|
||||||
data:
|
data: (value) => Column(
|
||||||
(value) => Column(
|
children: [
|
||||||
children: [
|
Expanded(
|
||||||
Expanded(
|
child: ListView.separated(
|
||||||
child: ListView.separated(
|
padding: EdgeInsets.only(
|
||||||
padding: EdgeInsets.only(
|
top: 8,
|
||||||
top: 8,
|
bottom: MediaQuery.of(context).padding.bottom + 8,
|
||||||
bottom: MediaQuery.of(context).padding.bottom + 8,
|
|
||||||
),
|
|
||||||
itemCount: value.length,
|
|
||||||
itemBuilder: (context, item) {
|
|
||||||
return ConstrainedBox(
|
|
||||||
constraints: const BoxConstraints(maxWidth: 540),
|
|
||||||
child: RealmListTile(realm: value[item]),
|
|
||||||
).padding(horizontal: 8).center();
|
|
||||||
},
|
|
||||||
separatorBuilder: (_, _) => const Gap(8),
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
],
|
itemCount: value.length,
|
||||||
|
itemBuilder: (context, item) {
|
||||||
|
return ConstrainedBox(
|
||||||
|
constraints: const BoxConstraints(maxWidth: 540),
|
||||||
|
child: RealmListTile(realm: value[item]),
|
||||||
|
).padding(horizontal: 8).center();
|
||||||
|
},
|
||||||
|
separatorBuilder: (_, _) => const Gap(8),
|
||||||
|
),
|
||||||
),
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
loading: () => const Center(child: CircularProgressIndicator()),
|
loading: () => const Center(child: CircularProgressIndicator()),
|
||||||
error:
|
error: (e, _) => ResponseErrorWidget(
|
||||||
(e, _) => ResponseErrorWidget(
|
error: e,
|
||||||
error: e,
|
onRetry: () => ref.invalidate(realmsJoinedProvider),
|
||||||
onRetry: () => ref.invalidate(realmsJoinedProvider),
|
),
|
||||||
),
|
|
||||||
),
|
),
|
||||||
onRefresh: () => ref.refresh(realmsJoinedProvider.future),
|
onRefresh: () => ref.refresh(realmsJoinedProvider.future),
|
||||||
),
|
),
|
||||||
@@ -183,57 +182,49 @@ class _RealmInviteSheet extends HookConsumerWidget {
|
|||||||
),
|
),
|
||||||
],
|
],
|
||||||
child: invites.when(
|
child: invites.when(
|
||||||
data:
|
data: (items) => items.isEmpty
|
||||||
(items) =>
|
? Center(
|
||||||
items.isEmpty
|
child: Text('invitesEmpty', textAlign: TextAlign.center).tr(),
|
||||||
? Center(
|
)
|
||||||
child:
|
: ListView.builder(
|
||||||
Text(
|
shrinkWrap: true,
|
||||||
'invitesEmpty',
|
itemCount: items.length,
|
||||||
textAlign: TextAlign.center,
|
itemBuilder: (context, index) {
|
||||||
).tr(),
|
final invite = items[index];
|
||||||
)
|
return ListTile(
|
||||||
: ListView.builder(
|
leading: ProfilePictureWidget(
|
||||||
shrinkWrap: true,
|
fileId: invite.realm!.picture?.id,
|
||||||
itemCount: items.length,
|
fallbackIcon: Symbols.group,
|
||||||
itemBuilder: (context, index) {
|
|
||||||
final invite = items[index];
|
|
||||||
return ListTile(
|
|
||||||
leading: ProfilePictureWidget(
|
|
||||||
fileId: invite.realm!.picture?.id,
|
|
||||||
fallbackIcon: Symbols.group,
|
|
||||||
),
|
|
||||||
title: Text(invite.realm!.name),
|
|
||||||
subtitle:
|
|
||||||
Text(
|
|
||||||
invite.role >= 100
|
|
||||||
? 'permissionOwner'
|
|
||||||
: invite.role >= 50
|
|
||||||
? 'permissionModerator'
|
|
||||||
: 'permissionMember',
|
|
||||||
).tr(),
|
|
||||||
trailing: Row(
|
|
||||||
mainAxisSize: MainAxisSize.min,
|
|
||||||
children: [
|
|
||||||
IconButton(
|
|
||||||
icon: const Icon(Symbols.check),
|
|
||||||
onPressed: () => acceptInvite(invite),
|
|
||||||
),
|
|
||||||
IconButton(
|
|
||||||
icon: const Icon(Symbols.close),
|
|
||||||
onPressed: () => declineInvite(invite),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
);
|
|
||||||
},
|
|
||||||
),
|
),
|
||||||
|
title: Text(invite.realm!.name),
|
||||||
|
subtitle: Text(
|
||||||
|
invite.role >= 100
|
||||||
|
? 'permissionOwner'
|
||||||
|
: invite.role >= 50
|
||||||
|
? 'permissionModerator'
|
||||||
|
: 'permissionMember',
|
||||||
|
).tr(),
|
||||||
|
trailing: Row(
|
||||||
|
mainAxisSize: MainAxisSize.min,
|
||||||
|
children: [
|
||||||
|
IconButton(
|
||||||
|
icon: const Icon(Symbols.check),
|
||||||
|
onPressed: () => acceptInvite(invite),
|
||||||
|
),
|
||||||
|
IconButton(
|
||||||
|
icon: const Icon(Symbols.close),
|
||||||
|
onPressed: () => declineInvite(invite),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
);
|
||||||
|
},
|
||||||
|
),
|
||||||
loading: () => const Center(child: CircularProgressIndicator()),
|
loading: () => const Center(child: CircularProgressIndicator()),
|
||||||
error:
|
error: (error, _) => ResponseErrorWidget(
|
||||||
(error, _) => ResponseErrorWidget(
|
error: error,
|
||||||
error: error,
|
onRetry: () => ref.invalidate(realmInvitesProvider),
|
||||||
onRetry: () => ref.invalidate(realmInvitesProvider),
|
),
|
||||||
),
|
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user