Skip to content
This repository has been archived by the owner on Sep 9, 2024. It is now read-only.

Commit

Permalink
refactor: reformat
Browse files Browse the repository at this point in the history
  • Loading branch information
Craftplacer committed Dec 31, 2023
1 parent b266e93 commit ee860a9
Showing 1 changed file with 86 additions and 58 deletions.
144 changes: 86 additions & 58 deletions src/kaiteki/lib/ui/user/user_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,10 @@ class _UserScreenState extends ConsumerState<UserScreen> {
),
subtitle: Text(
user.handle.toString(),
style: Theme.of(context).textTheme.labelSmall,
style: Theme
.of(context)
.textTheme
.labelSmall,
),
contentPadding: EdgeInsets.zero,
);
Expand All @@ -84,10 +87,11 @@ class _UserScreenState extends ConsumerState<UserScreen> {
final theme = Theme.of(context);
return FutureBuilder(
future: (user?.bannerUrl ?? user?.avatarUrl)?.nullTransform(
(url) => ColorScheme.fromImageProvider(
provider: NetworkImage(url.toString()),
brightness: theme.brightness,
),
(url) =>
ColorScheme.fromImageProvider(
provider: NetworkImage(url.toString()),
brightness: theme.brightness,
),
),
builder: (context, snapshot) {
return Theme(
Expand All @@ -113,8 +117,14 @@ class _UserScreenState extends ConsumerState<UserScreen> {

Color _getBackgroundColor(BuildContext context) {
return ElevationOverlay.applySurfaceTint(
Theme.of(context).colorScheme.surface,
Theme.of(context).colorScheme.surfaceTint,
Theme
.of(context)
.colorScheme
.surface,
Theme
.of(context)
.colorScheme
.surfaceTint,
2,
);
}
Expand All @@ -136,9 +146,13 @@ class _UserScreenState extends ConsumerState<UserScreen> {
Padding(
padding: const EdgeInsets.all(8.0),
child: IconButton.filledTonal(
onPressed: Navigator.of(context).maybePop,
onPressed: Navigator
.of(context)
.maybePop,
icon: Icon(Icons.adaptive.arrow_back),
tooltip: MaterialLocalizations.of(context).backButtonTooltip,
tooltip: MaterialLocalizations
.of(context)
.backButtonTooltip,
),
),
// https://m3.material.io/foundations/layout/canonical-layouts/supporting-pane#13c3c489-9cc7-4830-b44a-fe6c2d431c1f
Expand Down Expand Up @@ -209,7 +223,10 @@ class _UserScreenState extends ConsumerState<UserScreen> {
child: ClipRRect(
borderRadius: const BorderRadius.all(Radius.circular(16)),
child: ColoredBox(
color: Theme.of(context).colorScheme.surface,
color: Theme
.of(context)
.colorScheme
.surface,
child: Column(
children: [
Material(child: buildTabBar()),
Expand Down Expand Up @@ -248,19 +265,17 @@ class _UserScreenState extends ConsumerState<UserScreen> {
return [
MenuItemButton(
onPressed: user.url.nullTransform(
(url) => () async => share(context, url),
(url) => () async => share(context, url),
),
leadingIcon: Icon(Icons.adaptive.share_rounded),
child: const Text("Share"),
),
];
}

Widget buildBodyCompact(
BuildContext context,
User? user,
bool includeReplies,
) {
Widget buildBodyCompact(BuildContext context,
User? user,
bool includeReplies,) {
final primaryButton = buildPrimaryButton(
user,
);
Expand All @@ -275,17 +290,17 @@ class _UserScreenState extends ConsumerState<UserScreen> {
}) {
return innerBoxIsScrolled
? IconButton(
icon: icon,
onPressed: onPressed,
tooltip: tooltip,
visualDensity: VisualDensity.standard,
)
icon: icon,
onPressed: onPressed,
tooltip: tooltip,
visualDensity: VisualDensity.standard,
)
: IconButton.filledTonal(
icon: icon,
onPressed: onPressed,
tooltip: tooltip,
visualDensity: VisualDensity.standard,
);
icon: icon,
onPressed: onPressed,
tooltip: tooltip,
visualDensity: VisualDensity.standard,
);
}

final moreButton = buildMenuButton(user);
Expand All @@ -295,7 +310,9 @@ class _UserScreenState extends ConsumerState<UserScreen> {
leading: adaptiveIconButton(
icon: Icon(Icons.adaptive.arrow_back),
onPressed: () => Navigator.of(context).maybePop(),
tooltip: MaterialLocalizations.of(context).backButtonTooltip,
tooltip: MaterialLocalizations
.of(context)
.backButtonTooltip,
),
backgroundColor: _getBackgroundColor(context),
scrolledUnderElevation: 0,
Expand Down Expand Up @@ -386,7 +403,9 @@ class _UserScreenState extends ConsumerState<UserScreen> {
FilterChip(
selected: includeReplies,
onSelected: (value) =>
ref.read(_showReplies.notifier).state = value,
ref
.read(_showReplies.notifier)
.state = value,
label: const Text("Replies"),
),
],
Expand Down Expand Up @@ -466,7 +485,7 @@ class _UserScreenState extends ConsumerState<UserScreen> {
break;

case UserFollowState.pending:
// TODO(Craftplacer): Prompt to cancel follow request
// TODO(Craftplacer): Prompt to cancel follow request
break;
}

Expand All @@ -480,7 +499,10 @@ class _UserScreenState extends ConsumerState<UserScreen> {
visualDensity: VisualDensity.comfortable,
);

if (user?.id == ref.watch(currentAccountProvider)?.user.id) {
if (user?.id == ref
.watch(currentAccountProvider)
?.user
.id) {
if (small) {
return IconButton.filled(
onPressed: () {},
Expand All @@ -501,39 +523,42 @@ class _UserScreenState extends ConsumerState<UserScreen> {
Future<void> onPressed() => _onFollow(context, user!);

return switch (followState) {
UserFollowState.following => small
UserFollowState.following =>
small
? IconButton.filledTonal(
onPressed: onPressed,
icon: const Icon(Icons.person_remove_rounded),
tooltip: context.l10n.unfollowButtonLabel,
)
onPressed: onPressed,
icon: const Icon(Icons.person_remove_rounded),
tooltip: context.l10n.unfollowButtonLabel,
)
: FilledButton.tonal(
onPressed: onPressed,
style: comfortableFilledButtonStyle,
child: Text(context.l10n.unfollowButtonLabel),
),
UserFollowState.notFollowing => small
onPressed: onPressed,
style: comfortableFilledButtonStyle,
child: Text(context.l10n.unfollowButtonLabel),
),
UserFollowState.notFollowing =>
small
? IconButton.filled(
onPressed: onPressed,
icon: const Icon(Icons.person_add_rounded),
tooltip: context.l10n.followButtonLabel,
)
onPressed: onPressed,
icon: const Icon(Icons.person_add_rounded),
tooltip: context.l10n.followButtonLabel,
)
: FilledButton(
onPressed: onPressed,
style: comfortableFilledButtonStyle,
child: Text(context.l10n.followButtonLabel),
),
UserFollowState.pending => small
onPressed: onPressed,
style: comfortableFilledButtonStyle,
child: Text(context.l10n.followButtonLabel),
),
UserFollowState.pending =>
small
? IconButton.filled(
onPressed: onPressed,
icon: const Icon(Icons.lock_clock_rounded),
tooltip: context.l10n.pendingFollowRequestButtonLabel,
)
onPressed: onPressed,
icon: const Icon(Icons.lock_clock_rounded),
tooltip: context.l10n.pendingFollowRequestButtonLabel,
)
: FilledButton.tonal(
onPressed: onPressed,
style: comfortableFilledButtonStyle,
child: Text(context.l10n.pendingFollowRequestButtonLabel),
),
onPressed: onPressed,
style: comfortableFilledButtonStyle,
child: Text(context.l10n.pendingFollowRequestButtonLabel),
),
null => null,
};
}
Expand Down Expand Up @@ -604,7 +629,10 @@ class _Banner extends StatelessWidget {
@override
Widget build(BuildContext context) {
final placeholder = ColoredBox(
color: Theme.of(context).colorScheme.surfaceVariant,
color: Theme
.of(context)
.colorScheme
.surfaceVariant,
child: const SizedBox.expand(),
);

Expand Down

0 comments on commit ee860a9

Please sign in to comment.