forked from alexvasl/drifter_app
added flush bar + moved widgets
This commit is contained in:
parent
578a461075
commit
651a4e2421
@ -1,87 +0,0 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:drifter/theme/app_colors.dart';
|
||||
|
||||
import 'ok_button_widget.dart';
|
||||
|
||||
class DeleteKeysDialog extends StatelessWidget {
|
||||
const DeleteKeysDialog({
|
||||
super.key,
|
||||
required this.onNoPressed,
|
||||
required this.onYesPressed,
|
||||
});
|
||||
|
||||
final void Function()? onNoPressed;
|
||||
final void Function()? onYesPressed;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Dialog(
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
),
|
||||
child: Container(
|
||||
constraints: const BoxConstraints(maxWidth: 600),
|
||||
decoration: BoxDecoration(
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
color: Colors.white,
|
||||
),
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Container(
|
||||
padding: const EdgeInsets.symmetric(vertical: 24),
|
||||
decoration: BoxDecoration(
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
color: Colors.redAccent,
|
||||
),
|
||||
child: const Center(
|
||||
child: Text(
|
||||
'Delete Keys!',
|
||||
style: TextStyle(
|
||||
fontSize: 28,
|
||||
fontWeight: FontWeight.bold,
|
||||
color: Colors.white,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 24),
|
||||
Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 24),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
'Do you want to delete your keys?',
|
||||
style: TextStyle(
|
||||
fontSize: 18,
|
||||
fontWeight: FontWeight.bold,
|
||||
color: Colors.grey[700],
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.end,
|
||||
children: [
|
||||
TextButton(
|
||||
onPressed: onNoPressed,
|
||||
child: Text(
|
||||
'On',
|
||||
style: TextStyle(color: AppColors.mainDarkBlue),
|
||||
),
|
||||
),
|
||||
OkButton(
|
||||
onPressed: onYesPressed,
|
||||
label: 'YES',
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
)
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
@ -1,128 +0,0 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import 'ok_button_widget.dart';
|
||||
|
||||
class GeneratedKeys extends StatefulWidget {
|
||||
const GeneratedKeys({
|
||||
super.key,
|
||||
required this.npubEncoded,
|
||||
required this.nsecEncoded,
|
||||
required this.hexPriv,
|
||||
required this.hexPub,
|
||||
});
|
||||
|
||||
final String npubEncoded;
|
||||
final String nsecEncoded;
|
||||
final String hexPriv;
|
||||
final String hexPub;
|
||||
|
||||
@override
|
||||
State<GeneratedKeys> createState() => _GeneratedKeysState();
|
||||
}
|
||||
|
||||
class _GeneratedKeysState extends State<GeneratedKeys> {
|
||||
bool _toHex = false;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Dialog(
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
),
|
||||
child: Container(
|
||||
constraints: const BoxConstraints(maxWidth: 600),
|
||||
decoration: BoxDecoration(
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
color: Colors.white,
|
||||
),
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Container(
|
||||
padding: const EdgeInsets.symmetric(vertical: 24),
|
||||
decoration: BoxDecoration(
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
color: Colors.indigo,
|
||||
),
|
||||
child: const Center(
|
||||
child: Text(
|
||||
'Keys',
|
||||
style: TextStyle(
|
||||
fontSize: 28,
|
||||
fontWeight: FontWeight.bold,
|
||||
color: Colors.white,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 24),
|
||||
Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 24),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
'Public Key',
|
||||
style: TextStyle(
|
||||
fontSize: 18,
|
||||
fontWeight: FontWeight.bold,
|
||||
color: Colors.grey[700],
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 12),
|
||||
SelectableText(
|
||||
_toHex ? widget.hexPub : widget.npubEncoded,
|
||||
style: TextStyle(
|
||||
fontSize: 16,
|
||||
color: Colors.grey[800],
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 24),
|
||||
Text(
|
||||
'Private Key',
|
||||
style: TextStyle(
|
||||
fontSize: 18,
|
||||
fontWeight: FontWeight.bold,
|
||||
color: Colors.grey[700],
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 12),
|
||||
SelectableText(
|
||||
_toHex ? widget.hexPriv : widget.nsecEncoded,
|
||||
style: const TextStyle(
|
||||
fontSize: 16,
|
||||
fontWeight: FontWeight.bold,
|
||||
color: Colors.redAccent,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 24),
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment
|
||||
.spaceBetween, // Changed to space between to create space for icon buttons
|
||||
children: [
|
||||
IconButton(
|
||||
onPressed: () {
|
||||
setState(() {
|
||||
_toHex = !_toHex;
|
||||
});
|
||||
},
|
||||
icon: const Icon(Icons.autorenew_outlined),
|
||||
color: Colors.grey[700],
|
||||
),
|
||||
OkButton(
|
||||
onPressed: () {
|
||||
Navigator.pop(context);
|
||||
},
|
||||
label: 'OK',
|
||||
),
|
||||
],
|
||||
)
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
@ -1,128 +0,0 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:drifter/theme/app_colors.dart';
|
||||
|
||||
import 'ok_button_widget.dart';
|
||||
|
||||
class KeysExistDialog extends StatefulWidget {
|
||||
const KeysExistDialog({
|
||||
super.key,
|
||||
required this.npubEncoded,
|
||||
required this.nsecEncoded,
|
||||
required this.hexPriv,
|
||||
required this.hexPub,
|
||||
});
|
||||
|
||||
final String npubEncoded;
|
||||
final String nsecEncoded;
|
||||
final String hexPriv;
|
||||
final String hexPub;
|
||||
|
||||
@override
|
||||
State<KeysExistDialog> createState() => _KeysExistDialogState();
|
||||
}
|
||||
|
||||
class _KeysExistDialogState extends State<KeysExistDialog> {
|
||||
bool _toHex = false;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Dialog(
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
),
|
||||
child: Container(
|
||||
constraints: const BoxConstraints(maxWidth: 600),
|
||||
decoration: BoxDecoration(
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
color: Colors.white,
|
||||
),
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Container(
|
||||
padding: const EdgeInsets.symmetric(vertical: 24),
|
||||
decoration: BoxDecoration(
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
color: AppColors.mainDarkBlue,
|
||||
),
|
||||
child: const Center(
|
||||
child: Text(
|
||||
'Keys',
|
||||
style: TextStyle(
|
||||
fontSize: 28,
|
||||
fontWeight: FontWeight.bold,
|
||||
color: Colors.white,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 24),
|
||||
Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 24),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
'Public Key',
|
||||
style: TextStyle(
|
||||
fontSize: 18,
|
||||
fontWeight: FontWeight.bold,
|
||||
color: Colors.grey[700],
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 12),
|
||||
SelectableText(
|
||||
_toHex ? widget.hexPub : widget.npubEncoded,
|
||||
style: TextStyle(
|
||||
fontSize: 16,
|
||||
color: Colors.grey[800],
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 24),
|
||||
Text(
|
||||
'Private Key',
|
||||
style: TextStyle(
|
||||
fontSize: 18,
|
||||
fontWeight: FontWeight.bold,
|
||||
color: Colors.grey[700],
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 12),
|
||||
SelectableText(
|
||||
_toHex ? widget.hexPriv : widget.nsecEncoded,
|
||||
style: TextStyle(
|
||||
fontSize: 16,
|
||||
color: Colors.grey[800],
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 24),
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment
|
||||
.spaceBetween, // Changed to space between to create space for icon buttons
|
||||
children: [
|
||||
IconButton(
|
||||
onPressed: () {
|
||||
setState(() {
|
||||
_toHex = !_toHex;
|
||||
});
|
||||
},
|
||||
icon: const Icon(Icons.autorenew_outlined),
|
||||
color: Colors.grey[700],
|
||||
),
|
||||
OkButton(
|
||||
onPressed: () {
|
||||
Navigator.pop(context);
|
||||
},
|
||||
label: 'OK',
|
||||
),
|
||||
],
|
||||
)
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
@ -1,34 +0,0 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:drifter/theme/app_colors.dart';
|
||||
|
||||
class KeysOptionModalBottomSheet extends StatelessWidget {
|
||||
const KeysOptionModalBottomSheet({
|
||||
super.key,
|
||||
required this.generateNewKeyPressed,
|
||||
});
|
||||
|
||||
final void Function()? generateNewKeyPressed;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Container(
|
||||
padding: const EdgeInsets.all(20),
|
||||
decoration: BoxDecoration(color: AppColors.mainDarkBlue),
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
ElevatedButton(
|
||||
style: ButtonStyle(
|
||||
backgroundColor: MaterialStateProperty.all(Colors.white)),
|
||||
onPressed: generateNewKeyPressed,
|
||||
child: Text(
|
||||
'Generate New Key',
|
||||
style: TextStyle(color: AppColors.mainDarkBlue),
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 10),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
@ -1,46 +0,0 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
class MessageSnackBar extends SnackBar {
|
||||
MessageSnackBar({Key? key, required this.label, this.isWarning = false})
|
||||
: super(
|
||||
key: key,
|
||||
content: _GenericErrorSnackBarMessage(
|
||||
label: label,
|
||||
isWarning: isWarning,
|
||||
),
|
||||
backgroundColor: isWarning! ? Colors.red : Colors.white,
|
||||
elevation: 6.0,
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(10.0),
|
||||
),
|
||||
behavior: SnackBarBehavior.fixed,
|
||||
);
|
||||
|
||||
final String label;
|
||||
final bool? isWarning;
|
||||
}
|
||||
|
||||
class _GenericErrorSnackBarMessage extends StatelessWidget {
|
||||
const _GenericErrorSnackBarMessage({
|
||||
Key? key,
|
||||
required this.label,
|
||||
this.isWarning,
|
||||
}) : super(key: key);
|
||||
|
||||
final String label;
|
||||
final bool? isWarning;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Container(
|
||||
padding: const EdgeInsets.symmetric(vertical: 16.0, horizontal: 24.0),
|
||||
child: Text(
|
||||
label,
|
||||
style: TextStyle(
|
||||
color: isWarning! ? Colors.white : Colors.black,
|
||||
fontSize: 16.0,
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
@ -1,34 +0,0 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:drifter/theme/app_colors.dart';
|
||||
|
||||
class OkButton extends StatelessWidget {
|
||||
const OkButton({
|
||||
super.key,
|
||||
required this.onPressed,
|
||||
required this.label,
|
||||
});
|
||||
|
||||
final void Function()? onPressed;
|
||||
final String label;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return ElevatedButton(
|
||||
onPressed: onPressed,
|
||||
style: ElevatedButton.styleFrom(
|
||||
backgroundColor: AppColors.mainDarkBlue,
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
),
|
||||
),
|
||||
child: Text(
|
||||
label,
|
||||
style: const TextStyle(
|
||||
fontSize: 16,
|
||||
fontWeight: FontWeight.bold,
|
||||
color: Colors.white,
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
@ -1,97 +0,0 @@
|
||||
import 'package:drifter/theme/app_colors.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
class UserInfo extends StatelessWidget {
|
||||
const UserInfo({super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Container(
|
||||
child: Column(
|
||||
children: [
|
||||
AvatarWidget(),
|
||||
SizedBox(
|
||||
height: 10,
|
||||
),
|
||||
UserNameWidget(),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class AvatarWidget extends StatelessWidget {
|
||||
const AvatarWidget({super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Container(
|
||||
decoration: BoxDecoration(
|
||||
border: Border.all(color: Colors.black),
|
||||
borderRadius: BorderRadius.all(Radius.circular(75))),
|
||||
width: 150,
|
||||
height: 150,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class UserNameWidget extends StatefulWidget {
|
||||
const UserNameWidget({super.key});
|
||||
|
||||
@override
|
||||
State<UserNameWidget> createState() => _UserNameWidgetState();
|
||||
}
|
||||
|
||||
class _UserNameWidgetState extends State<UserNameWidget> {
|
||||
late final TextEditingController messageController;
|
||||
late final FocusNode messageFocusNode;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
messageController = TextEditingController();
|
||||
messageFocusNode = FocusNode();
|
||||
|
||||
super.initState();
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
messageController.dispose();
|
||||
messageFocusNode.dispose();
|
||||
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Padding(
|
||||
padding: const EdgeInsets.all(4.0),
|
||||
child: ClipRRect(
|
||||
borderRadius: const BorderRadius.all(
|
||||
Radius.circular(
|
||||
0.0,
|
||||
),
|
||||
),
|
||||
child: TextField(
|
||||
controller: messageController,
|
||||
focusNode: messageFocusNode,
|
||||
style: const TextStyle(
|
||||
fontSize: 14,
|
||||
),
|
||||
decoration: InputDecoration(
|
||||
hintText: 'Username',
|
||||
hintStyle: const TextStyle(fontSize: 14),
|
||||
suffixIcon: IconButton(
|
||||
icon: const Icon(
|
||||
Icons.send,
|
||||
color: AppColors.mainDarkBlue,
|
||||
size: 30,
|
||||
),
|
||||
onPressed: () {},
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
1
lib/pages/widgets/flust_bar_type.dart
Normal file
1
lib/pages/widgets/flust_bar_type.dart
Normal file
@ -0,0 +1 @@
|
||||
enum FlushBarType { success, info, warning }
|
64
lib/pages/widgets/show_flush_bar.dart
Normal file
64
lib/pages/widgets/show_flush_bar.dart
Normal file
@ -0,0 +1,64 @@
|
||||
import 'package:another_flushbar/flushbar.dart';
|
||||
import 'package:another_flushbar/flushbar_route.dart' as flushRoute;
|
||||
import 'package:drifter/pages/widgets/flust_bar_type.dart';
|
||||
import 'package:drifter/theme/app_colors.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_svg/svg.dart';
|
||||
|
||||
Future<dynamic> showFloatingFlushBar({
|
||||
required FlushBarType type,
|
||||
required String message,
|
||||
String? iconAsset,
|
||||
required BuildContext context,
|
||||
Duration? duration = const Duration(milliseconds: 1500),
|
||||
FlushbarPosition flushbarPosition = FlushbarPosition.TOP,
|
||||
VoidCallback? onTap,
|
||||
}) {
|
||||
Color bg;
|
||||
Color fg;
|
||||
switch (type) {
|
||||
case FlushBarType.success:
|
||||
fg = AppColors.snackBarTextSuccess;
|
||||
bg = AppColors.snackBarBackSuccess;
|
||||
break;
|
||||
case FlushBarType.info:
|
||||
fg = AppColors.snackBarTextInfo;
|
||||
bg = AppColors.snackBarBackInfo;
|
||||
break;
|
||||
case FlushBarType.warning:
|
||||
fg = AppColors.snackBarTextError;
|
||||
bg = AppColors.snackBarBackError;
|
||||
break;
|
||||
}
|
||||
final bar = Flushbar<dynamic>(
|
||||
onTap: (_) {
|
||||
onTap?.call();
|
||||
},
|
||||
icon: iconAsset != null
|
||||
? SvgPicture.asset(
|
||||
iconAsset,
|
||||
height: 16,
|
||||
width: 16,
|
||||
// color: fg,
|
||||
)
|
||||
: null,
|
||||
message: message,
|
||||
messageColor: fg,
|
||||
flushbarPosition: flushbarPosition,
|
||||
backgroundColor: bg,
|
||||
duration: duration,
|
||||
flushbarStyle: FlushbarStyle.FLOATING,
|
||||
borderRadius: BorderRadius.circular(
|
||||
8.0,
|
||||
),
|
||||
margin: const EdgeInsets.all(20),
|
||||
maxWidth: MediaQuery.of(context).size.width - 50,
|
||||
);
|
||||
|
||||
final _route = flushRoute.showFlushbar<dynamic>(
|
||||
context: context,
|
||||
flushbar: bar,
|
||||
);
|
||||
|
||||
return Navigator.of(context, rootNavigator: true).push(_route);
|
||||
}
|
@ -5,6 +5,14 @@ abstract class AppColors {
|
||||
static const mainAccent = const Color(0xFFFFCC11);
|
||||
static const mainBackground = const Color(0xFFF2EFFF);
|
||||
|
||||
// snack bar
|
||||
static const snackBarBackSuccess = const Color(0xFFB9E9D4);
|
||||
static const snackBarBackError = const Color(0xFFFFDAD4);
|
||||
static const snackBarBackInfo = const Color(0xFFDAE2FF);
|
||||
static const snackBarTextSuccess = const Color(0xFF006C4D);
|
||||
static const snackBarTextError = const Color(0xFF930006);
|
||||
static const snackBarTextInfo = const Color(0xFF002A78);
|
||||
|
||||
static const mainDarkBlue = Color.fromRGBO(3, 37, 65, 1);
|
||||
static const mainLightBlue = Color.fromRGBO(48, 86, 117, 1);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user