mirror of
https://gitlab.com/veilid/veilidchat.git
synced 2025-07-29 17:28:48 -04:00
widget work
This commit is contained in:
parent
c08878b35a
commit
f06657d700
6 changed files with 134 additions and 50 deletions
|
@ -1,63 +1,32 @@
|
|||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/widgets.dart';
|
||||
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
import 'package:window_manager/window_manager.dart';
|
||||
import 'package:user_profile_avatar/user_profile_avatar.dart';
|
||||
import 'package:circular_profile_avatar/circular_profile_avatar.dart';
|
||||
import 'package:badges/badges.dart';
|
||||
|
||||
import '../providers/local_accounts.dart';
|
||||
import '../entities/local_account.dart';
|
||||
import '../providers/logins.dart';
|
||||
|
||||
class AccountBubble extends ConsumerWidget {
|
||||
const AccountBubble({super.key});
|
||||
final LocalAccount account;
|
||||
|
||||
void _onReorder(WidgetRef ref, int oldIndex, int newIndex) {
|
||||
final accounts = ref.read(localAccountsProvider.notifier);
|
||||
accounts.reorderAccount(oldIndex, newIndex);
|
||||
// xxx fix this so we can await this properly, use FutureBuilder or whatever
|
||||
}
|
||||
const AccountBubble({super.key, required this.account});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context, WidgetRef ref) {
|
||||
windowManager.setTitleBarStyle(TitleBarStyle.normal);
|
||||
final accounts = ref.watch(localAccountsProvider);
|
||||
final logins = ref.watch(loginsProvider);
|
||||
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
centerTitle: true,
|
||||
title: const Text('Accounts'),
|
||||
actions: <Widget>[
|
||||
IconButton(
|
||||
icon: const Icon(Icons.settings),
|
||||
tooltip: 'Accessibility',
|
||||
onPressed: () {
|
||||
ScaffoldMessenger.of(context).showSnackBar(const SnackBar(
|
||||
content:
|
||||
Text('Accessibility and language options coming soon')));
|
||||
},
|
||||
),
|
||||
],
|
||||
),
|
||||
body: Center(
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
children: [
|
||||
const Spacer(),
|
||||
accounts.when(
|
||||
error: (obj, err) => Text("error loading accounts: $err"),
|
||||
loading: () => CircularProgressIndicator(),
|
||||
data: (accountList) => ReorderableGridView.extent(
|
||||
maxCrossAxisExtent: 128,
|
||||
onReorder: (oldIndex, newIndex) =>
|
||||
_onReorder(ref, oldIndex, newIndex),
|
||||
children: accountList.map((account) {
|
||||
return AccountBubble(account);
|
||||
}),
|
||||
)),
|
||||
const Spacer(),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
return ConstrainedBox(
|
||||
constraints: const BoxConstraints(maxHeight: 300),
|
||||
child: Column(mainAxisAlignment: MainAxisAlignment.center, children: [
|
||||
Expanded(
|
||||
flex: 4,
|
||||
child: CircularProfileAvatar("",
|
||||
child: Container(color: Theme.of(context).disabledColor))),
|
||||
Expanded(flex: 1, child: Text("Placeholder"))
|
||||
]));
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue