Files
sharedinbox/lib/ui/widgets/try_connection_button.dart
T
Thomas GüttlerandClaude Sonnet 4.6 eff2940bb8 refactor: extract TryConnectionButton widget shared by account screens
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>
2026-04-24 16:35:10 +02:00

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'),
),
],
);
}
}