Browse Source

Merge pull request #55 from jld3103/fix/multi-account-text-color

neon: Fix multi-account text color
pull/56/head
jld3103 2 years ago committed by GitHub
parent
commit
e1e953307d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 5
      packages/neon/lib/src/pages/home/home.dart
  2. 45
      packages/neon/lib/src/widgets/account_tile.dart

5
packages/neon/lib/src/pages/home/home.dart

@ -378,7 +378,9 @@ class _HomePageState extends State<HomePage> with tray.TrayListener, WindowListe
if (accounts.length > 1) ...[
Text(
account.client.humanReadableID,
style: Theme.of(context).textTheme.bodySmall,
style: Theme.of(context).textTheme.bodySmall!.copyWith(
color: Theme.of(context).colorScheme.onPrimary,
),
),
],
],
@ -478,6 +480,7 @@ class _HomePageState extends State<HomePage> with tray.TrayListener, WindowListe
child: AccountTile(
account: account,
dense: true,
textColor: Theme.of(context).colorScheme.onPrimary,
),
),
)

45
packages/neon/lib/src/widgets/account_tile.dart

@ -1,11 +1,12 @@
part of '../neon.dart';
class AccountTile extends StatefulWidget {
class AccountTile extends StatelessWidget {
const AccountTile({
required this.account,
this.color,
this.trailing,
this.onTap,
this.textColor,
this.dense = false,
super.key,
});
@ -14,39 +15,30 @@ class AccountTile extends StatefulWidget {
final Color? color;
final Widget? trailing;
final VoidCallback? onTap;
final Color? textColor;
final bool dense;
@override
State<AccountTile> createState() => _AccountTileState();
}
class _AccountTileState extends State<AccountTile> {
late final UserDetailsBloc _userDetailsBloc;
@override
void initState() {
super.initState();
Widget build(final BuildContext context) {
final userDetailsBloc = RxBlocProvider.of<AccountsBloc>(context).getUserDetailsBloc(account);
_userDetailsBloc = RxBlocProvider.of<AccountsBloc>(context).getUserDetailsBloc(widget.account);
}
@override
Widget build(final BuildContext context) => ListTile(
onTap: widget.onTap,
dense: widget.dense,
contentPadding: widget.dense ? EdgeInsets.zero : null,
visualDensity: widget.dense
return ListTile(
textColor: textColor,
onTap: onTap,
dense: dense,
contentPadding: dense ? EdgeInsets.zero : null,
visualDensity: dense
? const VisualDensity(
horizontal: -4,
vertical: -4,
)
: null,
leading: AccountAvatar(
account: widget.account,
account: account,
requestManager: Provider.of<RequestManager>(context),
),
title: StandardRxResultBuilder<UserDetailsBloc, ProvisioningApiUserDetails>(
bloc: _userDetailsBloc,
bloc: userDetailsBloc,
state: (final bloc) => bloc.userDetails,
builder: (
final context,
@ -61,7 +53,7 @@ class _AccountTileState extends State<AccountTile> {
Text(
userDetailsData.getDisplayName()!,
style: Theme.of(context).textTheme.bodyLarge!.copyWith(
color: widget.color,
color: textColor,
),
),
],
@ -74,7 +66,7 @@ class _AccountTileState extends State<AccountTile> {
width: 10,
child: CircularProgressIndicator(
strokeWidth: 1,
color: widget.color,
color: color,
),
),
],
@ -85,17 +77,18 @@ class _AccountTileState extends State<AccountTile> {
Icon(
Icons.error_outline,
size: 20,
color: widget.color,
color: color,
),
],
],
),
),
subtitle: Text(
widget.account.client.humanReadableID,
account.client.humanReadableID,
style: Theme.of(context).textTheme.bodySmall!.copyWith(
color: widget.color,
color: textColor,
),
),
);
}
}

Loading…
Cancel
Save