Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tweak broadcast game screen ui #1197

Merged
merged 2 commits into from
Dec 2, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 42 additions & 7 deletions lib/src/view/broadcast/broadcast_game_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -314,7 +314,7 @@ class _PlayerWidget extends ConsumerWidget {
final BroadcastGameId gameId;
final double width;
final _PlayerWidgetPosition widgetPosition;
final BorderRadiusGeometry? borderRadius;
final BorderRadius? borderRadius;

@override
Widget build(BuildContext context, WidgetRef ref) {
Expand Down Expand Up @@ -345,8 +345,10 @@ class _PlayerWidget extends ConsumerWidget {
if (game.isOver)
Card(
margin: EdgeInsets.zero,
shape: RoundedRectangleBorder(
borderRadius: borderRadius ?? BorderRadius.zero,
shape: _makePlayerWidgetBorder(
widgetPosition: widgetPosition,
borderRadius: borderRadius,
hasLeftBorderRadius: true,
),
child: Padding(
padding: const EdgeInsets.symmetric(
Expand All @@ -371,8 +373,11 @@ class _PlayerWidget extends ConsumerWidget {
Expanded(
child: Card(
margin: EdgeInsets.zero,
shape: RoundedRectangleBorder(
borderRadius: borderRadius ?? BorderRadius.zero,
shape: _makePlayerWidgetBorder(
widgetPosition: widgetPosition,
borderRadius: borderRadius,
hasLeftBorderRadius: !game.isOver,
hasRightBorderRadius: clock == null,
),
child: Padding(
padding:
Expand Down Expand Up @@ -437,8 +442,10 @@ class _PlayerWidget extends ConsumerWidget {
: Theme.of(context).colorScheme.secondaryContainer
: null,
margin: EdgeInsets.zero,
shape: RoundedRectangleBorder(
borderRadius: borderRadius ?? BorderRadius.zero,
shape: _makePlayerWidgetBorder(
widgetPosition: widgetPosition,
borderRadius: borderRadius,
hasRightBorderRadius: true,
),
child: Padding(
padding:
Expand Down Expand Up @@ -495,3 +502,31 @@ class _Clock extends StatelessWidget {
);
}
}

ShapeBorder _makePlayerWidgetBorder({
required BorderRadius? borderRadius,
required _PlayerWidgetPosition widgetPosition,
bool hasLeftBorderRadius = false,
bool hasRightBorderRadius = false,
}) {
if (borderRadius == null) return const Border();

if (!hasLeftBorderRadius && !hasRightBorderRadius) return const Border();

return RoundedRectangleBorder(
borderRadius: switch (widgetPosition) {
_PlayerWidgetPosition.top => borderRadius.copyWith(
topLeft: hasLeftBorderRadius ? null : Radius.zero,
topRight: hasRightBorderRadius ? null : Radius.zero,
bottomLeft: Radius.zero,
bottomRight: Radius.zero,
),
_PlayerWidgetPosition.bottom => borderRadius.copyWith(
topLeft: Radius.zero,
topRight: Radius.zero,
bottomLeft: hasLeftBorderRadius ? null : Radius.zero,
bottomRight: hasRightBorderRadius ? null : Radius.zero,
),
},
);
}