Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions assets/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@
"blur_borders": true,
"sync_interval_minutes": 15,
"delete_orphaned_files": true,
"show_clock": true,
"clock_size": "large",
"clock_position": "bottomRight",
"use_am_pm": false,
"active_source": "",
"sources": {
"nextcloud_link": {
Expand Down
3 changes: 3 additions & 0 deletions lib/domain/interfaces/config_provider.dart
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,9 @@ abstract class ConfigProvider extends ChangeNotifier {

String get clockPosition; // 'bottomRight', 'bottomLeft', 'topRight', 'topLeft'
set clockPosition(String value);

bool get useAmPm; // Use 12h format with AM/PM
set useAmPm(bool value);

// Display schedule settings (day/night mode)
bool get scheduleEnabled; // Enable day/night schedule
Expand Down
8 changes: 8 additions & 0 deletions lib/infrastructure/services/json_config_service.dart
Original file line number Diff line number Diff line change
Expand Up @@ -383,6 +383,14 @@ class JsonConfigService extends ConfigProvider {
set clockPosition(String value) {
_config['clock_position'] = value;
}

@override
bool get useAmPm => _config['use_am_pm'] ?? false;

@override
set useAmPm(bool value) {
_config['use_am_pm'] = value;
}

// Display schedule settings (day/night mode)
@override
Expand Down
2 changes: 2 additions & 0 deletions lib/l10n/app_de.arb
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
"showClockSubtitle": "Uhrzeit auf der Diashow anzeigen",
"size": "Größe",
"position": "Position",
"useAmPm": "AM/PM verwenden",
"useAmPmSubtitle": "Uhr im 12-Stunden-Format mit AM/PM anzeigen",

"sectionPhotoInfo": "Foto-Informationen",
"showPhotoInfo": "Foto-Info anzeigen",
Expand Down
2 changes: 2 additions & 0 deletions lib/l10n/app_en.arb
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
"showClockSubtitle": "Display time on slideshow",
"size": "Size",
"position": "Position",
"useAmPm": "Use AM/PM",
"useAmPmSubtitle": "Display clock in 12-hour format with AM/PM",

"sectionPhotoInfo": "Photo Information",
"showPhotoInfo": "Show Photo Info",
Expand Down
12 changes: 12 additions & 0 deletions lib/l10n/app_localizations.dart
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,18 @@ abstract class AppLocalizations {
/// **'Position'**
String get position;

/// No description provided for @useAmPm.
///
/// In en, this message translates to:
/// **'Use AM/PM'**
String get useAmPm;

/// No description provided for @useAmPmSubtitle.
///
/// In en, this message translates to:
/// **'Display clock in 12-hour format with AM/PM'**
String get useAmPmSubtitle;

/// No description provided for @sectionPhotoInfo.
///
/// In en, this message translates to:
Expand Down
6 changes: 6 additions & 0 deletions lib/l10n/app_localizations_de.dart
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,12 @@ class AppLocalizationsDe extends AppLocalizations {
@override
String get position => 'Position';

@override
String get useAmPm => 'AM/PM verwenden';

@override
String get useAmPmSubtitle => 'Uhr im 12-Stunden-Format mit AM/PM anzeigen';

@override
String get sectionPhotoInfo => 'Foto-Informationen';

Expand Down
6 changes: 6 additions & 0 deletions lib/l10n/app_localizations_en.dart
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,12 @@ class AppLocalizationsEn extends AppLocalizations {
@override
String get position => 'Position';

@override
String get useAmPm => 'Use AM/PM';

@override
String get useAmPmSubtitle => 'Display clock in 12-hour format with AM/PM';

@override
String get sectionPhotoInfo => 'Photo Information';

Expand Down
13 changes: 13 additions & 0 deletions lib/ui/screens/settings_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ class _SettingsScreenState extends State<SettingsScreen> with WidgetsBindingObse
late bool _showClock;
late String _clockSize;
late String _clockPosition;
late bool _useAmPm;

// Photo info settings
late bool _showPhotoInfo;
Expand Down Expand Up @@ -150,6 +151,7 @@ class _SettingsScreenState extends State<SettingsScreen> with WidgetsBindingObse
_showClock = config.showClock;
_clockSize = config.clockSize;
_clockPosition = config.clockPosition;
_useAmPm = config.useAmPm;

// Photo info settings
_showPhotoInfo = config.showPhotoInfo;
Expand Down Expand Up @@ -336,6 +338,7 @@ class _SettingsScreenState extends State<SettingsScreen> with WidgetsBindingObse
config.showClock = _showClock;
config.clockSize = _clockSize;
config.clockPosition = _clockPosition;
config.useAmPm = _useAmPm;

// Photo info settings
config.showPhotoInfo = _showPhotoInfo;
Expand Down Expand Up @@ -472,6 +475,16 @@ class _SettingsScreenState extends State<SettingsScreen> with WidgetsBindingObse
_buildClockSizeSelector(),
const SizedBox(height: 8),
_buildClockPositionSelector(),
const SizedBox(height: 16),
SwitchListTile(
title: Text(AppLocalizations.of(context)!.useAmPm),
subtitle: Text(AppLocalizations.of(context)!.useAmPmSubtitle),
secondary: const Icon(Icons.more_time),
value: _useAmPm,
onChanged: (value) {
setState(() => _useAmPm = value);
},
),
],

const SizedBox(height: 24),
Expand Down
3 changes: 2 additions & 1 deletion lib/ui/screens/slideshow_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -727,9 +727,10 @@ class _SlideshowScreenState extends State<SlideshowScreen> with TickerProviderSt
// 2. Clock Overlay
if (config.showClock)
ClockOverlay(
key: ValueKey('clock_${config.clockSize}_${config.clockPosition}'),
key: ValueKey('clock_${config.clockSize}_${config.clockPosition}_${config.useAmPm}'),
size: config.clockSize,
position: config.clockPosition,
useAmPm: config.useAmPm,
),

// 3. Photo Info Overlay
Expand Down
11 changes: 10 additions & 1 deletion lib/ui/widgets/clock_overlay.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,13 @@ import 'package:flutter/material.dart';
class ClockOverlay extends StatefulWidget {
final String size; // 'small', 'medium', 'large'
final String position; // 'bottomRight', 'bottomLeft', 'topRight', 'topLeft'
final bool useAmPm;

const ClockOverlay({
super.key,
required this.size,
required this.position,
required this.useAmPm,
});

@override
Expand Down Expand Up @@ -78,7 +80,14 @@ class _ClockOverlayState extends State<ClockOverlay> {

@override
Widget build(BuildContext context) {
final timeString = '${_now.hour.toString().padLeft(2, '0')}:${_now.minute.toString().padLeft(2, '0')}';
String timeString;
if (widget.useAmPm) {
final hour = _now.hour % 12 == 0 ? 12 : _now.hour % 12;
final amPm = _now.hour < 12 ? 'AM' : 'PM';
timeString = '$hour:${_now.minute.toString().padLeft(2, '0')} $amPm';
} else {
timeString = '${_now.hour.toString().padLeft(2, '0')}:${_now.minute.toString().padLeft(2, '0')}';
}

return Align(
alignment: _alignment,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ class FakeConfigProvider extends ChangeNotifier implements ConfigProvider {
@override
Future<void> save() async {}

@override
bool useAmPm = false;

@override
String get activeSourceType => '';

Expand Down
3 changes: 3 additions & 0 deletions test/infrastructure/services/app_initializer_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ class FakeConfigProvider extends ChangeNotifier implements ConfigProvider {
@override
Future<void> save() async {}

@override
bool useAmPm = false;

@override
String get activeSourceType => '';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,9 @@ class MockConfigProvider extends ChangeNotifier implements ConfigProvider {
@override
String? get customPhotoPath => _customPhotoPath;

@override
bool useAmPm = false;

@override
set customPhotoPath(String? value) {
_customPhotoPath = value;
Expand Down