Refactor profiles

This commit is contained in:
problematicconsumer
2023-11-26 21:20:58 +03:30
parent e2f5f51176
commit 829d58a1a2
49 changed files with 1206 additions and 1024 deletions

View File

@@ -0,0 +1,50 @@
import 'package:flutter/material.dart';
import 'package:hiddify/domain/failures.dart';
class CustomAlertDialog extends StatelessWidget {
const CustomAlertDialog({
super.key,
this.title,
required this.message,
});
final String? title;
final String message;
factory CustomAlertDialog.fromError(PresentableError error) =>
CustomAlertDialog(
title: error.message == null ? null : error.type,
message: error.message ?? error.type,
);
Future<void> show(BuildContext context) async {
await showDialog(
context: context,
useRootNavigator: true,
builder: (context) => this,
);
}
@override
Widget build(BuildContext context) {
final localizations = MaterialLocalizations.of(context);
return AlertDialog(
title: title != null ? Text(title!) : null,
content: SingleChildScrollView(
child: SizedBox(
width: 468,
child: Text(message),
),
),
actions: [
TextButton(
onPressed: () {
Navigator.of(context).pop();
},
child: Text(localizations.okButtonLabel),
),
],
);
}
}