mirror of
https://github.com/kuhyx/diet-guard.git
synced 2026-11-26 00:07:12 +01:00
Compare commits
3 Commits
2dc502bbb6
...
957ddc7ddc
| Author | SHA1 | Date | |
|---|---|---|---|
| 957ddc7ddc | |||
| e7ef648757 | |||
| dc2799e36a |
@ -7,6 +7,7 @@ import 'package:diet_guard_app/ui/macro_kind.dart';
|
||||
import 'package:diet_guard_app/ui/theme.dart';
|
||||
import 'package:diet_guard_app/widgets/body/body_section.dart';
|
||||
import 'package:diet_guard_app/widgets/body/formula_figure.dart';
|
||||
import 'package:diet_guard_app/widgets/body/workout_kind_icon.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
/// How many of the newest sessions to list.
|
||||
@ -185,7 +186,22 @@ class _SessionTile extends StatelessWidget {
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text('${session.day} ${session.label}'),
|
||||
Row(
|
||||
children: [
|
||||
Text(session.day),
|
||||
const SizedBox(width: AppSpacing.sm),
|
||||
Icon(
|
||||
kindIcon(session.kind),
|
||||
size: 16,
|
||||
color: muted,
|
||||
semanticLabel: session.label,
|
||||
),
|
||||
if (session.source == 'manual') ...[
|
||||
const SizedBox(width: AppSpacing.sm),
|
||||
Flexible(child: Text(session.label)),
|
||||
],
|
||||
],
|
||||
),
|
||||
Row(
|
||||
children: [
|
||||
Icon(
|
||||
|
||||
13
app/lib/widgets/body/workout_kind_icon.dart
Normal file
13
app/lib/widgets/body/workout_kind_icon.dart
Normal file
@ -0,0 +1,13 @@
|
||||
/// Returns the activity-type icon for [kind].
|
||||
library;
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
/// Activity kind icons used by _SessionTile (in `activity_card.dart`).
|
||||
IconData kindIcon(String kind) => switch (kind) {
|
||||
'run' => Icons.directions_run,
|
||||
'walk' => Icons.directions_walk,
|
||||
'cycle' => Icons.directions_bike,
|
||||
'strength' => Icons.fitness_center,
|
||||
_ => Icons.sports,
|
||||
};
|
||||
@ -157,11 +157,11 @@ packages:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
path: crdt_sync_dart
|
||||
ref: "crdt_sync_dart-v0.12.0"
|
||||
resolved-ref: "59b33949e4a130bb76c77e7434ddf4bbf8cde3a3"
|
||||
ref: "crdt_sync_dart-v0.12.1"
|
||||
resolved-ref: "6641d85f0550ca60433fc8e0d13a3dafdbb664d6"
|
||||
url: "https://github.com/kuhyx/utils"
|
||||
source: git
|
||||
version: "0.12.0"
|
||||
version: "0.12.1"
|
||||
cross_file:
|
||||
dependency: transitive
|
||||
description:
|
||||
@ -375,10 +375,10 @@ packages:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
name: fl_chart
|
||||
sha256: "5ed69b8be550c6276c8f0bc25c09704fb061018ed1b1681867ad18fcf477e7b7"
|
||||
sha256: "9f11b0b87a6b1843f5ca666ade4a62c08da1a6b7f9efeb91bb2c6f3fa6e31a9a"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "1.3.0"
|
||||
version: "1.3.1"
|
||||
flutter:
|
||||
dependency: "direct main"
|
||||
description: flutter
|
||||
@ -544,10 +544,10 @@ packages:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
name: idb_shim
|
||||
sha256: "60965b556624f7018ec26205283e32670bc78c6fe1388d4b90bdfe6b2311b87b"
|
||||
sha256: "507d8f3154fa4e41165941c5aa8509c6bf155bb30f76ba25a00d1e7ba1dd64c9"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "2.11.2"
|
||||
version: "2.11.3"
|
||||
image:
|
||||
dependency: transitive
|
||||
description:
|
||||
@ -824,10 +824,10 @@ packages:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: sembast
|
||||
sha256: "35775a26edbdf0d891bab304929a712e103c9d9a6e2fb5ebbd8437bb3139615a"
|
||||
sha256: "4f71f8c95105918fa207065429c913f38d0fb05fec9f3a745bbf4c113f5d482b"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "3.10.0"
|
||||
version: "3.10.1"
|
||||
share_plus:
|
||||
dependency: transitive
|
||||
description:
|
||||
@ -941,11 +941,11 @@ packages:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
path: sync_settings_ui
|
||||
ref: "sync_settings_ui-v0.6.1"
|
||||
resolved-ref: ebedbf4b27fa332f7b8e6d80117d1c409bf3a7ad
|
||||
ref: "sync_settings_ui-v0.6.2"
|
||||
resolved-ref: "95cd3731ede686114353d32ae6c286ad1694b488"
|
||||
url: "https://github.com/kuhyx/utils"
|
||||
source: git
|
||||
version: "0.6.1"
|
||||
version: "0.6.2"
|
||||
synchronized:
|
||||
dependency: transitive
|
||||
description:
|
||||
|
||||
@ -2,7 +2,7 @@ name: diet_guard_app
|
||||
description: "Companion phone app for diet_guard: log meals on the go."
|
||||
publish_to: 'none'
|
||||
|
||||
version: 1.0.147+1
|
||||
version: 1.0.150+1
|
||||
|
||||
environment:
|
||||
sdk: ^3.12.2
|
||||
@ -12,7 +12,7 @@ dependencies:
|
||||
crdt_sync:
|
||||
git:
|
||||
url: https://github.com/kuhyx/utils
|
||||
ref: crdt_sync_dart-v0.12.0
|
||||
ref: crdt_sync_dart-v0.12.1
|
||||
path: crdt_sync_dart
|
||||
crypto: 3.0.8
|
||||
cryptography: 2.9.0
|
||||
@ -23,7 +23,7 @@ dependencies:
|
||||
url: https://github.com/kuhyx/utils
|
||||
ref: data_transfer_flutter-v0.2.1
|
||||
path: data_transfer_flutter
|
||||
fl_chart: 1.3.0
|
||||
fl_chart: 1.3.1
|
||||
flutter:
|
||||
sdk: flutter
|
||||
flutter_local_notifications: 23.0.0
|
||||
@ -44,7 +44,7 @@ dependencies:
|
||||
path: google_account_token
|
||||
health: 13.3.2
|
||||
http: 1.6.0
|
||||
idb_shim: 2.11.2
|
||||
idb_shim: 2.11.3
|
||||
path: 1.9.1
|
||||
path_provider: 2.1.6
|
||||
permission_handler: 13.0.2
|
||||
@ -57,7 +57,7 @@ dependencies:
|
||||
sync_settings_ui:
|
||||
git:
|
||||
url: https://github.com/kuhyx/utils
|
||||
ref: sync_settings_ui-v0.6.1
|
||||
ref: sync_settings_ui-v0.6.2
|
||||
path: sync_settings_ui
|
||||
url_launcher: 6.3.3
|
||||
uuid: 4.6.0
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
// Guard: the Body screen, every tile sheet and the activity-method chooser
|
||||
// paint no words (only numbers, unit symbols, MET and workout labels).
|
||||
// Workout labels are content only for manual workouts (source == 'manual').
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
@ -12,10 +13,9 @@ import 'screens/body_screen_support.dart';
|
||||
/// proper names of the BMI / ideal-weight / BMR formulas that label their
|
||||
/// figures (DOUBT rows in keep.md: kept from the first pilot, outside the
|
||||
/// activity sheet). Activity formulas (ACSM, Per-km) are NOT here: that sheet
|
||||
/// and its chooser show glyphs only.
|
||||
/// and its chooser show glyphs only. Only manual workouts carry human content.
|
||||
const Set<String> _workouts = {
|
||||
'Evening run',
|
||||
'StrongLifts A',
|
||||
'walk to the shop',
|
||||
'Harris-Benedict (revised 1984)',
|
||||
'Peterson (BMI 22)',
|
||||
'Mifflin-St Jeor',
|
||||
@ -41,8 +41,8 @@ void main() {
|
||||
expect(wordsIn('70.0 kg'), isEmpty);
|
||||
expect(wordsIn('265 MET'), isEmpty);
|
||||
expect(wordsIn('Measured (ACSM)'), isNotEmpty);
|
||||
expect(wordsIn('Evening run 4 km', content: _workouts), ['km']);
|
||||
expect(wordsIn('Evening run', content: _workouts), isEmpty);
|
||||
expect(wordsIn('walk to the shop 4 km', content: _workouts), ['km']);
|
||||
expect(wordsIn('walk to the shop', content: _workouts), isEmpty);
|
||||
});
|
||||
|
||||
testWidgets('canary: a painted word fails the guard', (tester) async {
|
||||
|
||||
@ -70,16 +70,24 @@ Future<void> seedPerson(MemoryDocStore store, {Object? goal}) async {
|
||||
'kind': 'run',
|
||||
'min': 60,
|
||||
'km': 10,
|
||||
'label': 'Evening run',
|
||||
'label': 'Running 10.0 km',
|
||||
'src': 'runnerup',
|
||||
},
|
||||
{
|
||||
'day': yesterdayKey(),
|
||||
'kind': 'strength',
|
||||
'min': 80,
|
||||
'label': 'StrongLifts A',
|
||||
'label': 'StrongLifts workout A (80 min, all succeeded)',
|
||||
'src': 'screen-locker',
|
||||
},
|
||||
{
|
||||
'day': yesterdayKey(),
|
||||
'kind': 'walk',
|
||||
'min': 30,
|
||||
'km': 2,
|
||||
'label': 'walk to the shop',
|
||||
'src': 'manual',
|
||||
},
|
||||
],
|
||||
},
|
||||
});
|
||||
|
||||
@ -133,8 +133,15 @@ void main() {
|
||||
byIconLabel('Mean daily exercise, last 1 full days:'),
|
||||
findsOneWidget,
|
||||
);
|
||||
expect(find.textContaining('Evening run'), findsOneWidget);
|
||||
expect(find.textContaining('StrongLifts A'), findsOneWidget);
|
||||
expect(
|
||||
byIconLabel('Running 10.0 km'),
|
||||
findsOneWidget,
|
||||
);
|
||||
expect(
|
||||
byIconLabel('StrongLifts workout A (80 min, all succeeded)'),
|
||||
findsOneWidget,
|
||||
);
|
||||
expect(find.textContaining('walk to the shop'), findsOneWidget);
|
||||
expect(byIconLabel('Connect Health Connect steps'), findsNothing);
|
||||
});
|
||||
|
||||
|
||||
@ -100,11 +100,16 @@ def _clock_window(day: str, item: dict[str, object]) -> tuple[str | None, str |
|
||||
def manual_session(
|
||||
day: str, item: dict[str, object], minutes: float, label: str
|
||||
) -> Session:
|
||||
"""The :class:`Session` one manual workout stands for."""
|
||||
"""The :class:`Session` one manual workout stands for.
|
||||
|
||||
Source is "manual" so the phone's activity sheet can paint the human-typed
|
||||
label (``source == "manual"`` in Dart). Verified screen-locker workouts keep
|
||||
source "screen-locker".
|
||||
"""
|
||||
text = _text(item)
|
||||
kind = _kind(item, text)
|
||||
km = _typed_km(item)
|
||||
if km is None and kind in {"run", "walk"}:
|
||||
km = _text_km(text)
|
||||
start, end = _clock_window(day, item)
|
||||
return Session(day, kind, minutes, km, label, "screen-locker", start, end)
|
||||
return Session(day, kind, minutes, km, label, "manual", start, end)
|
||||
|
||||
@ -47,3 +47,7 @@ class TestManualParse:
|
||||
assert start is not None
|
||||
assert end is not None
|
||||
assert logged_window("never", 60) == (None, None)
|
||||
|
||||
def test_manual_session_source_is_manual(self) -> None:
|
||||
session = manual_session("2026-09-20", {}, 45.0, "walk to work")
|
||||
assert session.source == "manual"
|
||||
|
||||
Loading…
Reference in New Issue
Block a user