fix: alot
This commit is contained in:
@@ -2,6 +2,7 @@ import 'package:flutter/material.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
|
||||
import '../l10n/app_localizations.dart';
|
||||
import '../utils/navigation.dart';
|
||||
import '../viewmodels/registration_view_model.dart';
|
||||
import '../viewmodels/remote_sync_view_model.dart';
|
||||
|
||||
@@ -25,6 +26,8 @@ class _RegistrationViewState extends State<RegistrationView> {
|
||||
});
|
||||
}
|
||||
|
||||
AppLocalizations get _l10n => AppLocalizations.of(context);
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
_deviceNameController.dispose();
|
||||
@@ -39,6 +42,14 @@ class _RegistrationViewState extends State<RegistrationView> {
|
||||
|
||||
return Scaffold(
|
||||
backgroundColor: Theme.of(context).colorScheme.surface,
|
||||
appBar: AppBar(
|
||||
backgroundColor: Colors.transparent,
|
||||
leading: IconButton(
|
||||
tooltip: l10n.cancel,
|
||||
onPressed: () => context.popOrGo('/admin'),
|
||||
icon: const Icon(Icons.close_rounded),
|
||||
),
|
||||
),
|
||||
body: SafeArea(
|
||||
child: Center(
|
||||
child: SingleChildScrollView(
|
||||
@@ -87,7 +98,7 @@ class _RegistrationViewState extends State<RegistrationView> {
|
||||
const CircularProgressIndicator(strokeWidth: 3),
|
||||
const SizedBox(height: 16),
|
||||
Text(
|
||||
'Connecting to server…',
|
||||
_l10n.connectingToServer,
|
||||
style: Theme.of(context).textTheme.titleMedium,
|
||||
),
|
||||
],
|
||||
@@ -106,12 +117,12 @@ class _RegistrationViewState extends State<RegistrationView> {
|
||||
),
|
||||
const SizedBox(height: 24),
|
||||
Text(
|
||||
'Failed to connect',
|
||||
_l10n.failedToConnect,
|
||||
style: Theme.of(context).textTheme.titleLarge,
|
||||
),
|
||||
const SizedBox(height: 12),
|
||||
Text(
|
||||
vm.errorMessage ?? 'Unknown error',
|
||||
vm.errorMessage ?? _l10n.unknownError,
|
||||
textAlign: TextAlign.center,
|
||||
style: Theme.of(context).textTheme.bodyMedium?.copyWith(
|
||||
color: Theme.of(
|
||||
@@ -123,7 +134,7 @@ class _RegistrationViewState extends State<RegistrationView> {
|
||||
FilledButton.icon(
|
||||
onPressed: () => vm.retry(),
|
||||
icon: const Icon(Icons.refresh),
|
||||
label: const Text('Retry'),
|
||||
label: Text(_l10n.retry),
|
||||
),
|
||||
],
|
||||
);
|
||||
@@ -142,13 +153,13 @@ class _RegistrationViewState extends State<RegistrationView> {
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
Text(
|
||||
'Connect to remote server',
|
||||
_l10n.connectToRemoteServer,
|
||||
textAlign: TextAlign.center,
|
||||
style: Theme.of(context).textTheme.headlineSmall,
|
||||
),
|
||||
const SizedBox(height: 8),
|
||||
Text(
|
||||
'Select your venue to link this device',
|
||||
_l10n.selectVenueToLink,
|
||||
textAlign: TextAlign.center,
|
||||
style: Theme.of(context).textTheme.bodyMedium?.copyWith(
|
||||
color: Theme.of(
|
||||
@@ -158,7 +169,7 @@ class _RegistrationViewState extends State<RegistrationView> {
|
||||
),
|
||||
const SizedBox(height: 32),
|
||||
Text(
|
||||
'Select venue',
|
||||
_l10n.selectVenue,
|
||||
style: Theme.of(context).textTheme.labelLarge?.copyWith(
|
||||
color: Theme.of(
|
||||
context,
|
||||
@@ -217,7 +228,7 @@ class _RegistrationViewState extends State<RegistrationView> {
|
||||
const SizedBox(height: 24),
|
||||
TextButton(
|
||||
onPressed: () => vm.retry(),
|
||||
child: const Text('Refresh venues'),
|
||||
child: Text(_l10n.refreshVenues),
|
||||
),
|
||||
],
|
||||
);
|
||||
@@ -244,7 +255,7 @@ class _RegistrationViewState extends State<RegistrationView> {
|
||||
),
|
||||
const SizedBox(height: 8),
|
||||
Text(
|
||||
'Enter device details to complete pairing',
|
||||
_l10n.enterDeviceDetails,
|
||||
textAlign: TextAlign.center,
|
||||
style: Theme.of(context).textTheme.bodyMedium?.copyWith(
|
||||
color: Theme.of(
|
||||
@@ -255,20 +266,19 @@ class _RegistrationViewState extends State<RegistrationView> {
|
||||
const SizedBox(height: 32),
|
||||
TextFormField(
|
||||
controller: _deviceNameController,
|
||||
decoration: const InputDecoration(
|
||||
labelText: 'Device name',
|
||||
decoration: InputDecoration(
|
||||
labelText: _l10n.deviceName,
|
||||
hintText: 'e.g. Bar terminal 1',
|
||||
border: OutlineInputBorder(),
|
||||
),
|
||||
validator: (v) => v == null || v.trim().isEmpty
|
||||
? 'Device name is required'
|
||||
: null,
|
||||
validator: (v) =>
|
||||
v == null || v.trim().isEmpty ? _l10n.deviceNameRequired : null,
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
TextFormField(
|
||||
controller: _regCodeController,
|
||||
decoration: const InputDecoration(
|
||||
labelText: 'Registration code',
|
||||
decoration: InputDecoration(
|
||||
labelText: _l10n.registrationCode,
|
||||
hintText: '6-character code from dashboard',
|
||||
border: OutlineInputBorder(),
|
||||
counterText: '',
|
||||
@@ -276,7 +286,7 @@ class _RegistrationViewState extends State<RegistrationView> {
|
||||
maxLength: 6,
|
||||
textCapitalization: TextCapitalization.characters,
|
||||
validator: (v) => v == null || v.trim().length < 6
|
||||
? 'Enter the 6-character code'
|
||||
? _l10n.enterRegistrationCode
|
||||
: null,
|
||||
),
|
||||
const SizedBox(height: 8),
|
||||
@@ -298,7 +308,7 @@ class _RegistrationViewState extends State<RegistrationView> {
|
||||
onPressed: () {
|
||||
vm.reset();
|
||||
},
|
||||
child: const Text('Back'),
|
||||
child: Text(_l10n.back),
|
||||
),
|
||||
const SizedBox(width: 12),
|
||||
Expanded(
|
||||
@@ -312,7 +322,7 @@ class _RegistrationViewState extends State<RegistrationView> {
|
||||
.toUpperCase(),
|
||||
);
|
||||
},
|
||||
child: const Text('Register'),
|
||||
child: Text(_l10n.register),
|
||||
),
|
||||
),
|
||||
],
|
||||
@@ -330,7 +340,7 @@ class _RegistrationViewState extends State<RegistrationView> {
|
||||
const CircularProgressIndicator(strokeWidth: 3),
|
||||
const SizedBox(height: 24),
|
||||
Text(
|
||||
'Registering device…',
|
||||
_l10n.registeringDevice,
|
||||
style: Theme.of(context).textTheme.titleMedium,
|
||||
),
|
||||
],
|
||||
@@ -349,7 +359,7 @@ class _RegistrationViewState extends State<RegistrationView> {
|
||||
),
|
||||
const SizedBox(height: 24),
|
||||
Text(
|
||||
'Device registered!',
|
||||
_l10n.deviceRegistered,
|
||||
textAlign: TextAlign.center,
|
||||
style: Theme.of(context).textTheme.headlineSmall,
|
||||
),
|
||||
@@ -365,7 +375,7 @@ class _RegistrationViewState extends State<RegistrationView> {
|
||||
),
|
||||
const SizedBox(height: 8),
|
||||
Text(
|
||||
'Open tabs will sync to the dashboard.',
|
||||
_l10n.openTabsWillSync,
|
||||
textAlign: TextAlign.center,
|
||||
style: Theme.of(context).textTheme.bodySmall?.copyWith(
|
||||
color: Theme.of(
|
||||
@@ -378,7 +388,7 @@ class _RegistrationViewState extends State<RegistrationView> {
|
||||
// Once configured, the router redirects to /bar by itself.
|
||||
onPressed: () => context.read<RemoteSyncViewModel>().activate(),
|
||||
icon: const Icon(Icons.arrow_forward),
|
||||
label: const Text('Start using KoolTap'),
|
||||
label: Text(_l10n.done),
|
||||
),
|
||||
],
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user