new UI + new targets.
This commit is contained in:
@@ -3,12 +3,14 @@ class Contact {
|
||||
final String lastName;
|
||||
final String phone;
|
||||
final String email;
|
||||
final String role; // "predsednik", "članica" …; empty when the club data has none
|
||||
|
||||
const Contact({
|
||||
required this.firstName,
|
||||
required this.lastName,
|
||||
required this.phone,
|
||||
required this.email,
|
||||
this.role = '',
|
||||
});
|
||||
|
||||
String get fullName => '$firstName $lastName';
|
||||
@@ -18,5 +20,6 @@ class Contact {
|
||||
lastName: json['lastName'] ?? '',
|
||||
phone: json['phone'] ?? '',
|
||||
email: json['email'] ?? '',
|
||||
role: json['role'] ?? '',
|
||||
);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,96 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
/// A holiday look (FigCraft Designs/holiday-themes/v2, themes.json): while a
|
||||
/// holiday's window is on, the app shows its background, its target (locked)
|
||||
/// and its hit colour (until the user picks another one). Afterwards everything
|
||||
/// is back to the user's own settings. Saved targets are never changed.
|
||||
class HolidayTheme {
|
||||
final String id; // "01" … "10"; "00" is the everyday look
|
||||
final String name; // Slovenian name, also shown in the app
|
||||
final int targetId; // TargetStyle id (70–79)
|
||||
final Color color; // hit colour, the same in dark and light
|
||||
// Window: month-day range (inclusive, may cross the new year) …
|
||||
final (int, int)? from;
|
||||
final (int, int)? to;
|
||||
// … or days relative to Easter Sunday (inclusive)
|
||||
final (int, int)? easter;
|
||||
|
||||
const HolidayTheme(this.id, this.name, this.targetId, this.color, {this.from, this.to, this.easter});
|
||||
|
||||
String background(bool dark) => 'assets/backgrounds/bg${id}_${dark ? 'dark' : 'light'}.webp';
|
||||
|
||||
/// In the order of themes.json: when windows overlap, the first one wins.
|
||||
static const List<HolidayTheme> all = [
|
||||
HolidayTheme('01', 'Božič', 70, Color(0xFFF2C12E), from: (12, 1), to: (12, 26)),
|
||||
HolidayTheme('02', 'Novo leto', 71, Color(0xFF2EC7FF), from: (12, 27), to: (1, 2)),
|
||||
HolidayTheme('03', 'Valentinovo', 73, Color(0xFFFFD27A), from: (2, 12), to: (2, 15)),
|
||||
HolidayTheme('04', 'Pust', 75, Color(0xFFFF2F6D), easter: (-52, -46)),
|
||||
HolidayTheme('05', 'Velika noč', 72, Color(0xFFFF8A1A), easter: (-7, 1)),
|
||||
HolidayTheme('06', 'Praznik dela', 77, Color(0xFF2F8CFF), from: (4, 30), to: (5, 2)),
|
||||
HolidayTheme('07', 'Kresna noč', 78, Color(0xFF7FE0FF), from: (6, 21), to: (6, 23)),
|
||||
HolidayTheme('08', 'Dan državnosti', 79, Color(0xFFF2C12E), from: (6, 24), to: (6, 26)),
|
||||
HolidayTheme('09', 'Noč čarovnic', 74, Color(0xFF7CFF6B), from: (10, 25), to: (11, 1)),
|
||||
HolidayTheme('10', 'Martinovo', 76, Color(0xFF2EC7FF), from: (11, 8), to: (11, 11)),
|
||||
];
|
||||
|
||||
/// The holiday on [day], or null on an ordinary day.
|
||||
static HolidayTheme? on(DateTime day) {
|
||||
final d = DateTime(day.year, day.month, day.day);
|
||||
for (final h in all) {
|
||||
if (h.covers(d)) return h;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
bool covers(DateTime d) {
|
||||
final e = easter;
|
||||
if (e != null) {
|
||||
final first = easterDay(d.year, e.$1);
|
||||
final last = easterDay(d.year, e.$2);
|
||||
return !d.isBefore(first) && !d.isAfter(last);
|
||||
}
|
||||
final md = d.month * 100 + d.day;
|
||||
final a = from!.$1 * 100 + from!.$2;
|
||||
final b = to!.$1 * 100 + to!.$2;
|
||||
return a <= b ? md >= a && md <= b : md >= a || md <= b; // crosses the new year
|
||||
}
|
||||
|
||||
/// First and last day of this holiday's window around [today] (for "until …").
|
||||
(DateTime, DateTime) window(DateTime today) {
|
||||
final e = easter;
|
||||
if (e != null) {
|
||||
return (easterDay(today.year, e.$1), easterDay(today.year, e.$2));
|
||||
}
|
||||
final crosses = from!.$1 * 100 + from!.$2 > to!.$1 * 100 + to!.$2;
|
||||
final startYear = crosses && today.month <= to!.$1 ? today.year - 1 : today.year;
|
||||
final start = DateTime(startYear, from!.$1, from!.$2);
|
||||
final end = DateTime(crosses ? startYear + 1 : startYear, to!.$1, to!.$2);
|
||||
return (start, end);
|
||||
}
|
||||
|
||||
/// The day [offset] days from Easter Sunday. Calendar days, not 24-hour
|
||||
/// steps: those would land on the evening before across the March clock change.
|
||||
static DateTime easterDay(int year, int offset) {
|
||||
final e = easterSunday(year);
|
||||
return DateTime(e.year, e.month, e.day + offset);
|
||||
}
|
||||
|
||||
/// Easter Sunday (anonymous Gregorian algorithm).
|
||||
static DateTime easterSunday(int year) {
|
||||
final a = year % 19;
|
||||
final b = year ~/ 100;
|
||||
final c = year % 100;
|
||||
final d = b ~/ 4;
|
||||
final e = b % 4;
|
||||
final f = (b + 8) ~/ 25;
|
||||
final g = (b - f + 1) ~/ 3;
|
||||
final h = (19 * a + b - d - g + 15) % 30;
|
||||
final i = c ~/ 4;
|
||||
final k = c % 4;
|
||||
final l = (32 + 2 * e + 2 * i - h - k) % 7;
|
||||
final m = (a + 11 * h + 22 * l) ~/ 451;
|
||||
final month = (h + l - 7 * m + 114) ~/ 31;
|
||||
final day = (h + l - 7 * m + 114) % 31 + 1;
|
||||
return DateTime(year, month, day);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,66 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
/// Where a target design comes from (only used to order and group the picker).
|
||||
enum TargetGroup { classic, design, holiday }
|
||||
|
||||
/// One target design of the v3 set (FigCraft Designs/target-designs/v3).
|
||||
///
|
||||
/// Every design has the same geometry in a 1200 × 1200 space: centre
|
||||
/// (600, 600), ring 1 at r 510, the black at r 180; decoration and glow only
|
||||
/// outside ring 1. Hits are stored in that space, so a hit lands on the same
|
||||
/// ring whatever design is picked. The default ([id] 0) is drawn as vectors
|
||||
/// (sharp at any zoom); the others are 1600 px WebP images with transparency.
|
||||
class TargetStyle {
|
||||
final int id; // 1–35 are the old Target<id>.jpg, so saved choices carry over
|
||||
final String sl;
|
||||
final String en;
|
||||
final String de;
|
||||
final TargetGroup group;
|
||||
final Color glow; // outer glow colour, used for the picker's selection ring
|
||||
|
||||
const TargetStyle(this.id, this.sl, this.en, this.de, this.group, this.glow);
|
||||
|
||||
bool get isDefault => id == 0;
|
||||
bool get isHoliday => group == TargetGroup.holiday;
|
||||
|
||||
/// Image asset; null for the vector default.
|
||||
String? get asset => isDefault ? null : 'assets/targets/v3/t${id.toString().padLeft(2, '0')}.webp';
|
||||
|
||||
String name(String language) => switch (language) {
|
||||
'Slovenian' => sl,
|
||||
'German' => de,
|
||||
_ => en,
|
||||
};
|
||||
|
||||
static const TargetStyle fallback = TargetStyle(0, 'Privzeta', 'Default', 'Standard', TargetGroup.classic, Color(0xFF9FD8FF));
|
||||
|
||||
static TargetStyle byId(int? id) =>
|
||||
[...all, ...holidays].firstWhere((t) => t.id == id, orElse: () => fallback);
|
||||
|
||||
/// Holiday targets: never in the picker, only shown (locked) during their
|
||||
/// holiday – see HolidayTheme.
|
||||
static const List<TargetStyle> holidays = [
|
||||
TargetStyle(70, 'Božič', 'Christmas', 'Weihnachten', TargetGroup.holiday, Color(0xFFE2231A)),
|
||||
TargetStyle(71, 'Novo leto', 'New Year', 'Neujahr', TargetGroup.holiday, Color(0xFF7A2CFF)),
|
||||
TargetStyle(72, 'Velika noč', 'Easter', 'Ostern', TargetGroup.holiday, Color(0xFFB6E86E)),
|
||||
TargetStyle(73, 'Valentinovo', 'Valentine\'s Day', 'Valentinstag', TargetGroup.holiday, Color(0xFFE2112F)),
|
||||
TargetStyle(74, 'Noč čarovnic', 'Halloween', 'Halloween', TargetGroup.holiday, Color(0xFF7A2CFF)),
|
||||
TargetStyle(75, 'Pust', 'Carnival', 'Fasching', TargetGroup.holiday, Color(0xFFFF2F6D)),
|
||||
TargetStyle(76, 'Martinovo', 'St Martin\'s Day', 'Martinstag', TargetGroup.holiday, Color(0xFF7A1E4A)),
|
||||
TargetStyle(77, 'Praznik dela', 'Labour Day', 'Tag der Arbeit', TargetGroup.holiday, Color(0xFFE2231A)),
|
||||
TargetStyle(78, 'Kresna noč', 'Midsummer night', 'Johannisnacht', TargetGroup.holiday, Color(0xFFFF3D00)),
|
||||
TargetStyle(79, 'Dan državnosti', 'Statehood Day', 'Staatsfeiertag', TargetGroup.holiday, Color(0xFF1C4FA0)),
|
||||
];
|
||||
|
||||
/// The designs the app ships, in picker order. The rest of the v3 set
|
||||
/// (FigCraft Designs/target-designs/v3) is not used for now; to bring one
|
||||
/// back, add its line here and its webp to assets/targets/v3.
|
||||
static const List<TargetStyle> all = [
|
||||
fallback,
|
||||
TargetStyle(1, 'Lovorov venec', 'Laurel wreath', 'Lorbeerkranz', TargetGroup.classic, Color(0xFF3E8A1E)),
|
||||
TargetStyle(42, 'ISSF ecru', 'ISSF ecru', 'ISSF Ecru', TargetGroup.design, Color(0xFFE8D9B0)),
|
||||
TargetStyle(5, 'Plameni', 'Flames', 'Flammen', TargetGroup.classic, Color(0xFFFF3D00)),
|
||||
TargetStyle(8, 'Val', 'Wave', 'Welle', TargetGroup.classic, Color(0xFF0B8BD9)),
|
||||
TargetStyle(7, 'Sončno rumena', 'Sunny yellow', 'Sonnengelb', TargetGroup.classic, Color(0xFFFFA000)),
|
||||
];
|
||||
}
|
||||
Reference in New Issue
Block a user