Compare commits
No commits in common. "c935a202cc46a275adfd8b54ccee65c166e4a46b" and "3bb21c00d677607984c39f53dfa7a06329eaa409" have entirely different histories.
c935a202cc
...
3bb21c00d6
@ -98,7 +98,7 @@ repos:
|
|||||||
additional_dependencies:
|
additional_dependencies:
|
||||||
- pytest
|
- pytest
|
||||||
- requests
|
- requests
|
||||||
- gatelock @ git+https://github.com/kuhyx/utils@gatelock-v0.1.1#subdirectory=gatelock
|
- gatelock @ git+https://github.com/kuhyx/utils@gatelock-v0.1.0#subdirectory=gatelock
|
||||||
- crdt-sync @ git+https://github.com/kuhyx/utils@crdt-sync-v0.1.0#subdirectory=crdt-sync
|
- crdt-sync @ git+https://github.com/kuhyx/utils@crdt-sync-v0.1.0#subdirectory=crdt-sync
|
||||||
- mcp
|
- mcp
|
||||||
- pydantic
|
- pydantic
|
||||||
|
|||||||
26
CLAUDE.md
@ -535,20 +535,15 @@ linter:
|
|||||||
provide an intuitive and easy navigation bar or controls.
|
provide an intuitive and easy navigation bar or controls.
|
||||||
* **Typography:** Stress and emphasize font sizes to ease understanding, e.g.,
|
* **Typography:** Stress and emphasize font sizes to ease understanding, e.g.,
|
||||||
hero text, section headlines, list headlines, keywords in paragraphs.
|
hero text, section headlines, list headlines, keywords in paragraphs.
|
||||||
* **Background:** Keep backgrounds flat and simple — no noise texture or
|
* **Background:** Apply subtle noise texture to the main background to add a
|
||||||
gradients. Follow the `unified-design-system` skill (safe-design-rules
|
premium, tactile feel.
|
||||||
rule 17: simple-on-complex); let content and typography carry visual
|
* **Shadows:** Multi-layered drop shadows create a strong sense of depth; cards
|
||||||
interest instead of background texture.
|
have a soft, deep shadow to look "lifted."
|
||||||
* **Shadows:** Follow the `unified-design-system` skill's shadow policy: no
|
|
||||||
shadows at all in dark UI (differentiate elevation with lighter surface
|
|
||||||
fills, not shadows); in light UI, shadows are for floating/overlay
|
|
||||||
elements only (menus, dialogs), never for inline cards, and never mixed
|
|
||||||
with a border on the same surface.
|
|
||||||
* **Icons:** Incorporate icons to enhance the user’s understanding and the
|
* **Icons:** Incorporate icons to enhance the user’s understanding and the
|
||||||
logical navigation of the app.
|
logical navigation of the app.
|
||||||
* **Interactive Elements:** Buttons/controls signal state via color and fill
|
* **Interactive Elements:** Buttons, checkboxes, sliders, lists, charts, graphs,
|
||||||
changes, not a "glow" shadow — one depth technique per surface, per
|
and other interactive elements have a shadow with elegant use of color to
|
||||||
`unified-design-system`.
|
create a "glow" effect.
|
||||||
|
|
||||||
#### Theming
|
#### Theming
|
||||||
* **Centralized Theme:** Define a centralized `ThemeData` object to ensure a
|
* **Centralized Theme:** Define a centralized `ThemeData` object to ensure a
|
||||||
@ -556,11 +551,8 @@ linter:
|
|||||||
* **Light and Dark Themes:** Implement support for both light and dark themes,
|
* **Light and Dark Themes:** Implement support for both light and dark themes,
|
||||||
ideal for a user-facing theme toggle (`ThemeMode.light`, `ThemeMode.dark`,
|
ideal for a user-facing theme toggle (`ThemeMode.light`, `ThemeMode.dark`,
|
||||||
`ThemeMode.system`).
|
`ThemeMode.system`).
|
||||||
* **Color Scheme Generation:** Do NOT use `ColorScheme.fromSeed` for this
|
* **Color Scheme Generation:** Generate harmonious color palettes from a single
|
||||||
app's palette — it can't reproduce hand-picked values exactly. Build
|
color using `ColorScheme.fromSeed`.
|
||||||
`ThemeData` from explicit `ColorScheme.dark(...)`/`.light(...)` using the
|
|
||||||
frozen, identical-everywhere tokens in the `unified-design-system` skill
|
|
||||||
(`~/.claude/skills/unified-design-system/references/tokens.md`).
|
|
||||||
|
|
||||||
```dart
|
```dart
|
||||||
final ThemeData lightTheme = ThemeData(
|
final ThemeData lightTheme = ThemeData(
|
||||||
|
|||||||
|
Before Width: | Height: | Size: 5.3 KiB After Width: | Height: | Size: 5.2 KiB |
|
Before Width: | Height: | Size: 3.3 KiB After Width: | Height: | Size: 3.3 KiB |
|
Before Width: | Height: | Size: 6.5 KiB After Width: | Height: | Size: 6.4 KiB |
|
Before Width: | Height: | Size: 9.5 KiB After Width: | Height: | Size: 9.5 KiB |
|
Before Width: | Height: | Size: 13 KiB After Width: | Height: | Size: 13 KiB |
|
Before Width: | Height: | Size: 1.9 KiB After Width: | Height: | Size: 1.8 KiB |
|
Before Width: | Height: | Size: 1.1 KiB After Width: | Height: | Size: 1.1 KiB |
|
Before Width: | Height: | Size: 2.2 KiB After Width: | Height: | Size: 2.2 KiB |
|
Before Width: | Height: | Size: 3.5 KiB After Width: | Height: | Size: 3.4 KiB |
|
Before Width: | Height: | Size: 4.3 KiB After Width: | Height: | Size: 4.3 KiB |
@ -1,4 +1,4 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<resources>
|
<resources>
|
||||||
<color name="ic_launcher_background">#211D1B</color>
|
<color name="ic_launcher_background">#1B1D21</color>
|
||||||
</resources>
|
</resources>
|
||||||
|
|||||||
|
Before Width: | Height: | Size: 22 KiB After Width: | Height: | Size: 22 KiB |
@ -1,8 +1,8 @@
|
|||||||
<svg xmlns="http://www.w3.org/2000/svg" width="1024" height="1024" viewBox="0 0 1024 1024">
|
<svg xmlns="http://www.w3.org/2000/svg" width="1024" height="1024" viewBox="0 0 1024 1024">
|
||||||
<rect width="1024" height="1024" fill="#211D1B"/>
|
<rect width="1024" height="1024" fill="#1B1D21"/>
|
||||||
<g fill="none" stroke="#B8862E" stroke-width="72" stroke-linecap="round" stroke-linejoin="round" transform="translate(0,-2)">
|
<g fill="none" stroke="#26A69A" stroke-width="72" stroke-linecap="round" stroke-linejoin="round" transform="translate(0,-2)">
|
||||||
<path d="M 512 275 L 752 366 L 752 544 C 752 655 646 723 512 753 C 378 723 272 655 272 544 L 272 366 Z"/>
|
<path d="M 512 275 L 752 366 L 752 544 C 752 655 646 723 512 753 C 378 723 272 655 272 544 L 272 366 Z"/>
|
||||||
<g transform="translate(356,362) scale(13)" fill="#B8862E" stroke="none">
|
<g transform="translate(356,362) scale(13)" fill="#26A69A" stroke="none">
|
||||||
<path d="M11 9H9V2H7v7H5V2H3v7c0 2.12 1.66 3.84 3.75 3.97V22h2.5v-9.03C11.34 12.84 13 11.12 13 9V2h-2v7z"/>
|
<path d="M11 9H9V2H7v7H5V2H3v7c0 2.12 1.66 3.84 3.75 3.97V22h2.5v-9.03C11.34 12.84 13 11.12 13 9V2h-2v7z"/>
|
||||||
<path d="M16 12h2.5v10H21V2c-2.76 0-5 2.24-5 5v5z"/>
|
<path d="M16 12h2.5v10H21V2c-2.76 0-5 2.24-5 5v5z"/>
|
||||||
</g>
|
</g>
|
||||||
|
|||||||
|
Before Width: | Height: | Size: 656 B After Width: | Height: | Size: 656 B |
|
Before Width: | Height: | Size: 24 KiB After Width: | Height: | Size: 24 KiB |
@ -1,7 +1,7 @@
|
|||||||
<svg xmlns="http://www.w3.org/2000/svg" width="1024" height="1024" viewBox="0 0 1024 1024">
|
<svg xmlns="http://www.w3.org/2000/svg" width="1024" height="1024" viewBox="0 0 1024 1024">
|
||||||
<g fill="none" stroke="#B8862E" stroke-width="72" stroke-linecap="round" stroke-linejoin="round" transform="translate(0,-2)">
|
<g fill="none" stroke="#26A69A" stroke-width="72" stroke-linecap="round" stroke-linejoin="round" transform="translate(0,-2)">
|
||||||
<path d="M 512 275 L 752 366 L 752 544 C 752 655 646 723 512 753 C 378 723 272 655 272 544 L 272 366 Z"/>
|
<path d="M 512 275 L 752 366 L 752 544 C 752 655 646 723 512 753 C 378 723 272 655 272 544 L 272 366 Z"/>
|
||||||
<g transform="translate(356,362) scale(13)" fill="#B8862E" stroke="none">
|
<g transform="translate(356,362) scale(13)" fill="#26A69A" stroke="none">
|
||||||
<path d="M11 9H9V2H7v7H5V2H3v7c0 2.12 1.66 3.84 3.75 3.97V22h2.5v-9.03C11.34 12.84 13 11.12 13 9V2h-2v7z"/>
|
<path d="M11 9H9V2H7v7H5V2H3v7c0 2.12 1.66 3.84 3.75 3.97V22h2.5v-9.03C11.34 12.84 13 11.12 13 9V2h-2v7z"/>
|
||||||
<path d="M16 12h2.5v10H21V2c-2.76 0-5 2.24-5 5v5z"/>
|
<path d="M16 12h2.5v10H21V2c-2.76 0-5 2.24-5 5v5z"/>
|
||||||
</g>
|
</g>
|
||||||
|
|||||||
|
Before Width: | Height: | Size: 604 B After Width: | Height: | Size: 604 B |
@ -11,7 +11,6 @@ import 'package:diet_guard_app/services/foodbank_service.dart';
|
|||||||
import 'package:diet_guard_app/services/frame_stats.dart';
|
import 'package:diet_guard_app/services/frame_stats.dart';
|
||||||
import 'package:diet_guard_app/services/log_storage_service.dart';
|
import 'package:diet_guard_app/services/log_storage_service.dart';
|
||||||
import 'package:diet_guard_app/services/notification_service.dart';
|
import 'package:diet_guard_app/services/notification_service.dart';
|
||||||
import 'package:diet_guard_app/ui/theme.dart';
|
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
Future<void> main() async {
|
Future<void> main() async {
|
||||||
@ -50,7 +49,7 @@ class DietGuardApp extends StatelessWidget {
|
|||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return MaterialApp(
|
return MaterialApp(
|
||||||
title: 'Diet Guard',
|
title: 'Diet Guard',
|
||||||
theme: buildAppTheme(),
|
theme: ThemeData(colorSchemeSeed: Colors.teal, useMaterial3: true),
|
||||||
home: const LogMealScreen(),
|
home: const LogMealScreen(),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -16,19 +16,18 @@ class PhotoViewerScreen extends StatelessWidget {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
final scheme = Theme.of(context).colorScheme;
|
|
||||||
return Scaffold(
|
return Scaffold(
|
||||||
backgroundColor: scheme.surface,
|
backgroundColor: Colors.black,
|
||||||
appBar: AppBar(
|
appBar: AppBar(
|
||||||
backgroundColor: scheme.surface,
|
backgroundColor: Colors.black,
|
||||||
foregroundColor: scheme.onSurface,
|
foregroundColor: Colors.white,
|
||||||
),
|
),
|
||||||
body: Center(
|
body: Center(
|
||||||
child: InteractiveViewer(
|
child: InteractiveViewer(
|
||||||
child: AttachedImage(
|
child: AttachedImage(
|
||||||
path: path,
|
path: path,
|
||||||
errorIconSize: 64,
|
errorIconSize: 64,
|
||||||
errorIconColor: scheme.onSurface,
|
errorIconColor: Colors.white,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|||||||
@ -564,10 +564,7 @@ class _DeviceCodeDialogState extends State<_DeviceCodeDialog> {
|
|||||||
],
|
],
|
||||||
)
|
)
|
||||||
else
|
else
|
||||||
Text(
|
Text(_error!, style: const TextStyle(color: Colors.red)),
|
||||||
_error!,
|
|
||||||
style: TextStyle(color: Theme.of(context).colorScheme.error),
|
|
||||||
),
|
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
actions: [
|
actions: [
|
||||||
|
|||||||
@ -1,163 +0,0 @@
|
|||||||
/// The app's design tokens: one identical palette shared across every one
|
|
||||||
/// of kuhy's apps (Flutter, web, Python/Tkinter alike) — see the
|
|
||||||
/// `unified-design-system` skill (`~/.claude/skills/unified-design-system/`)
|
|
||||||
/// for the frozen token table this file implements. Built from an explicit
|
|
||||||
/// `ColorScheme`, not `ColorScheme.fromSeed`, because the shared palette is
|
|
||||||
/// hand-picked, not algorithmically derived from one seed color.
|
|
||||||
library;
|
|
||||||
|
|
||||||
import 'package:flutter/material.dart';
|
|
||||||
|
|
||||||
/// Builds the app's single dark `ThemeData` from the shared token set.
|
|
||||||
ThemeData buildAppTheme() {
|
|
||||||
const colorScheme = ColorScheme.dark(
|
|
||||||
surface: Color(0xFF211D1B), // ink
|
|
||||||
surfaceContainerHighest: Color(0xFF38312E), // ink-raised-2
|
|
||||||
surfaceContainerHigh: Color(0xFF2B2624), // ink-raised-1
|
|
||||||
onSurface: Color(0xFFECEAE9), // text-on-dark
|
|
||||||
onSurfaceVariant: Color(0xFFAAA09A), // muted-on-dark
|
|
||||||
outline: Color(0xFF463E3A), // line-dark
|
|
||||||
primary: Color(0xFFB8862E), // accent
|
|
||||||
onPrimary: Color(
|
|
||||||
0xFF211D1B,
|
|
||||||
), // on-fill — every filled surface uses dark text
|
|
||||||
error: Color(0xFFE2585F), // danger
|
|
||||||
onError: Color(0xFF211D1B), // on-fill
|
|
||||||
);
|
|
||||||
return ThemeData(
|
|
||||||
useMaterial3: true,
|
|
||||||
colorScheme: colorScheme,
|
|
||||||
scaffoldBackgroundColor: colorScheme.surface,
|
|
||||||
extensions: const [AppStatusColors.dark],
|
|
||||||
textTheme: const TextTheme(
|
|
||||||
bodyLarge: TextStyle(fontSize: AppTextSize.body),
|
|
||||||
bodyMedium: TextStyle(fontSize: AppTextSize.body),
|
|
||||||
titleLarge: TextStyle(fontSize: AppTextSize.title),
|
|
||||||
titleMedium: TextStyle(fontSize: AppTextSize.subtitle),
|
|
||||||
labelMedium: TextStyle(fontSize: AppTextSize.label),
|
|
||||||
labelSmall: TextStyle(fontSize: AppTextSize.caption),
|
|
||||||
),
|
|
||||||
// Previously unset, so every TextField fell back to M3's default
|
|
||||||
// indigo focus color instead of the shared palette (open finding from
|
|
||||||
// the unified-design-system component doc).
|
|
||||||
inputDecorationTheme: InputDecorationTheme(
|
|
||||||
filled: true,
|
|
||||||
fillColor: colorScheme.surfaceContainerHigh,
|
|
||||||
border: OutlineInputBorder(
|
|
||||||
borderRadius: BorderRadius.circular(AppRadius.sm),
|
|
||||||
borderSide: BorderSide(color: colorScheme.outline),
|
|
||||||
),
|
|
||||||
enabledBorder: OutlineInputBorder(
|
|
||||||
borderRadius: BorderRadius.circular(AppRadius.sm),
|
|
||||||
borderSide: BorderSide(color: colorScheme.outline),
|
|
||||||
),
|
|
||||||
focusedBorder: OutlineInputBorder(
|
|
||||||
borderRadius: BorderRadius.circular(AppRadius.sm),
|
|
||||||
borderSide: BorderSide(color: colorScheme.primary, width: 2),
|
|
||||||
),
|
|
||||||
labelStyle: TextStyle(color: colorScheme.onSurfaceVariant),
|
|
||||||
),
|
|
||||||
// Previously unset, so every Divider fell back to M3's default grey
|
|
||||||
// instead of `line-dark` (same open finding as above).
|
|
||||||
dividerTheme: DividerThemeData(
|
|
||||||
color: colorScheme.outline,
|
|
||||||
thickness: 1,
|
|
||||||
space: AppSpacing.md,
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Semantic status colors M3's [ColorScheme] has no role for (it only has
|
|
||||||
/// `error`). Success/warning are the shared `unified-design-system` values —
|
|
||||||
/// every status indicator (calendar day, slot chip, sync state) should read
|
|
||||||
/// these instead of an ad hoc `Colors.green`/`Colors.amber`.
|
|
||||||
@immutable
|
|
||||||
class AppStatusColors extends ThemeExtension<AppStatusColors> {
|
|
||||||
/// Creates a status-color set.
|
|
||||||
const AppStatusColors({required this.success, required this.warning});
|
|
||||||
|
|
||||||
/// The shared dark-theme instance — success/warning from the unified
|
|
||||||
/// palette (danger already exists as `colorScheme.error`).
|
|
||||||
static const dark = AppStatusColors(
|
|
||||||
success: Color(0xFF8A9A3C),
|
|
||||||
warning: Color(0xFFE0A63C),
|
|
||||||
);
|
|
||||||
|
|
||||||
/// Positive/on-track status (e.g. a fully-logged, in-budget day).
|
|
||||||
final Color success;
|
|
||||||
|
|
||||||
/// Caution/pending status (e.g. a partially-logged day).
|
|
||||||
final Color warning;
|
|
||||||
|
|
||||||
@override
|
|
||||||
AppStatusColors copyWith({Color? success, Color? warning}) => AppStatusColors(
|
|
||||||
success: success ?? this.success,
|
|
||||||
warning: warning ?? this.warning,
|
|
||||||
);
|
|
||||||
|
|
||||||
@override
|
|
||||||
AppStatusColors lerp(AppStatusColors? other, double t) {
|
|
||||||
if (other is! AppStatusColors) return this;
|
|
||||||
return AppStatusColors(
|
|
||||||
success: Color.lerp(success, other.success, t) ?? success,
|
|
||||||
warning: Color.lerp(warning, other.warning, t) ?? warning,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Shared spacing scale (4px base) — round any new value to one of these
|
|
||||||
/// instead of introducing an off-scale literal.
|
|
||||||
abstract final class AppSpacing {
|
|
||||||
/// 4px.
|
|
||||||
static const double xs = 4;
|
|
||||||
|
|
||||||
/// 8px.
|
|
||||||
static const double sm = 8;
|
|
||||||
|
|
||||||
/// 16px.
|
|
||||||
static const double md = 16;
|
|
||||||
|
|
||||||
/// 24px.
|
|
||||||
static const double lg = 24;
|
|
||||||
|
|
||||||
/// 32px.
|
|
||||||
static const double xl = 32;
|
|
||||||
|
|
||||||
/// 48px.
|
|
||||||
static const double xxl = 48;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Shared corner-radius scale. Nested radii should be `outer - gap`, not a
|
|
||||||
/// fixed constant — compute per instance per safe-design-rules rule 24.
|
|
||||||
abstract final class AppRadius {
|
|
||||||
/// Buttons, inputs, chips.
|
|
||||||
static const double sm = 8;
|
|
||||||
|
|
||||||
/// Cards.
|
|
||||||
static const double md = 12;
|
|
||||||
|
|
||||||
/// Sheets, dialogs.
|
|
||||||
static const double lg = 16;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Shared type scale (px). `body` is the floor for anything a user reads;
|
|
||||||
/// `label`/`caption` are for UI chrome only (timestamps, badges, tags).
|
|
||||||
abstract final class AppTextSize {
|
|
||||||
/// 12px — chrome only.
|
|
||||||
static const double caption = 12;
|
|
||||||
|
|
||||||
/// 14px — chrome only.
|
|
||||||
static const double label = 14;
|
|
||||||
|
|
||||||
/// 16px — the floor for actual reading content.
|
|
||||||
static const double body = 16;
|
|
||||||
|
|
||||||
/// 20px.
|
|
||||||
static const double subtitle = 20;
|
|
||||||
|
|
||||||
/// 24px.
|
|
||||||
static const double title = 24;
|
|
||||||
|
|
||||||
/// 32px.
|
|
||||||
static const double display = 32;
|
|
||||||
}
|
|
||||||
@ -2,7 +2,6 @@
|
|||||||
library;
|
library;
|
||||||
|
|
||||||
import 'package:diet_guard_app/models/day_status.dart';
|
import 'package:diet_guard_app/models/day_status.dart';
|
||||||
import 'package:diet_guard_app/ui/theme.dart';
|
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
/// Monthly calendar widget that colors each day by its [DayStatus].
|
/// Monthly calendar widget that colors each day by its [DayStatus].
|
||||||
@ -75,40 +74,22 @@ class DayStatusCalendar extends StatelessWidget {
|
|||||||
return statusByDate[_dateKey(year, m, day)] ?? DayStatus.notLogged;
|
return statusByDate[_dateKey(year, m, day)] ?? DayStatus.notLogged;
|
||||||
}
|
}
|
||||||
|
|
||||||
Color _cellColor(
|
Color _cellColor(DayStatus? status) => switch (status) {
|
||||||
DayStatus? status,
|
null => Colors.grey.shade800,
|
||||||
ColorScheme scheme,
|
DayStatus.notLogged => Colors.black,
|
||||||
AppStatusColors statusColors,
|
DayStatus.red => Colors.red.shade400,
|
||||||
) => switch (status) {
|
DayStatus.yellow => Colors.amber.shade700,
|
||||||
// Future day: nothing to judge yet, so it reads as part of the
|
DayStatus.green => Colors.green.shade700,
|
||||||
// panel rather than an empty/failed slot.
|
|
||||||
null => scheme.surfaceContainerHigh,
|
|
||||||
// Recessed below the panel (darker than the surrounding
|
|
||||||
// ink-raised-1 container) with a visible outline, so it reads as
|
|
||||||
// "empty" without vanishing into the background.
|
|
||||||
DayStatus.notLogged => scheme.surface,
|
|
||||||
DayStatus.red => scheme.error,
|
|
||||||
DayStatus.yellow => statusColors.warning,
|
|
||||||
DayStatus.green => statusColors.success,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
Color _textColor(DayStatus? status, ColorScheme scheme) => switch (status) {
|
Color _textColor(DayStatus? status) => switch (status) {
|
||||||
null => scheme.onSurfaceVariant,
|
null => Colors.white38,
|
||||||
DayStatus.notLogged => scheme.onSurface,
|
DayStatus.notLogged => Colors.white,
|
||||||
// Status colors sit at mid brightness, so the near-black `ink` role
|
DayStatus.red || DayStatus.yellow || DayStatus.green => Colors.black,
|
||||||
// (not a separate pure black) gives strong, on-palette contrast.
|
|
||||||
DayStatus.red || DayStatus.yellow || DayStatus.green => scheme.surface,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
final scheme = Theme.of(context).colorScheme;
|
|
||||||
// A `!` here would crash in any context that doesn't build its theme
|
|
||||||
// from buildAppTheme() -- most widget tests just wrap in a bare
|
|
||||||
// MaterialApp(home: ...). Falling back to the app's own dark instance
|
|
||||||
// matches production exactly when the extension is genuinely absent.
|
|
||||||
final statusColors =
|
|
||||||
Theme.of(context).extension<AppStatusColors>() ?? AppStatusColors.dark;
|
|
||||||
final year = month.year;
|
final year = month.year;
|
||||||
final m = month.month;
|
final m = month.month;
|
||||||
final daysInMonth = DateTime(year, m + 1, 0).day;
|
final daysInMonth = DateTime(year, m + 1, 0).day;
|
||||||
@ -118,10 +99,10 @@ class DayStatusCalendar extends StatelessWidget {
|
|||||||
final rows = (totalCells / 7).ceil();
|
final rows = (totalCells / 7).ceil();
|
||||||
|
|
||||||
return Container(
|
return Container(
|
||||||
padding: const EdgeInsets.all(AppSpacing.md),
|
padding: const EdgeInsets.all(12),
|
||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
color: scheme.surfaceContainerHigh,
|
color: Colors.grey.shade800,
|
||||||
borderRadius: BorderRadius.circular(AppRadius.md),
|
borderRadius: BorderRadius.circular(8),
|
||||||
),
|
),
|
||||||
child: Column(
|
child: Column(
|
||||||
children: [
|
children: [
|
||||||
@ -129,28 +110,28 @@ class DayStatusCalendar extends StatelessWidget {
|
|||||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||||
children: [
|
children: [
|
||||||
IconButton(
|
IconButton(
|
||||||
icon: Icon(Icons.chevron_left, color: scheme.onSurfaceVariant),
|
icon: const Icon(Icons.chevron_left, color: Colors.white70),
|
||||||
visualDensity: VisualDensity.compact,
|
visualDensity: VisualDensity.compact,
|
||||||
padding: EdgeInsets.zero,
|
padding: EdgeInsets.zero,
|
||||||
onPressed: onPrevMonth,
|
onPressed: onPrevMonth,
|
||||||
),
|
),
|
||||||
Text(
|
Text(
|
||||||
'${_monthNames[m - 1]} $year',
|
'${_monthNames[m - 1]} $year',
|
||||||
style: TextStyle(
|
style: const TextStyle(
|
||||||
color: scheme.onSurface,
|
color: Colors.white,
|
||||||
fontWeight: FontWeight.bold,
|
fontWeight: FontWeight.bold,
|
||||||
fontSize: AppTextSize.body,
|
fontSize: 14,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
IconButton(
|
IconButton(
|
||||||
icon: Icon(Icons.chevron_right, color: scheme.onSurfaceVariant),
|
icon: const Icon(Icons.chevron_right, color: Colors.white70),
|
||||||
visualDensity: VisualDensity.compact,
|
visualDensity: VisualDensity.compact,
|
||||||
padding: EdgeInsets.zero,
|
padding: EdgeInsets.zero,
|
||||||
onPressed: onNextMonth,
|
onPressed: onNextMonth,
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
const SizedBox(height: AppSpacing.xs + 2),
|
const SizedBox(height: 6),
|
||||||
Row(
|
Row(
|
||||||
mainAxisAlignment: MainAxisAlignment.spaceAround,
|
mainAxisAlignment: MainAxisAlignment.spaceAround,
|
||||||
children: _weekHeaders
|
children: _weekHeaders
|
||||||
@ -160,12 +141,9 @@ class DayStatusCalendar extends StatelessWidget {
|
|||||||
child: Text(
|
child: Text(
|
||||||
h,
|
h,
|
||||||
textAlign: TextAlign.center,
|
textAlign: TextAlign.center,
|
||||||
// Two-letter day abbreviations are UI chrome (like a
|
style: const TextStyle(
|
||||||
// badge/tag), deliberately kept below the 16px body
|
color: Colors.white38,
|
||||||
// floor rather than forced to grow past their slot.
|
fontSize: 11,
|
||||||
style: TextStyle(
|
|
||||||
color: scheme.onSurfaceVariant,
|
|
||||||
fontSize: AppTextSize.label - 2,
|
|
||||||
fontWeight: FontWeight.bold,
|
fontWeight: FontWeight.bold,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
@ -173,7 +151,7 @@ class DayStatusCalendar extends StatelessWidget {
|
|||||||
)
|
)
|
||||||
.toList(),
|
.toList(),
|
||||||
),
|
),
|
||||||
const SizedBox(height: AppSpacing.xs),
|
const SizedBox(height: 4),
|
||||||
...List.generate(rows, (row) {
|
...List.generate(rows, (row) {
|
||||||
return Row(
|
return Row(
|
||||||
mainAxisAlignment: MainAxisAlignment.spaceAround,
|
mainAxisAlignment: MainAxisAlignment.spaceAround,
|
||||||
@ -190,20 +168,17 @@ class DayStatusCalendar extends StatelessWidget {
|
|||||||
margin: const EdgeInsets.symmetric(vertical: 2),
|
margin: const EdgeInsets.symmetric(vertical: 2),
|
||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
shape: BoxShape.circle,
|
shape: BoxShape.circle,
|
||||||
color: _cellColor(status, scheme, statusColors),
|
color: _cellColor(status),
|
||||||
border: status == DayStatus.notLogged
|
border: status == DayStatus.notLogged
|
||||||
? Border.all(color: scheme.outline)
|
? Border.all(color: Colors.white70)
|
||||||
: null,
|
: null,
|
||||||
),
|
),
|
||||||
alignment: Alignment.center,
|
alignment: Alignment.center,
|
||||||
child: Text(
|
child: Text(
|
||||||
'$day',
|
'$day',
|
||||||
// A fixed 30px circle can't fit 16px bold digits for
|
|
||||||
// two-digit days without overflowing — kept as a
|
|
||||||
// deliberate chrome exception (rule 4), not accidental.
|
|
||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
color: _textColor(status, scheme),
|
color: _textColor(status),
|
||||||
fontSize: AppTextSize.label - 2,
|
fontSize: 12,
|
||||||
fontWeight:
|
fontWeight:
|
||||||
status != null && status != DayStatus.notLogged
|
status != null && status != DayStatus.notLogged
|
||||||
? FontWeight.bold
|
? FontWeight.bold
|
||||||
|
|||||||
@ -4,7 +4,6 @@
|
|||||||
library;
|
library;
|
||||||
|
|
||||||
import 'package:diet_guard_app/models/slot.dart';
|
import 'package:diet_guard_app/models/slot.dart';
|
||||||
import 'package:diet_guard_app/ui/theme.dart';
|
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
/// One row of [ChoiceChip]s: one per today's slot hour plus a fixed
|
/// One row of [ChoiceChip]s: one per today's slot hour plus a fixed
|
||||||
@ -35,47 +34,24 @@ class SlotSelectorRow extends StatelessWidget {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
final scheme = Theme.of(context).colorScheme;
|
|
||||||
// A `!` here would crash in any context that doesn't build its theme
|
|
||||||
// from buildAppTheme() -- most widget tests just wrap in a bare
|
|
||||||
// MaterialApp(home: ...). Falling back to the app's own dark instance
|
|
||||||
// matches production exactly when the extension is genuinely absent.
|
|
||||||
final statusColors =
|
|
||||||
Theme.of(context).extension<AppStatusColors>() ?? AppStatusColors.dark;
|
|
||||||
final elapsed = elapsedSlots(now).toSet();
|
final elapsed = elapsedSlots(now).toSet();
|
||||||
// Snack has no logged/due/upcoming status like the hour chips, so it
|
|
||||||
// uses `accent` as its "color" instead of a status color -- but still
|
|
||||||
// needs every property below set explicitly like the hour chips are.
|
|
||||||
// Leaving any of them unset falls through to Flutter's own ChoiceChip
|
|
||||||
// default, a literal pure-white border (the one banned value in this
|
|
||||||
// system) -- the open finding the unified-design-system doc flagged.
|
|
||||||
final snackSelected = selectedSlot == null;
|
|
||||||
final snackColor = snackSelected ? scheme.primary : scheme.onSurfaceVariant;
|
|
||||||
return Wrap(
|
return Wrap(
|
||||||
spacing: AppSpacing.xs + 2,
|
spacing: 6,
|
||||||
runSpacing: AppSpacing.xs,
|
runSpacing: 4,
|
||||||
children: [
|
children: [
|
||||||
...daySlots().map((slot) {
|
...daySlots().map((slot) {
|
||||||
final isLogged = loggedSlots.contains(slot);
|
final isLogged = loggedSlots.contains(slot);
|
||||||
final isDue = !isLogged && elapsed.contains(slot);
|
final isDue = !isLogged && elapsed.contains(slot);
|
||||||
final color = isLogged
|
final color = isLogged
|
||||||
? statusColors.success
|
? Colors.green
|
||||||
: isDue
|
: isDue
|
||||||
? scheme.error
|
? Colors.red
|
||||||
: scheme.onSurfaceVariant;
|
: Colors.grey;
|
||||||
final isSelected = selectedSlot == slot;
|
final isSelected = selectedSlot == slot;
|
||||||
return ChoiceChip(
|
return ChoiceChip(
|
||||||
label: Text(slotLabel(slot)),
|
label: Text(slotLabel(slot)),
|
||||||
selected: isSelected,
|
selected: isSelected,
|
||||||
// Icon reads lighter than the label text (rule 28): reduced
|
avatar: isLogged ? Icon(Icons.check, size: 14, color: color) : null,
|
||||||
// opacity instead of the label's full-strength color.
|
|
||||||
avatar: isLogged
|
|
||||||
? Icon(
|
|
||||||
Icons.check,
|
|
||||||
size: 14,
|
|
||||||
color: color.withValues(alpha: 0.72),
|
|
||||||
)
|
|
||||||
: null,
|
|
||||||
backgroundColor: color.withValues(alpha: 0.15),
|
backgroundColor: color.withValues(alpha: 0.15),
|
||||||
selectedColor: color.withValues(alpha: 0.35),
|
selectedColor: color.withValues(alpha: 0.35),
|
||||||
labelStyle: TextStyle(color: color),
|
labelStyle: TextStyle(color: color),
|
||||||
@ -88,23 +64,8 @@ class SlotSelectorRow extends StatelessWidget {
|
|||||||
}),
|
}),
|
||||||
ChoiceChip(
|
ChoiceChip(
|
||||||
label: const Text('Snack'),
|
label: const Text('Snack'),
|
||||||
// Icon reads lighter than the label text (rule 28): reduced
|
avatar: const Icon(Icons.fastfood, size: 14),
|
||||||
// opacity instead of the label's full-strength color.
|
selected: selectedSlot == null,
|
||||||
avatar: Icon(
|
|
||||||
Icons.fastfood,
|
|
||||||
size: 14,
|
|
||||||
color: snackColor.withValues(alpha: 0.72),
|
|
||||||
),
|
|
||||||
selected: snackSelected,
|
|
||||||
backgroundColor: scheme.onSurfaceVariant.withValues(alpha: 0.15),
|
|
||||||
selectedColor: scheme.primary.withValues(alpha: 0.35),
|
|
||||||
labelStyle: TextStyle(color: snackColor),
|
|
||||||
side: BorderSide(
|
|
||||||
width: snackSelected ? 2 : 1,
|
|
||||||
color: snackSelected
|
|
||||||
? snackColor
|
|
||||||
: snackColor.withValues(alpha: 0.4),
|
|
||||||
),
|
|
||||||
onSelected: (_) => onSlotSelected(null),
|
onSelected: (_) => onSlotSelected(null),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
|
|||||||
@ -50,7 +50,7 @@ flutter_launcher_icons:
|
|||||||
android: true
|
android: true
|
||||||
ios: false
|
ios: false
|
||||||
image_path: "assets/icon/icon.png"
|
image_path: "assets/icon/icon.png"
|
||||||
adaptive_icon_background: "#211D1B"
|
adaptive_icon_background: "#1B1D21"
|
||||||
adaptive_icon_foreground: "assets/icon/icon_foreground.png"
|
adaptive_icon_foreground: "assets/icon/icon_foreground.png"
|
||||||
adaptive_icon_monochrome: "assets/icon/icon_monochrome.png"
|
adaptive_icon_monochrome: "assets/icon/icon_monochrome.png"
|
||||||
min_sdk_android: 21
|
min_sdk_android: 21
|
||||||
|
|||||||
@ -1,20 +1,9 @@
|
|||||||
import 'package:diet_guard_app/models/day_status.dart';
|
import 'package:diet_guard_app/models/day_status.dart';
|
||||||
import 'package:diet_guard_app/ui/theme.dart';
|
|
||||||
import 'package:diet_guard_app/widgets/day_status_calendar.dart';
|
import 'package:diet_guard_app/widgets/day_status_calendar.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_test/flutter_test.dart';
|
import 'package:flutter_test/flutter_test.dart';
|
||||||
|
|
||||||
// The real app theme, not a bare default MaterialApp -- the widget under
|
Widget _wrap(Widget child) => MaterialApp(home: Scaffold(body: child));
|
||||||
// test reads its colors from Theme.of(context), so asserting against the
|
|
||||||
// same theme the app actually ships is what makes these assertions mean
|
|
||||||
// anything (a bare MaterialApp's own default colors would be arbitrary).
|
|
||||||
final _theme = buildAppTheme();
|
|
||||||
final _statusColors = _theme.extension<AppStatusColors>()!;
|
|
||||||
|
|
||||||
Widget _wrap(Widget child) => MaterialApp(
|
|
||||||
theme: _theme,
|
|
||||||
home: Scaffold(body: child),
|
|
||||||
);
|
|
||||||
|
|
||||||
Color _colorOfDay(WidgetTester tester, String day) {
|
Color _colorOfDay(WidgetTester tester, String day) {
|
||||||
final container = tester.widget<Container>(
|
final container = tester.widget<Container>(
|
||||||
@ -106,7 +95,7 @@ void main() {
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
expect(_colorOfDay(tester, '15'), _statusColors.success);
|
expect(_colorOfDay(tester, '15'), Colors.green.shade700);
|
||||||
});
|
});
|
||||||
|
|
||||||
testWidgets('colors a yellow day', (tester) async {
|
testWidgets('colors a yellow day', (tester) async {
|
||||||
@ -121,7 +110,7 @@ void main() {
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
expect(_colorOfDay(tester, '15'), _statusColors.warning);
|
expect(_colorOfDay(tester, '15'), Colors.amber.shade700);
|
||||||
});
|
});
|
||||||
|
|
||||||
testWidgets('colors a red day', (tester) async {
|
testWidgets('colors a red day', (tester) async {
|
||||||
@ -136,7 +125,7 @@ void main() {
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
expect(_colorOfDay(tester, '15'), _theme.colorScheme.error);
|
expect(_colorOfDay(tester, '15'), Colors.red.shade400);
|
||||||
});
|
});
|
||||||
|
|
||||||
testWidgets(
|
testWidgets(
|
||||||
@ -153,7 +142,7 @@ void main() {
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
expect(_colorOfDay(tester, '15'), _theme.colorScheme.surface);
|
expect(_colorOfDay(tester, '15'), Colors.black);
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -172,10 +161,7 @@ void main() {
|
|||||||
),
|
),
|
||||||
);
|
);
|
||||||
// Day 25 is after the reference "today" of June 10.
|
// Day 25 is after the reference "today" of June 10.
|
||||||
expect(
|
expect(_colorOfDay(tester, '25'), Colors.grey.shade800);
|
||||||
_colorOfDay(tester, '25'),
|
|
||||||
_theme.colorScheme.surfaceContainerHigh,
|
|
||||||
);
|
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -193,7 +179,7 @@ void main() {
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
expect(_colorOfDay(tester, '20'), _theme.colorScheme.error);
|
expect(_colorOfDay(tester, '20'), Colors.red.shade400);
|
||||||
});
|
});
|
||||||
|
|
||||||
testWidgets('renders a month starting on Sunday correctly', (
|
testWidgets('renders a month starting on Sunday correctly', (
|
||||||
|
|||||||
@ -4,7 +4,7 @@ version = "1.0.0"
|
|||||||
description = "Tkinter/systemd log-to-unlock meal gate with calorie/macro budget tracking"
|
description = "Tkinter/systemd log-to-unlock meal gate with calorie/macro budget tracking"
|
||||||
requires-python = ">=3.10"
|
requires-python = ">=3.10"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"gatelock @ git+https://github.com/kuhyx/utils@gatelock-v0.1.1#subdirectory=gatelock",
|
"gatelock @ git+https://github.com/kuhyx/utils@gatelock-v0.1.0#subdirectory=gatelock",
|
||||||
"crdt-sync @ git+https://github.com/kuhyx/utils@crdt-sync-v0.1.0#subdirectory=crdt-sync",
|
"crdt-sync @ git+https://github.com/kuhyx/utils@crdt-sync-v0.1.0#subdirectory=crdt-sync",
|
||||||
"requests>=2.31.0",
|
"requests>=2.31.0",
|
||||||
]
|
]
|
||||||
|
|||||||
@ -4,7 +4,7 @@ bandit>=1.7.0
|
|||||||
codespell>=2.2.0
|
codespell>=2.2.0
|
||||||
coverage>=7.4.0
|
coverage>=7.4.0
|
||||||
crdt-sync @ git+https://github.com/kuhyx/utils@crdt-sync-v0.1.0#subdirectory=crdt-sync
|
crdt-sync @ git+https://github.com/kuhyx/utils@crdt-sync-v0.1.0#subdirectory=crdt-sync
|
||||||
gatelock @ git+https://github.com/kuhyx/utils@gatelock-v0.1.1#subdirectory=gatelock
|
gatelock @ git+https://github.com/kuhyx/utils@gatelock-v0.1.0#subdirectory=gatelock
|
||||||
mcp>=1.9
|
mcp>=1.9
|
||||||
mypy>=1.8.0
|
mypy>=1.8.0
|
||||||
pre-commit>=3.6.0
|
pre-commit>=3.6.0
|
||||||
|
|||||||