new UI + new targets.
This commit is contained in:
@@ -4,6 +4,7 @@ import '../services/app_settings.dart';
|
||||
import '../theme/app_theme.dart';
|
||||
import '../widgets/section.dart';
|
||||
import '../widgets/text_prompt.dart';
|
||||
import '../widgets/ui.dart';
|
||||
|
||||
/// Locations (strelišča), number of positions, and the camera IP of every
|
||||
/// position at every location.
|
||||
@@ -18,92 +19,81 @@ class CameraSettingsScreen extends StatelessWidget {
|
||||
final s = AppSettings.instance;
|
||||
final t = s.t;
|
||||
final setup = s.cameras;
|
||||
final surf = Surfaces.current;
|
||||
final c = Palette.current;
|
||||
const firstPort = CameraSetup.firstPort;
|
||||
|
||||
return Scaffold(
|
||||
backgroundColor: s.backgroundColor,
|
||||
appBar: AppBar(
|
||||
title: Text(t('Cameras'), style: const TextStyle(color: Colors.white)),
|
||||
backgroundColor: AppTheme.bar,
|
||||
iconTheme: const IconThemeData(color: Colors.white),
|
||||
scrolledUnderElevation: 0,
|
||||
),
|
||||
body: ListView(
|
||||
// Keep the last row clear of the system gesture bar (edge-to-edge)
|
||||
padding: EdgeInsets.fromLTRB(16, 4, 16, 24 + MediaQuery.paddingOf(context).bottom),
|
||||
body: Column(
|
||||
children: [
|
||||
SectionHeader(t('Locations')),
|
||||
GroupCard(children: [
|
||||
for (final location in setup.locations)
|
||||
SettingsTile(
|
||||
leading: Icon(
|
||||
location == setup.clubLocation ? Icons.verified_rounded : Icons.place_rounded,
|
||||
color: location == setup.clubLocation ? Colors.green : s.bulletColor,
|
||||
),
|
||||
title: location,
|
||||
subtitle: location == setup.clubLocation ? t('Added with the club code') : null,
|
||||
value: t('{n} cameras').replaceAll('{n}', '${setup.camerasIn(location)}'),
|
||||
onTap: () => _editLocation(context, location),
|
||||
),
|
||||
SettingsTile(
|
||||
leading: Icon(Icons.add_rounded, color: surf.textSecondary),
|
||||
title: t('Add location'),
|
||||
onTap: () => _addLocation(context),
|
||||
),
|
||||
]),
|
||||
|
||||
SectionHeader(t('Positions')),
|
||||
GroupCard(children: [
|
||||
SettingsTile(
|
||||
title: t('Number of positions'),
|
||||
trailing: Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
IconButton(
|
||||
icon: const Icon(Icons.remove_rounded),
|
||||
color: surf.textPrimary,
|
||||
onPressed: setup.positions > 1 ? () => s.setPositionCount(setup.positions - 1) : null,
|
||||
BackHeader(title: t('Cameras'), subtitle: t('Locations, positions and camera addresses')),
|
||||
Expanded(
|
||||
child: ListView(
|
||||
// Keep the last row clear of the system gesture bar (edge-to-edge)
|
||||
padding: EdgeInsets.fromLTRB(AppTheme.edge, 0, AppTheme.edge, 24 + MediaQuery.paddingOf(context).bottom),
|
||||
children: [
|
||||
SectionHeader(t('Locations')),
|
||||
GroupCard(children: [
|
||||
for (final location in setup.locations)
|
||||
SettingsTile(
|
||||
icon: location == setup.clubLocation ? Icons.verified_user_outlined : Icons.place_outlined,
|
||||
iconColor: location == setup.clubLocation ? c.accent : c.muted,
|
||||
title: location,
|
||||
subtitle: location == setup.clubLocation ? t('Added with the club code') : null,
|
||||
value: _cameraCount(s, setup.camerasIn(location)),
|
||||
onTap: () => _editLocation(context, location),
|
||||
),
|
||||
SettingsTile(
|
||||
icon: Icons.add_rounded,
|
||||
title: t('Add location'),
|
||||
titleColor: c.muted,
|
||||
showChevron: false,
|
||||
onTap: () => _addLocation(context),
|
||||
),
|
||||
SizedBox(
|
||||
width: 28,
|
||||
child: Text(
|
||||
'${setup.positions}',
|
||||
textAlign: TextAlign.center,
|
||||
style: TextStyle(fontSize: 18, fontWeight: FontWeight.bold, color: surf.textPrimary),
|
||||
]),
|
||||
|
||||
SectionHeader(t('Positions')),
|
||||
GroupCard(children: [
|
||||
SettingsTile(
|
||||
title: t('Number of positions'),
|
||||
trailing: Stepper3(
|
||||
value: '${setup.positions}',
|
||||
valueWidth: 44,
|
||||
onMinus: setup.positions > 1 ? () => s.setPositionCount(setup.positions - 1) : null,
|
||||
onPlus: setup.positions < CameraSetup.maxPositions ? () => s.setPositionCount(setup.positions + 1) : null,
|
||||
),
|
||||
),
|
||||
IconButton(
|
||||
icon: const Icon(Icons.add_rounded),
|
||||
color: surf.textPrimary,
|
||||
onPressed: setup.positions < CameraSetup.maxPositions
|
||||
? () => s.setPositionCount(setup.positions + 1)
|
||||
: null,
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
]),
|
||||
|
||||
for (final location in setup.locations) ...[
|
||||
SectionHeader(location),
|
||||
GroupCard(children: [
|
||||
SettingsTile(
|
||||
leading: Icon(Icons.bolt_rounded, color: s.bulletColor),
|
||||
title: t('Set all cameras from one IP'),
|
||||
subtitle: t('Ports {from}–{to}')
|
||||
.replaceAll('{from}', '$firstPort')
|
||||
.replaceAll('{to}', '${firstPort + setup.positions - 1}'),
|
||||
onTap: () => _editHost(context, location),
|
||||
),
|
||||
for (int p = 1; p <= setup.positions; p++)
|
||||
SettingsTile(
|
||||
title: '${t('Camera')} $p',
|
||||
value: setup.ipFor(p, location).isEmpty ? '—' : setup.ipFor(p, location),
|
||||
onTap: () => _editCamera(context, p, location),
|
||||
]),
|
||||
Padding(
|
||||
padding: const EdgeInsets.fromLTRB(4, 10, 4, 0),
|
||||
child: Text(t('One tile on the Shooting screen for each position.'),
|
||||
style: TextStyle(fontSize: 12, color: c.muted)),
|
||||
),
|
||||
]),
|
||||
],
|
||||
|
||||
for (final location in setup.locations) ...[
|
||||
SectionHeader(location),
|
||||
GroupCard(children: [
|
||||
SettingsTile(
|
||||
icon: Icons.bolt_rounded,
|
||||
iconColor: c.accent,
|
||||
title: t('Set all cameras from one IP'),
|
||||
subtitle: t('Ports {from}–{to}')
|
||||
.replaceAll('{from}', '$firstPort')
|
||||
.replaceAll('{to}', '${firstPort + setup.positions - 1}'),
|
||||
onTap: () => _editHost(context, location),
|
||||
),
|
||||
for (int p = 1; p <= setup.positions; p++)
|
||||
SettingsTile(
|
||||
title: '${t('Camera')} $p',
|
||||
value: setup.ipFor(p, location).isEmpty ? t('Not set up') : setup.ipFor(p, location),
|
||||
mono: setup.ipFor(p, location).isNotEmpty,
|
||||
valueColor: setup.ipFor(p, location).isEmpty ? c.faint : c.ink2,
|
||||
onTap: () => _editCamera(context, p, location),
|
||||
),
|
||||
]),
|
||||
],
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
@@ -111,6 +101,14 @@ class CameraSettingsScreen extends StatelessWidget {
|
||||
);
|
||||
}
|
||||
|
||||
static String _cameraCount(AppSettings s, int n) {
|
||||
if (s.language == 'Slovenian') {
|
||||
final mod = n % 100;
|
||||
return '$n ${mod == 1 ? 'kamera' : mod == 2 ? 'kameri' : (mod == 3 || mod == 4) ? 'kamere' : 'kamer'}';
|
||||
}
|
||||
return s.t('{n} cameras').replaceAll('{n}', '$n');
|
||||
}
|
||||
|
||||
Future<void> _addLocation(BuildContext context) async {
|
||||
final s = AppSettings.instance;
|
||||
final name = await showTextPrompt(context, title: s.t('Add location'), hint: s.t('e.g. Home'));
|
||||
@@ -139,6 +137,7 @@ class CameraSettingsScreen extends StatelessWidget {
|
||||
context,
|
||||
title: '${s.t('Set all cameras from one IP')} · $location',
|
||||
initial: first.split(':').first,
|
||||
mono: true,
|
||||
hint: '192.168.0.10',
|
||||
keyboardType: TextInputType.url,
|
||||
);
|
||||
@@ -151,6 +150,7 @@ class CameraSettingsScreen extends StatelessWidget {
|
||||
context,
|
||||
title: '${s.t('Camera')} $position · $location',
|
||||
initial: s.cameras.ipFor(position, location),
|
||||
mono: true,
|
||||
hint: '192.168.0.10:${CameraSetup.firstPort + position - 1}',
|
||||
keyboardType: TextInputType.url,
|
||||
resetLabel: s.t('Remove'),
|
||||
|
||||
Reference in New Issue
Block a user