Migrate to singbox
This commit is contained in:
@@ -1,6 +1,42 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:fluttertoast/fluttertoast.dart';
|
||||
|
||||
class CustomAlertDialog extends StatelessWidget {
|
||||
const CustomAlertDialog({
|
||||
super.key,
|
||||
this.title,
|
||||
required this.message,
|
||||
});
|
||||
|
||||
final String? title;
|
||||
final String message;
|
||||
|
||||
Future<void> show(BuildContext context) async {
|
||||
await showDialog(
|
||||
context: context,
|
||||
builder: (context) => this,
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final localizations = MaterialLocalizations.of(context);
|
||||
|
||||
return AlertDialog(
|
||||
title: title != null ? Text(title!) : null,
|
||||
content: Text(message),
|
||||
actions: [
|
||||
TextButton(
|
||||
onPressed: () {
|
||||
Navigator.of(context).pop();
|
||||
},
|
||||
child: Text(localizations.okButtonLabel),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
enum AlertType { info, error, success }
|
||||
|
||||
class CustomToast extends StatelessWidget {
|
||||
|
||||
31
lib/utils/custom_log_printer.dart
Normal file
31
lib/utils/custom_log_printer.dart
Normal file
@@ -0,0 +1,31 @@
|
||||
import 'dart:io';
|
||||
|
||||
import 'package:loggy/loggy.dart';
|
||||
|
||||
class MultiLogPrinter extends LoggyPrinter {
|
||||
MultiLogPrinter(this.consolePrinter, this.filePrinter);
|
||||
|
||||
final LoggyPrinter consolePrinter;
|
||||
final LoggyPrinter filePrinter;
|
||||
|
||||
@override
|
||||
void onLog(LogRecord record) {
|
||||
consolePrinter.onLog(record);
|
||||
filePrinter.onLog(record);
|
||||
}
|
||||
}
|
||||
|
||||
class FileLogPrinter extends LoggyPrinter {
|
||||
FileLogPrinter(String filePath) : _logFile = File(filePath);
|
||||
|
||||
final File _logFile;
|
||||
|
||||
late final _sink = _logFile.openWrite(
|
||||
mode: FileMode.writeOnly,
|
||||
);
|
||||
|
||||
@override
|
||||
void onLog(LogRecord record) {
|
||||
_sink.writeln(record.toString());
|
||||
}
|
||||
}
|
||||
@@ -36,7 +36,11 @@ class SliverLoadingBodyPlaceholder extends HookConsumerWidget {
|
||||
}
|
||||
|
||||
class SliverErrorBodyPlaceholder extends HookConsumerWidget {
|
||||
const SliverErrorBodyPlaceholder(this.msg, {super.key, this.icon});
|
||||
const SliverErrorBodyPlaceholder(
|
||||
this.msg, {
|
||||
super.key,
|
||||
this.icon = Icons.error,
|
||||
});
|
||||
|
||||
final String msg;
|
||||
final IconData? icon;
|
||||
@@ -48,8 +52,10 @@ class SliverErrorBodyPlaceholder extends HookConsumerWidget {
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
Icon(icon ?? Icons.error),
|
||||
const Gap(16),
|
||||
if (icon != null) ...[
|
||||
Icon(icon),
|
||||
const Gap(16),
|
||||
],
|
||||
Text(msg),
|
||||
],
|
||||
),
|
||||
|
||||
@@ -2,6 +2,7 @@ export 'alerts.dart';
|
||||
export 'async_mutation.dart';
|
||||
export 'bottom_sheet_page.dart';
|
||||
export 'callback_debouncer.dart';
|
||||
export 'custom_log_printer.dart';
|
||||
export 'custom_loggers.dart';
|
||||
export 'custom_text_form_field.dart';
|
||||
export 'link_parsers.dart';
|
||||
|
||||
Reference in New Issue
Block a user