adding i18n to all other pages

This commit is contained in:
Azmat-7860
2026-10-03 11:22:48 +05:30
parent 47656678e1
commit 3fbeb606a8
22 changed files with 2526 additions and 249 deletions
@@ -5,6 +5,7 @@ import 'package:flutter_foreground_task/flutter_foreground_task.dart';
import 'package:geolocator/geolocator.dart';
import 'package:permission_handler/permission_handler.dart' as ph;
import '../../l10n/app_localizations.dart';
import 'attendance_math.dart';
import 'attendance_storage.dart';
@@ -261,18 +262,17 @@ class AttendanceService {
final bool? go = await showDialog<bool>(
context: context,
builder: (c) => AlertDialog(
title: const Text('Keep tracking running'),
content: const Text(
'Xiaomi, Oppo, Vivo and Samsung phones stop background tracking '
'to save battery. Allow "Unrestricted" battery use for this app '
'so duty tracking keeps working when the screen is off?'),
title: Text(AppLocalizations.of(context)!.keepTracking),
content: Text(
AppLocalizations.of(context)!.batteryExemptBody),
actions: [
TextButton(
onPressed: () => Navigator.of(c).pop(false),
child: const Text('Later')),
child: Text(AppLocalizations.of(context)!.laterBtn)),
TextButton(
onPressed: () => Navigator.of(c).pop(true),
child: const Text('Open settings')),
child: Text(
AppLocalizations.of(context)!.openSettings)),
],
),
);
+33 -21
View File
@@ -5,6 +5,7 @@ import 'package:flutter_foreground_task/flutter_foreground_task.dart';
import '../../Utils/image_constant.dart';
import '../../Utils/size_utils.dart';
import '../../l10n/app_localizations.dart';
import '../../theme/app_style.dart';
import '../../widgets/app_bar/appbar_image.dart';
import '../../widgets/app_bar/appbar_title.dart';
@@ -116,9 +117,9 @@ class _PunchScreenState extends State<PunchScreen> {
await AttendanceService.maybeAskBatteryExemption(context);
}
await _refresh();
_msg('Punched in - tracking every 5 min', false);
_msg(AppLocalizations.of(context)!.punchedInTracking, false);
} catch (e) {
_msg('Punch in failed: $e', true);
_msg(AppLocalizations.of(context)!.punchInFailed(e.toString()), true);
} finally {
if (mounted) setState(() => _busy = false);
}
@@ -135,22 +136,21 @@ class _PunchScreenState extends State<PunchScreen> {
showDialog(
context: context,
builder: (c) => AlertDialog(
title: const Text('Duty summary'),
title: Text(AppLocalizations.of(context)!.dutySummary),
content: Text(
'Points recorded: $pts\n'
'Distance (straight line): ${km.toStringAsFixed(2)} km\n'
'Road distance: coming in step 4 (free API).',
AppLocalizations.of(context)!.dutySummaryBody(
pts.toString(), km.toStringAsFixed(2)),
),
actions: [
TextButton(
onPressed: () => Navigator.of(c).pop(),
child: const Text('OK'),
child: Text(AppLocalizations.of(context)!.ok),
),
],
),
);
} catch (e) {
_msg('Punch out failed: $e', true);
_msg(AppLocalizations.of(context)!.punchOutFailed(e.toString()), true);
} finally {
if (mounted) setState(() => _busy = false);
}
@@ -180,7 +180,8 @@ class _PunchScreenState extends State<PunchScreen> {
onTap: () => Navigator.pop(context),
),
centerTitle: true,
title: AppbarTitle(text: 'Duty Punch'),
title: AppbarTitle(
text: AppLocalizations.of(context)!.dutyPunch),
),
body: SingleChildScrollView(
padding: const EdgeInsets.all(16),
@@ -192,22 +193,22 @@ class _PunchScreenState extends State<PunchScreen> {
CustomButton(
height: getVerticalSize(50),
text: _busy
? 'Please wait...'
: (_punchedIn ? 'Punch Out' : 'Punch In'),
? AppLocalizations.of(context)!.pleaseWait
: (_punchedIn
? AppLocalizations.of(context)!.punchOut
: AppLocalizations.of(context)!.punchIn),
margin: getMargin(top: 8, bottom: 5),
onTap: _busy ? () {} : (_punchedIn ? _onPunchOut : _onPunchIn),
),
const SizedBox(height: 8),
Text(
'Keeps recording one location every 5 min, even with the app '
'minimized. For Xiaomi/Oppo/Vivo/Samsung allow Unrestricted '
'battery use or tracking may pause.',
AppLocalizations.of(context)!.batteryNote,
style: AppStyle.txtGilroyMedium16Bluegray900.copyWith(
fontSize: 12,
),
),
const SizedBox(height: 20),
Text('Recent duties',
Text(AppLocalizations.of(context)!.recentDuties,
style: AppStyle.txtGilroyMedium16Bluegray900.copyWith(
fontWeight: FontWeight.bold,
)),
@@ -238,20 +239,29 @@ class _PunchScreenState extends State<PunchScreen> {
),
const SizedBox(width: 8),
Text(
_punchedIn ? 'Punched IN' : 'Punched OUT',
_punchedIn
? AppLocalizations.of(context)!.punchedIn
: AppLocalizations.of(context)!.punchedOut,
style: const TextStyle(
fontSize: 18, fontWeight: FontWeight.bold),
),
],
),
const SizedBox(height: 12),
Text('Session: ${_sessionId ?? '-'}'),
if (_punchInTime != null) Text('Since: $_punchInTime'),
Text(AppLocalizations.of(context)!
.sessionRow(_sessionId ?? '-')),
if (_punchInTime != null)
Text(AppLocalizations.of(context)!
.sinceRow(_punchInTime!)),
const SizedBox(height: 8),
Text('Points: $_points',
Text(
AppLocalizations.of(context)!
.pointsRow(_points.toString()),
style:
const TextStyle(fontSize: 16, fontWeight: FontWeight.w600)),
Text('Distance: ${_km.toStringAsFixed(2)} km',
Text(
AppLocalizations.of(context)!
.distanceRow(_km.toStringAsFixed(2)),
style:
const TextStyle(fontSize: 16, fontWeight: FontWeight.w600)),
],
@@ -268,7 +278,9 @@ class _PunchScreenState extends State<PunchScreen> {
title: Text('${s['punch_in']}',
style: const TextStyle(fontSize: 12)),
subtitle: Text(
'Out: ${s['punch_out'] ?? '-'} • ${km.toStringAsFixed(2)} km',
AppLocalizations.of(context)!.historyOutRow(
(s['punch_out'] ?? '-').toString(),
km.toStringAsFixed(2)),
style: const TextStyle(fontSize: 11)),
trailing: Text(status,
style: TextStyle(