feat(train): Settings choose the app's appearance and language
The developer asked for Train to offer what Learn's Settings offer first (ADR 0014's amendment of 4 Nov 2026). Train passed a fixed look, the system's theme and language; it now opens halkyon_app's LookCubit on <app support>/look.json in main, provides it above InstanceGate, and its start screens and each person's MaterialApp follow it. Settings show DeviceLookCard right after the Sync and operator's cards, as Learn's, offering English (UK), English (US) and Deutsch (trainLanguages). The app's tests tapping Delete account and About now scroll them into view first (tapInSettings, as Todo's and Meditate's): the card moved them below the phone's fold. Whats-New: Settings: choose the app's appearance and language. Whats-New-De: Einstellungen: Darstellung und Sprache der App wählen. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Tizian 「ティツィアーン」 <raisondetredev@pm.me>
This commit is contained in:
parent
a2384dcbfe
commit
7aba2a2dcc
4 changed files with 187 additions and 104 deletions
|
|
@ -32,6 +32,11 @@ Future<void> main() async {
|
|||
sharesStorage: device.storage.sharesWith,
|
||||
);
|
||||
await instances.load(usedBefore: device.storage.usedBefore());
|
||||
// The device's appearance and language, read before the first frame so
|
||||
// that it opens in them.
|
||||
final look = await LookCubit.open(
|
||||
FileLookStore(File(p.join(device.support, 'look.json'))),
|
||||
);
|
||||
runApp(
|
||||
WhatsNewScope(
|
||||
whatsNew: WhatsNew(
|
||||
|
|
@ -47,6 +52,7 @@ Future<void> main() async {
|
|||
// answers too, but holds nothing of this app's.
|
||||
checker: ServerpodInstanceChecker(app: 'train'),
|
||||
open: (instance) => TrainDependencies.create(instance, device),
|
||||
look: look,
|
||||
),
|
||||
),
|
||||
);
|
||||
|
|
|
|||
|
|
@ -25,10 +25,6 @@ import 'package:halkyon_train_flutter/src/feature/workout/model/workout.dart';
|
|||
import 'package:halkyon_ui/halkyon_ui.dart';
|
||||
import 'package:material_ui/material_ui.dart';
|
||||
|
||||
/// The device's look until Train has settings: the system's theme mode and
|
||||
/// language.
|
||||
const _systemLook = (themeMode: ThemeMode.system, locale: null);
|
||||
|
||||
/// Halkyon Train: halkyon_app's [InstanceGate] (the first start, the account
|
||||
/// on each instance) with Train's [trainFrame], and on the instance in use
|
||||
/// halkyon_app's [SessionGate], which shows each signed-in person their own
|
||||
|
|
@ -47,19 +43,27 @@ class const TrainApp({
|
|||
|
||||
/// Train's dependencies on an instance.
|
||||
required final Future<TrainDependencies> Function(Instance instance) open,
|
||||
|
||||
/// The device's appearance and language, chosen in Settings (ADR 0014's
|
||||
/// amendment of 4 Nov 2026): above everything, as they apply before
|
||||
/// anyone signs in.
|
||||
required final LookCubit look,
|
||||
super.key,
|
||||
}) extends StatelessWidget {
|
||||
@override
|
||||
Widget build(BuildContext context) => InstanceGate(
|
||||
frame: trainFrame,
|
||||
choice: choice,
|
||||
checker: checker,
|
||||
countryNames: countryNames,
|
||||
open: open,
|
||||
readLook: () async => _systemLook,
|
||||
app: SessionGate(
|
||||
look: (context) => _systemLook,
|
||||
app: (person) => TrainPersonApp(person: person),
|
||||
Widget build(BuildContext context) => BlocProvider.value(
|
||||
value: look,
|
||||
child: InstanceGate(
|
||||
frame: trainFrame,
|
||||
choice: choice,
|
||||
checker: checker,
|
||||
countryNames: countryNames,
|
||||
open: open,
|
||||
readLook: () async => look.state.settings,
|
||||
app: SessionGate(
|
||||
look: (context) => context.watch<LookCubit>().state.settings,
|
||||
app: (person) => TrainPersonApp(person: person),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
|
@ -88,89 +92,95 @@ class _TrainPersonAppState() extends State<TrainPersonApp> {
|
|||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) => MaterialApp.router(
|
||||
routerConfig: _router,
|
||||
onGenerateTitle: (context) => AppLocalizations.of(context).appTitle,
|
||||
theme: appTheme(Brightness.light),
|
||||
darkTheme: appTheme(Brightness.dark),
|
||||
localizationsDelegates: trainLocalizationsDelegates,
|
||||
supportedLocales: AppLocalizations.supportedLocales,
|
||||
localeListResolutionCallback: resolveAppLocale,
|
||||
// How many accounts wait, for whoever operates the instance: the
|
||||
// account sheet's tiles and the badge on its button. The workouts above
|
||||
// the navigator, so home and a workout's page share their deletions.
|
||||
builder: (context, child) => PersonScope(
|
||||
person: widget.person,
|
||||
child: MultiBlocProvider(
|
||||
providers: [
|
||||
BlocProvider(
|
||||
create: (context) =>
|
||||
OperatingCubit(AppScope.of(context).instanceOperators),
|
||||
),
|
||||
// Where sync stands: Settings' card and the dot on the cog, as
|
||||
// Learn's and Todo's.
|
||||
BlocProvider(
|
||||
create: (context) =>
|
||||
SyncStatusBloc(PersonScope.of<TrainPerson>(context).sync),
|
||||
),
|
||||
BlocProvider(
|
||||
create: (context) {
|
||||
final train = PersonScope.of<TrainPerson>(context);
|
||||
return WorkoutsCubit(train.workouts, train.deletions)..open();
|
||||
},
|
||||
),
|
||||
BlocProvider(
|
||||
create: (context) {
|
||||
final train = PersonScope.of<TrainPerson>(context);
|
||||
return DaysCubit(train.days, train.loop)..open();
|
||||
},
|
||||
),
|
||||
BlocProvider(
|
||||
create: (context) {
|
||||
final train = PersonScope.of<TrainPerson>(context);
|
||||
return PlansCubit(train.plans, train.planDeletions)..open();
|
||||
},
|
||||
),
|
||||
// The places and the strength plans, which the plans' lists, a
|
||||
// session and Equipment share (ADR 0034, ADR 0035).
|
||||
BlocProvider(
|
||||
create: (context) {
|
||||
final train = PersonScope.of<TrainPerson>(context);
|
||||
return PlacesCubit(train.places, train.chosenPlace)..open();
|
||||
},
|
||||
),
|
||||
// Their weights, which Progress and Your body share (D64).
|
||||
BlocProvider(
|
||||
create: (context) {
|
||||
final train = PersonScope.of<TrainPerson>(context);
|
||||
return WeightsCubit(train.weights, train.profile)..open();
|
||||
},
|
||||
),
|
||||
BlocProvider(
|
||||
create: (context) {
|
||||
final train = PersonScope.of<TrainPerson>(context);
|
||||
return StrengthPlansCubit(
|
||||
train.strengthPlans,
|
||||
train.strengthPlanDeletions,
|
||||
)..open();
|
||||
},
|
||||
),
|
||||
BlocProvider(
|
||||
create: (context) {
|
||||
final train = PersonScope.of<TrainPerson>(context);
|
||||
return RoutesCubit(train.routes, train.routeDeletions)..open();
|
||||
},
|
||||
),
|
||||
],
|
||||
child: _Recording(
|
||||
child: ScreenColor(
|
||||
color: PaletteColor.carrot.background,
|
||||
child: child!,
|
||||
Widget build(BuildContext context) {
|
||||
// The device's look and language, chosen in Settings.
|
||||
final look = context.watch<LookCubit>().state;
|
||||
return MaterialApp.router(
|
||||
routerConfig: _router,
|
||||
onGenerateTitle: (context) => AppLocalizations.of(context).appTitle,
|
||||
theme: appTheme(Brightness.light),
|
||||
darkTheme: appTheme(Brightness.dark),
|
||||
themeMode: look.themeMode,
|
||||
locale: look.locale,
|
||||
localizationsDelegates: trainLocalizationsDelegates,
|
||||
supportedLocales: AppLocalizations.supportedLocales,
|
||||
localeListResolutionCallback: resolveAppLocale,
|
||||
// How many accounts wait, for whoever operates the instance: the
|
||||
// account sheet's tiles and the badge on its button. The workouts above
|
||||
// the navigator, so home and a workout's page share their deletions.
|
||||
builder: (context, child) => PersonScope(
|
||||
person: widget.person,
|
||||
child: MultiBlocProvider(
|
||||
providers: [
|
||||
BlocProvider(
|
||||
create: (context) =>
|
||||
OperatingCubit(AppScope.of(context).instanceOperators),
|
||||
),
|
||||
// Where sync stands: Settings' card and the dot on the cog, as
|
||||
// Learn's and Todo's.
|
||||
BlocProvider(
|
||||
create: (context) =>
|
||||
SyncStatusBloc(PersonScope.of<TrainPerson>(context).sync),
|
||||
),
|
||||
BlocProvider(
|
||||
create: (context) {
|
||||
final train = PersonScope.of<TrainPerson>(context);
|
||||
return WorkoutsCubit(train.workouts, train.deletions)..open();
|
||||
},
|
||||
),
|
||||
BlocProvider(
|
||||
create: (context) {
|
||||
final train = PersonScope.of<TrainPerson>(context);
|
||||
return DaysCubit(train.days, train.loop)..open();
|
||||
},
|
||||
),
|
||||
BlocProvider(
|
||||
create: (context) {
|
||||
final train = PersonScope.of<TrainPerson>(context);
|
||||
return PlansCubit(train.plans, train.planDeletions)..open();
|
||||
},
|
||||
),
|
||||
// The places and the strength plans, which the plans' lists, a
|
||||
// session and Equipment share (ADR 0034, ADR 0035).
|
||||
BlocProvider(
|
||||
create: (context) {
|
||||
final train = PersonScope.of<TrainPerson>(context);
|
||||
return PlacesCubit(train.places, train.chosenPlace)..open();
|
||||
},
|
||||
),
|
||||
// Their weights, which Progress and Your body share (D64).
|
||||
BlocProvider(
|
||||
create: (context) {
|
||||
final train = PersonScope.of<TrainPerson>(context);
|
||||
return WeightsCubit(train.weights, train.profile)..open();
|
||||
},
|
||||
),
|
||||
BlocProvider(
|
||||
create: (context) {
|
||||
final train = PersonScope.of<TrainPerson>(context);
|
||||
return StrengthPlansCubit(
|
||||
train.strengthPlans,
|
||||
train.strengthPlanDeletions,
|
||||
)..open();
|
||||
},
|
||||
),
|
||||
BlocProvider(
|
||||
create: (context) {
|
||||
final train = PersonScope.of<TrainPerson>(context);
|
||||
return RoutesCubit(train.routes, train.routeDeletions)..open();
|
||||
},
|
||||
),
|
||||
],
|
||||
child: _Recording(
|
||||
child: ScreenColor(
|
||||
color: PaletteColor.carrot.background,
|
||||
child: child!,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/// The person's recording (ADR 0030, D21) above [child], where the device
|
||||
|
|
|
|||
|
|
@ -13,3 +13,13 @@ const trainLocalizationsDelegates = <LocalizationsDelegate<Object?>>[
|
|||
HalkyonUiLocalizations.delegate,
|
||||
...GlobalMaterialLocalizations.delegates,
|
||||
];
|
||||
|
||||
/// The languages a person can choose for the app in Settings
|
||||
/// (`DeviceLookCard`), in the order the picker lists them, each named in
|
||||
/// its own language: every one the app speaks (`app_en_GB.arb`,
|
||||
/// `app_en_US.arb`, `app_de.arb`).
|
||||
const trainLanguages = <AppLanguage>[
|
||||
(tag: 'en-GB', name: 'English (UK)'),
|
||||
(tag: 'en-US', name: 'English (US)'),
|
||||
(tag: 'de', name: 'Deutsch'),
|
||||
];
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@ import 'package:halkyon_app/halkyon_app.dart';
|
|||
import 'package:halkyon_train_flutter/l10n/app_localizations.dart';
|
||||
import 'package:halkyon_train_flutter/src/app/train_dependencies.dart';
|
||||
import 'package:halkyon_train_flutter/src/app/train_frame.dart';
|
||||
import 'package:halkyon_train_flutter/src/app/train_languages.dart';
|
||||
import 'package:halkyon_train_flutter/src/app/train_paths.dart';
|
||||
import 'package:halkyon_train_flutter/src/feature/equipment/widget/equipment_screen.dart';
|
||||
import 'package:halkyon_train_flutter/src/feature/health/widget/health_screen.dart';
|
||||
|
|
@ -29,7 +30,7 @@ class const SettingsButton({super.key}) extends StatelessWidget {
|
|||
}
|
||||
|
||||
/// Settings, over the tabs (ADR 0030, D60), grouped in cards as Learn's:
|
||||
/// where sync stands, with Sync now; the operator's card for whoever operates the instance; the training's
|
||||
/// where sync stands, with Sync now; the operator's card for whoever operates the instance; how this device shows the app (appearance, language); the training's
|
||||
/// screens (the body's figures, Health Connect, the Polar Loop, music,
|
||||
/// those the device has); the account, near the foot (halkyon_app's
|
||||
/// sections: whose it is on which instance, switching, signing out and
|
||||
|
|
@ -74,6 +75,11 @@ class const SettingsScreen({super.key}) extends StatelessWidget {
|
|||
// the instance alone (Halkyon Learn's ADR 0021, D34),
|
||||
// first, as the cog's count leads here.
|
||||
const InstanceOperatorCard(below: 12),
|
||||
// How this device shows the app, its appearance and
|
||||
// language, first of the app's own, as Learn's
|
||||
// (halkyon_app's, ADR 0014's amendment of 4 Nov 2026).
|
||||
const DeviceLookCard(languages: trainLanguages),
|
||||
const SizedBox(height: 12),
|
||||
SectionCard(
|
||||
padding: const EdgeInsets.symmetric(vertical: 8),
|
||||
child: Column(
|
||||
|
|
|
|||
Loading…
Reference in a new issue