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. 147
      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,
), ),
), ),
) )

147
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,88 +15,80 @@ 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);
}
@override return ListTile(
Widget build(final BuildContext context) => ListTile( textColor: textColor,
onTap: widget.onTap, onTap: onTap,
dense: widget.dense, dense: dense,
contentPadding: widget.dense ? EdgeInsets.zero : null, contentPadding: dense ? EdgeInsets.zero : null,
visualDensity: widget.dense visualDensity: 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,
final userDetailsData, final userDetailsData,
final userDetailsError, final userDetailsError,
final userDetailsLoading, final userDetailsLoading,
final _, final _,
) => ) =>
Row( Row(
children: [ children: [
if (userDetailsData != null) ...[ if (userDetailsData != null) ...[
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,
), ),
), ),
], ],
if (userDetailsLoading) ...[ if (userDetailsLoading) ...[
const SizedBox( const SizedBox(
width: 5, width: 5,
), ),
SizedBox( SizedBox(
height: 10, height: 10,
width: 10, width: 10,
child: CircularProgressIndicator( child: CircularProgressIndicator(
strokeWidth: 1, strokeWidth: 1,
color: widget.color, color: color,
),
),
],
if (userDetailsError != null) ...[
const SizedBox(
width: 5,
),
Icon(
Icons.error_outline,
size: 20,
color: widget.color,
), ),
], ),
], ],
), if (userDetailsError != null) ...[
), const SizedBox(
subtitle: Text( width: 5,
widget.account.client.humanReadableID, ),
style: Theme.of(context).textTheme.bodySmall!.copyWith( Icon(
color: widget.color, Icons.error_outline,
size: 20,
color: color,
), ),
],
],
), ),
); ),
subtitle: Text(
account.client.humanReadableID,
style: Theme.of(context).textTheme.bodySmall!.copyWith(
color: textColor,
),
),
);
}
} }

Loading…
Cancel
Save