mirror of
https://github.com/gabehf/Fladder.git
synced 2026-03-13 17:30:31 -07:00
Init repo
This commit is contained in:
commit
764b6034e3
566 changed files with 212335 additions and 0 deletions
47
lib/screens/settings/widgets/settings_message_box.dart
Normal file
47
lib/screens/settings/widgets/settings_message_box.dart
Normal file
|
|
@ -0,0 +1,47 @@
|
|||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
|
||||
enum MessageType {
|
||||
info,
|
||||
warning,
|
||||
error;
|
||||
|
||||
Color color(BuildContext context) {
|
||||
switch (this) {
|
||||
case info:
|
||||
return Theme.of(context).colorScheme.surface;
|
||||
case warning:
|
||||
return Theme.of(context).colorScheme.primaryContainer;
|
||||
case error:
|
||||
return Theme.of(context).colorScheme.errorContainer;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class SettingsMessageBox extends ConsumerWidget {
|
||||
final String message;
|
||||
final MessageType messageType;
|
||||
const SettingsMessageBox(this.message, {this.messageType = MessageType.info, super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context, WidgetRef ref) {
|
||||
return SizedBox(
|
||||
width: double.infinity,
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 8).add(
|
||||
EdgeInsets.symmetric(
|
||||
horizontal: MediaQuery.paddingOf(context).horizontal,
|
||||
),
|
||||
),
|
||||
child: Card(
|
||||
elevation: 2,
|
||||
color: messageType.color(context),
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(8.0),
|
||||
child: Text(message),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue