Skip to content
Merged
Show file tree
Hide file tree
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
57 changes: 46 additions & 11 deletions lib/src/view/clock/clock_tool_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ class ClockTile extends ConsumerWidget {
}
: null,
child: Padding(
padding: const EdgeInsets.all(40),
padding: const EdgeInsets.all(48),
child: Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
mainAxisSize: MainAxisSize.max,
Expand All @@ -139,16 +139,10 @@ class ClockTile extends ConsumerWidget {
FittedBox(
child: AnimatedCrossFade(
duration: const Duration(milliseconds: 300),
firstChild: ValueListenableBuilder(
valueListenable: clockState.getDuration(playerType),
builder: (context, value, _) {
return Clock(
padLeft: true,
clockStyle: clockStyle,
timeLeft: value,
active: clockState.isActivePlayer(playerType),
);
},
firstChild: _ClockDisplay(
clockState: clockState,
playerType: playerType,
clockStyle: clockStyle,
),
secondChild: const Icon(Icons.flag),
crossFadeState:
Expand Down Expand Up @@ -176,6 +170,19 @@ class ClockTile extends ConsumerWidget {
),
),
),
if (orientation == Orientation.portrait)
Positioned(
top: 24,
left: 24,
child: RotatedBox(
quarterTurns: 2,
child: _ClockDisplay(
clockState: clockState,
playerType: playerType,
clockStyle: clockStyle,
),
),
),
Positioned(
bottom: MediaQuery.paddingOf(context).bottom + 48.0,
child: AnimatedOpacity(
Expand Down Expand Up @@ -220,3 +227,31 @@ class ClockTile extends ConsumerWidget {
);
}
}

class _ClockDisplay extends StatelessWidget {
const _ClockDisplay({
required this.clockState,
required this.playerType,
required this.clockStyle,
});

final ClockState clockState;
final Side playerType;
final ClockStyle clockStyle;

@override
Widget build(BuildContext context) {
return ValueListenableBuilder(
valueListenable: clockState.getDuration(playerType),
builder: (context, value, _) {
return Clock(
padLeft: true,
clockStyle: clockStyle,
timeLeft: value,
active: clockState.isActivePlayer(playerType),
padding: EdgeInsets.zero,
);
},
);
}
}
6 changes: 5 additions & 1 deletion lib/src/widgets/clock.dart
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ class Clock extends StatelessWidget {
this.clockStyle,
this.emergencyThreshold,
this.padLeft = false,
this.padding = const EdgeInsets.symmetric(vertical: 3.0, horizontal: 5.0),
super.key,
});

Expand All @@ -40,6 +41,9 @@ class Clock extends StatelessWidget {
/// Whether to pad with a leading zero (default is `false`).
final bool padLeft;

/// Padding around the clock.
final EdgeInsets padding;

@override
Widget build(BuildContext context) {
final hours = timeLeft.inHours;
Expand Down Expand Up @@ -72,7 +76,7 @@ class Clock extends StatelessWidget {
: effectiveClockStyle.backgroundColor,
),
child: Padding(
padding: const EdgeInsets.symmetric(vertical: 3.0, horizontal: 5.0),
padding: padding,
child: MediaQuery.withClampedTextScaling(
maxScaleFactor: kMaxClockTextScaleFactor,
child: RichText(
Expand Down