Browse Source

neon: Fix multi-account text color

pull/55/head
jld3103 2 years ago
parent
commit
e55185897a
No known key found for this signature in database
GPG Key ID: 9062417B9E8EB7B3
  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) ...[ if (accounts.length > 1) ...[
Text( Text(
account.client.humanReadableID, 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( child: AccountTile(
account: account, account: account,
dense: true, 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'; part of '../neon.dart';
class AccountTile extends StatefulWidget { class AccountTile extends StatelessWidget {
const AccountTile({ const AccountTile({
required this.account, required this.account,
this.color, this.color,
this.trailing, this.trailing,
this.onTap, this.onTap,
this.textColor,
this.dense = false, this.dense = false,
super.key, super.key,
}); });
@ -14,39 +15,30 @@ class AccountTile extends StatefulWidget {
final Color? color; final Color? color;
final Widget? trailing; final Widget? trailing;
final VoidCallback? onTap; final VoidCallback? onTap;
final Color? textColor;
final bool dense; final bool dense;
@override @override
State<AccountTile> createState() => _AccountTileState(); Widget build(final BuildContext context) {
} final userDetailsBloc = RxBlocProvider.of<AccountsBloc>(context).getUserDetailsBloc(account);
class _AccountTileState extends State<AccountTile> {
late final UserDetailsBloc _userDetailsBloc;
@override
void initState() {
super.initState();
_userDetailsBloc = RxBlocProvider.of<AccountsBloc>(context).getUserDetailsBloc(widget.account); return ListTile(
} textColor: textColor,
onTap: onTap,
@override dense: dense,
Widget build(final BuildContext context) => ListTile( contentPadding: dense ? EdgeInsets.zero : null,
onTap: widget.onTap, visualDensity: dense
dense: widget.dense,
contentPadding: widget.dense ? EdgeInsets.zero : null,
visualDensity: widget.dense
? const VisualDensity( ? const VisualDensity(
horizontal: -4, horizontal: -4,
vertical: -4, vertical: -4,
) )
: null, : null,
leading: AccountAvatar( leading: AccountAvatar(
account: widget.account, account: account,
requestManager: Provider.of<RequestManager>(context), requestManager: Provider.of<RequestManager>(context),
), ),
title: StandardRxResultBuilder<UserDetailsBloc, ProvisioningApiUserDetails>( title: StandardRxResultBuilder<UserDetailsBloc, ProvisioningApiUserDetails>(
bloc: _userDetailsBloc, bloc: userDetailsBloc,
state: (final bloc) => bloc.userDetails, state: (final bloc) => bloc.userDetails,
builder: ( builder: (
final context, final context,
@ -61,7 +53,7 @@ class _AccountTileState extends State<AccountTile> {
Text( Text(
userDetailsData.getDisplayName()!, userDetailsData.getDisplayName()!,
style: Theme.of(context).textTheme.bodyLarge!.copyWith( style: Theme.of(context).textTheme.bodyLarge!.copyWith(
color: widget.color, color: textColor,
), ),
), ),
], ],
@ -74,7 +66,7 @@ class _AccountTileState extends State<AccountTile> {
width: 10, width: 10,
child: CircularProgressIndicator( child: CircularProgressIndicator(
strokeWidth: 1, strokeWidth: 1,
color: widget.color, color: color,
), ),
), ),
], ],
@ -85,17 +77,18 @@ class _AccountTileState extends State<AccountTile> {
Icon( Icon(
Icons.error_outline, Icons.error_outline,
size: 20, size: 20,
color: widget.color, color: color,
), ),
], ],
], ],
), ),
), ),
subtitle: Text( subtitle: Text(
widget.account.client.humanReadableID, account.client.humanReadableID,
style: Theme.of(context).textTheme.bodySmall!.copyWith( style: Theme.of(context).textTheme.bodySmall!.copyWith(
color: widget.color, color: textColor,
), ),
), ),
); );
} }
}

Loading…
Cancel
Save