Moved the result banner + spinner/button UI into a new stateless TryConnectionButton widget, used by both add and edit account screens. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
60 lines
1.7 KiB
Dart
60 lines
1.7 KiB
Dart
import 'package:flutter/material.dart';
|
|
|
|
/// Renders the "Try connection" button together with its success/error result.
|
|
///
|
|
/// The parent manages [testing], [okMessage], [errorMessage], and [onPressed]
|
|
/// state; this widget is purely presentational.
|
|
class TryConnectionButton extends StatelessWidget {
|
|
const TryConnectionButton({
|
|
super.key,
|
|
required this.testing,
|
|
required this.onPressed,
|
|
this.okMessage,
|
|
this.errorMessage,
|
|
this.buttonKey,
|
|
});
|
|
|
|
final bool testing;
|
|
final VoidCallback? onPressed;
|
|
final String? okMessage;
|
|
final String? errorMessage;
|
|
final Key? buttonKey;
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return Column(
|
|
crossAxisAlignment: CrossAxisAlignment.stretch,
|
|
children: [
|
|
if (okMessage != null)
|
|
Padding(
|
|
padding: const EdgeInsets.only(top: 8),
|
|
child: Text(
|
|
okMessage!,
|
|
style: TextStyle(color: Theme.of(context).colorScheme.primary),
|
|
),
|
|
),
|
|
if (errorMessage != null)
|
|
Padding(
|
|
padding: const EdgeInsets.only(top: 8),
|
|
child: Text(
|
|
errorMessage!,
|
|
style: TextStyle(color: Theme.of(context).colorScheme.error),
|
|
),
|
|
),
|
|
const SizedBox(height: 12),
|
|
OutlinedButton(
|
|
key: buttonKey,
|
|
onPressed: testing ? null : onPressed,
|
|
child: testing
|
|
? const SizedBox(
|
|
width: 16,
|
|
height: 16,
|
|
child: CircularProgressIndicator(strokeWidth: 2),
|
|
)
|
|
: const Text('Try connection'),
|
|
),
|
|
],
|
|
);
|
|
}
|
|
}
|