Apply dart format to all files

This commit is contained in:
dmit.b
2026-05-15 19:09:25 +03:00
parent 6497c1eebf
commit 69f3d09e62
11 changed files with 191 additions and 171 deletions
+124 -113
View File
@@ -67,141 +67,152 @@ class _LoginScreenState extends State<LoginScreen>
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
const Text(
'Family Safety',
textAlign: TextAlign.center,
style: TextStyle(fontSize: 32, fontWeight: FontWeight.bold),
),
const SizedBox(height: 24),
if (!kIsWeb) ...[
TextField(
controller: _serverUrlController,
decoration: const InputDecoration(
labelText: 'Server URL',
hintText: 'https://example.com/api',
border: OutlineInputBorder(),
prefixIcon: Icon(Icons.cloud_outlined),
const Text(
'Family Safety',
textAlign: TextAlign.center,
style: TextStyle(
fontSize: 32,
fontWeight: FontWeight.bold,
),
keyboardType: TextInputType.url,
),
const SizedBox(height: 16),
],
TabBar(
controller: _tabController,
tabs: const [
Tab(text: 'Login'),
Tab(text: 'Register'),
const SizedBox(height: 24),
if (!kIsWeb) ...[
TextField(
controller: _serverUrlController,
decoration: const InputDecoration(
labelText: 'Server URL',
hintText: 'https://example.com/api',
border: OutlineInputBorder(),
prefixIcon: Icon(Icons.cloud_outlined),
),
keyboardType: TextInputType.url,
),
const SizedBox(height: 16),
],
),
const SizedBox(height: 24),
TextField(
controller: _loginController,
decoration: const InputDecoration(
labelText: 'Login',
border: OutlineInputBorder(),
TabBar(
controller: _tabController,
tabs: const [
Tab(text: 'Login'),
Tab(text: 'Register'),
],
),
),
const SizedBox(height: 16),
TextField(
controller: _passwordController,
decoration: const InputDecoration(
labelText: 'Password',
border: OutlineInputBorder(),
const SizedBox(height: 24),
TextField(
controller: _loginController,
decoration: const InputDecoration(
labelText: 'Login',
border: OutlineInputBorder(),
),
),
obscureText: true,
),
if (_tabController.index == 1) ...[
const SizedBox(height: 16),
TextField(
controller: _secretKeyController,
controller: _passwordController,
decoration: const InputDecoration(
labelText: 'Secret Key',
labelText: 'Password',
border: OutlineInputBorder(),
),
obscureText: true,
),
],
const SizedBox(height: 16),
if (authProvider.error.isNotEmpty)
Text(
authProvider.error,
style: const TextStyle(color: Colors.red),
),
const SizedBox(height: 16),
ElevatedButton(
onPressed: authProvider.isLoading
? null
: () async {
if (!kIsWeb) {
final status = await Geolocator.checkPermission();
if (status == LocationPermission.denied) {
final requested = await Geolocator.requestPermission();
if (requested == LocationPermission.denied) {
authProvider.setError('Location permission denied');
if (_tabController.index == 1) ...[
const SizedBox(height: 16),
TextField(
controller: _secretKeyController,
decoration: const InputDecoration(
labelText: 'Secret Key',
border: OutlineInputBorder(),
),
obscureText: true,
),
],
const SizedBox(height: 16),
if (authProvider.error.isNotEmpty)
Text(
authProvider.error,
style: const TextStyle(color: Colors.red),
),
const SizedBox(height: 16),
ElevatedButton(
onPressed: authProvider.isLoading
? null
: () async {
if (!kIsWeb) {
final status =
await Geolocator.checkPermission();
if (status == LocationPermission.denied) {
final requested =
await Geolocator.requestPermission();
if (requested == LocationPermission.denied) {
authProvider.setError(
'Location permission denied',
);
return;
}
}
if (status ==
LocationPermission.deniedForever) {
authProvider.setError(
'Location permission permanently denied. Please enable it in settings.',
);
return;
}
}
if (status == LocationPermission.deniedForever) {
authProvider.setError('Location permission permanently denied. Please enable it in settings.');
return;
if (!kIsWeb) {
final newUrl = _serverUrlController.text.trim();
if (newUrl.isNotEmpty &&
newUrl != settings.baseUrl) {
ApiConfig.setBaseUrl(newUrl);
await settings.setBaseUrl(newUrl);
}
}
}
if (!kIsWeb) {
final newUrl = _serverUrlController.text.trim();
if (newUrl.isNotEmpty && newUrl != settings.baseUrl) {
ApiConfig.setBaseUrl(newUrl);
await settings.setBaseUrl(newUrl);
}
}
if (_tabController.index == 0) {
try {
await authProvider.login(
_loginController.text,
_passwordController.text,
if (_tabController.index == 0) {
try {
await authProvider.login(
_loginController.text,
_passwordController.text,
);
if (!context.mounted) return;
Navigator.of(
context,
).pushReplacementNamed('/map');
} catch (e) {
// Error is handled by provider
}
} else {
if (_secretKeyController.text != _secretKey) {
authProvider.setError('Invalid secret key');
return;
}
Digest digest = md5.convert(
utf8.encode(_secretKeyController.text),
);
if (!context.mounted) return;
Navigator.of(
context,
).pushReplacementNamed('/map');
} catch (e) {
// Error is handled by provider
String secretKeyHash = hex.encode(digest.bytes);
try {
await authProvider.register(
_loginController.text,
_passwordController.text,
secretKeyHash,
);
} catch (e) {
// Error is handled by provider
}
}
} else {
if (_secretKeyController.text != _secretKey) {
authProvider.setError('Invalid secret key');
return;
}
Digest digest = md5.convert(
utf8.encode(_secretKeyController.text),
);
String secretKeyHash = hex.encode(digest.bytes);
try {
await authProvider.register(
_loginController.text,
_passwordController.text,
secretKeyHash,
);
} catch (e) {
// Error is handled by provider
}
}
},
child: authProvider.isLoading
? const SizedBox(
height: 20,
width: 20,
child: CircularProgressIndicator(strokeWidth: 2),
)
: Text(
_tabController.index == 0 ? 'Login' : 'Register',
),
),
],
},
child: authProvider.isLoading
? const SizedBox(
height: 20,
width: 20,
child: CircularProgressIndicator(strokeWidth: 2),
)
: Text(
_tabController.index == 0 ? 'Login' : 'Register',
),
),
],
),
),
),
),
),
),
),
);
}