UI fixes and league

This commit is contained in:
Jan Pleterski
2026-11-28 12:22:02 +01:00
parent 2fc741a9f6
commit 258303deb8
118 changed files with 1439 additions and 537 deletions
+41 -61
View File
@@ -321,11 +321,47 @@ class AppTheme {
);
}
/// The screen background of the design (holiday-themes/v2, "ozadje"): the
/// everyday one in dark or light, or the current holiday's.
/// The screen background, in dark or light: the current holiday's
/// (holiday-themes/v3) for the whole app, otherwise the everyday "00 Privzeto".
/// [target]: the target screens' background instead, the picked target's own
/// (target-backgrounds/v2) unless a holiday is on; those screens wrap
/// themselves in it, over the page's everyday one.
/// The target's window on a target screen: the band the target backgrounds
/// (target-backgrounds/v3, drawn for a 390 × 844 screen and shown with
/// BoxFit.cover, see [AppBackground]) leave for it, between the line under
/// the header and the line over the tiles and buttons. Put it in a [Stack]
/// that fills the screen; the page's other parts go above and below it.
class TargetWindow extends StatelessWidget {
final Widget child;
const TargetWindow({super.key, required this.child});
static const double _bgWidth = 390, _bgHeight = 844;
static const double _top = 186.5, _bottom = 659;
/// Where the two lines are on a screen of [size]: (y of the upper, y of the lower).
static (double, double) lines(Size size) {
final k = size.width / _bgWidth > size.height / _bgHeight ? size.width / _bgWidth : size.height / _bgHeight;
final dy = (size.height - _bgHeight * k) / 2;
return (dy + _top * k, dy + _bottom * k);
}
@override
Widget build(BuildContext context) {
return Positioned.fill(
child: LayoutBuilder(builder: (context, box) {
final (top, bottom) = lines(box.biggest);
return Stack(children: [
Positioned(left: 0, right: 0, top: top, height: bottom - top, child: child),
]);
}),
);
}
}
class AppBackground extends StatelessWidget {
final Widget child;
const AppBackground({super.key, required this.child});
final bool target;
const AppBackground({super.key, required this.child, this.target = false});
@override
Widget build(BuildContext context) {
@@ -337,12 +373,8 @@ class AppBackground extends StatelessWidget {
fit: StackFit.expand,
children: [
ColoredBox(color: s.palette.bg),
// Holidays have their drawn backgrounds; the everyday one is
// painted here, cleaner than the design's busier image
if (s.holiday != null)
Image.asset(s.background, fit: BoxFit.cover, gaplessPlayback: true, filterQuality: FilterQuality.medium)
else
CustomPaint(painter: _EverydayBackground(dark: s.isDark)),
Image.asset(target ? s.targetBackground : s.background,
fit: BoxFit.cover, gaplessPlayback: true, filterQuality: FilterQuality.medium),
child!,
],
);
@@ -373,55 +405,3 @@ class _BackgroundTransitions extends PageTransitionsBuilder {
inner.buildTransitions(route, context, animation, secondaryAnimation, AppBackground(child: child));
}
/// The everyday background ("00 Privzeto", holiday-themes/v2) in a calmer
/// version: the same gradient and two corners of target rings, but three
/// widely spaced, faint rings per corner and a few fine dots.
class _EverydayBackground extends CustomPainter {
final bool dark;
const _EverydayBackground({required this.dark});
@override
void paint(Canvas canvas, Size size) {
final rect = Offset.zero & size;
canvas.drawRect(
rect,
Paint()
..shader = LinearGradient(
begin: Alignment.topCenter,
end: Alignment.bottomCenter,
colors: dark ? const [Color(0xFF15191C), Color(0xFF0B0D0F)] : const [Color(0xFFFAFAF7), Color(0xFFECEDE7)],
).createShader(rect),
);
// Design units: a 390 × 844 screen
final k = size.width / 390;
final ink = dark ? Colors.white : const Color(0xFF16181B);
final ring = Paint()
..style = PaintingStyle.stroke
..isAntiAlias = true;
void rings(Offset c, List<double> radii) {
for (int i = 0; i < radii.length; i++) {
ring
..strokeWidth = (i == radii.length - 1 ? 1.6 : 1.1) * k
..color = ink.withValues(alpha: dark ? (i == radii.length - 1 ? 0.09 : 0.06) : (i == radii.length - 1 ? 0.08 : 0.05));
canvas.drawCircle(c, radii[i] * k, ring);
}
}
rings(Offset(size.width + 40 * k, -30 * k), const [150, 260, 380]);
rings(Offset(-60 * k, size.height + 40 * k), const [140, 250]);
// A few fine dots, always in the same places
final dot = Paint()..color = ink.withValues(alpha: dark ? 0.16 : 0.12);
const spots = [
(0.12, 0.08), (0.78, 0.18), (0.34, 0.31), (0.88, 0.44), (0.07, 0.52),
(0.62, 0.61), (0.25, 0.74), (0.91, 0.83), (0.48, 0.92), (0.70, 0.36),
];
for (int i = 0; i < spots.length; i++) {
final (x, y) = spots[i];
canvas.drawCircle(Offset(x * size.width, y * size.height), (i.isEven ? 1.4 : 1.0) * k, dot);
}
}
@override
bool shouldRepaint(_EverydayBackground old) => old.dark != dark;
}