drifter_app/lib/pages/profile_screen/widgets/key_exist_dialog.dart
2023-05-19 09:46:45 -06:00

149 lines
4.8 KiB
Dart

import 'package:flutter/material.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: BoxConstraints(
maxWidth: 700,
maxHeight: 340,
),
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(12),
color: Colors.white,
),
child: Padding(
padding: const EdgeInsets.symmetric(vertical: 10.0, horizontal: 15.0),
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Text(
"Keys",
style: TextStyle(
fontSize: 28,
fontWeight: FontWeight.bold,
color: Colors.black,
),
),
],
),
const SizedBox(height: 24),
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),
Padding(
padding: const EdgeInsets.symmetric(horizontal: 10.0),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
MaterialButton(
elevation: 3.0,
onPressed: () {
Navigator.of(context).pop();
},
color: Colors.grey[400],
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(
8.0,
),
),
child: Text(
"Cancel",
style: TextStyle(
fontWeight: FontWeight.bold,
),
),
),
_toHex
? OkButton(
onPressed: () {
setState(() {
_toHex = !_toHex;
});
},
label: "Encoded",
)
: OkButton(
onPressed: () {
setState(() {
_toHex = !_toHex;
});
},
label: "Hex",
),
],
),
)
],
),
],
),
),
),
);
}
}