import 'package:dart_nostr/dart_nostr.dart'; import 'package:drifter/models/models.dart'; import 'package:drifter/pages/profile_screen/widgets/delete_keys_dialog.dart'; import 'package:drifter/main.dart'; import 'package:drifter/pages/profile_screen/widgets/key_exist_dialog.dart'; import 'package:drifter/pages/profile_screen/widgets/keys_option_modal_bottom_sheet.dart'; import 'package:drifter/pages/profile_screen/widgets/message_snack_bar.dart'; import 'package:drifter/pages/profile_screen/widgets/user_info_widget.dart'; import 'package:drifter/theme/app_colors.dart'; import 'package:flutter/material.dart'; import 'package:flutter_secure_storage/flutter_secure_storage.dart'; class EditProfileScreen extends StatefulWidget { const EditProfileScreen({super.key}); @override State createState() => EditProfileScreenState(); } class EditProfileScreenState extends State { final secureStorage = const FlutterSecureStorage(); bool _toHex = false; TextEditingController privateKeyInput = TextEditingController(); TextEditingController publicKeyInput = TextEditingController(); // final keyGenerator = KeyApi(); // final nip19 = Nip19(); @override Widget build(BuildContext context) { return Scaffold( backgroundColor: AppColors.mainBackground, appBar: AppBar( actions: [ Container( margin: EdgeInsets.symmetric(horizontal: 16, vertical: 8), height: 40, width: 82, child: ElevatedButton( style: ButtonStyle( shape: MaterialStateProperty.all(RoundedRectangleBorder( borderRadius: BorderRadius.circular(100))), backgroundColor: MaterialStateProperty.all(AppColors.buttonPrimaryDefaultBg), ), onPressed: () {}, child: Text('Save'), ), ) ], leading: IconButton( icon: Icon( Icons.arrow_back, color: AppColors.topNavIconPtimary, ), onPressed: () => Navigator.of(context).pop(), ), title: Text( ('Edit profile'), style: TextStyle( color: AppColors.topNavText, ), // textAlign: TextAlign.center, ), backgroundColor: AppColors.mainBackground, elevation: 0, ), body: ListView( children: [ Stack( children: [ Container( width: double.infinity, height: 70, child: FittedBox( child: Image.asset('assets/images/banner.png'), fit: BoxFit.fill, ), ), Row( children: [ Padding( padding: const EdgeInsets.only(top: 30, left: 16, right: 58), child: ClipRRect( borderRadius: BorderRadius.circular(200), child: InkWell( onTap: () { Navigator.pushNamed( context, '/ViewProfilePhotoScreen'); }, child: Container( width: 80, height: 80, decoration: BoxDecoration( border: Border.all( width: 2, color: Color(0xFFF2EFFF))), child: Image.asset('assets/images/avatar.png')), ), ), ), ], ) ], ), Padding( padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 20), child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ Text( 'User info', style: TextStyle( color: AppColors.label, fontWeight: FontWeight.w500), ), SizedBox( height: 8, ), TextField( decoration: InputDecoration( filled: true, fillColor: AppColors.textFieldDefaultBg, labelText: 'Username', labelStyle: TextStyle(color: AppColors.textFieldDefaultText), prefixIcon: const Icon(Icons.alternate_email), border: OutlineInputBorder( borderRadius: BorderRadius.circular(8), borderSide: BorderSide( width: 0, style: BorderStyle.none, ), ), iconColor: AppColors.textFieldDefaultIconTrail), controller: userNameController, ), const SizedBox(height: 8), TextField( decoration: InputDecoration( filled: true, fillColor: AppColors.textFieldDefaultBg, labelText: 'Name', labelStyle: TextStyle(color: AppColors.textFieldDefaultText), border: OutlineInputBorder( borderRadius: BorderRadius.circular(8), borderSide: BorderSide( width: 0, style: BorderStyle.none, ), ), iconColor: AppColors.textFieldDefaultIconTrail), controller: nameController, ), const SizedBox(height: 8), SizedBox( height: 112, child: TextField( minLines: 3, maxLines: 5, decoration: InputDecoration( filled: true, fillColor: AppColors.textFieldDefaultBg, labelText: 'Description', alignLabelWithHint: true, labelStyle: TextStyle(color: AppColors.textFieldDefaultText), border: OutlineInputBorder( borderRadius: BorderRadius.circular(8), borderSide: BorderSide( width: 0, style: BorderStyle.none, ), ), iconColor: AppColors.textFieldDefaultIconTrail), controller: descriptionController, ), ), const SizedBox(height: 8), TextField( decoration: InputDecoration( filled: true, fillColor: AppColors.textFieldDefaultBg, labelText: 'Website URL', labelStyle: TextStyle(color: AppColors.textFieldDefaultText), border: OutlineInputBorder( borderRadius: BorderRadius.circular(8), borderSide: BorderSide( width: 0, style: BorderStyle.none, ), ), iconColor: AppColors.textFieldDefaultIconTrail), controller: nameController, ), ], ), ) ], ), ); // return ListView( // children: [ // const SizedBox( // height: 60, // ), // const UserInfo(), // const SizedBox( // height: 40, // ), // FormKeys(), // const SizedBox(height: 20), // Padding( // padding: const EdgeInsets.all(16.0), // child: Row( // mainAxisAlignment: MainAxisAlignment.spaceAround, // children: [ // Keys.keysExist // ? IconButton( // onPressed: () { // setState(() { // _toHex = !_toHex; // }); // }, // icon: const Icon(Icons.refresh)) // // ElevatedButton( // // style: ButtonStyle( // // backgroundColor: // // MaterialStateProperty.all(AppColors.background)), // // onPressed: () { // // keysExistDialog( // // Nostr.instance.keysService // // .encodePublicKeyToNpub(Keys.publicKey), // // Nostr.instance.keysService // // .encodePrivateKeyToNsec(Keys.privateKey), // // ); // // }, // // child: const Text( // // 'Keys', // // ), // // ) // : Row( // children: [ // ElevatedButton( // style: ButtonStyle( // backgroundColor: MaterialStateProperty.all( // AppColors.background)), // onPressed: () { // modalBottomSheet(); // }, // child: const Text( // 'Generate Keys', // ), // ), // SizedBox(width: 100), // ElevatedButton( // style: ButtonStyle( // backgroundColor: MaterialStateProperty.all( // AppColors.background)), // onPressed: () { // Navigator.pushNamed(context, '/login').then((_) { // initState(); // }); // }, // child: const Text( // 'Login', // ), // ), // ], // ), // Keys.keysExist // ? Row( // children: [ // IconButton( // onPressed: () { // deleteKeysDialog(); // }, // icon: const Icon(Icons.delete)), // ], // ) // : Container(), // ], // ), // ) // ], // ); } Form FormKeys() { return Form( child: Padding( padding: const EdgeInsets.all(16.0), child: Column( children: [ TextFormField( controller: privateKeyInput, // _toHex ? widget.hexPriv : widget.nsecEncoded, decoration: const InputDecoration( labelText: 'Private Key', border: OutlineInputBorder(), ), maxLength: 64, ), const SizedBox( height: 20, ), TextFormField( controller: publicKeyInput, // _toHex ? widget.hexPub : widget.npubEncoded, decoration: const InputDecoration( labelText: 'Public Key', border: OutlineInputBorder(), ), ), const SizedBox( height: 40, ), TextFormField( decoration: const InputDecoration( labelText: 'Relay', border: OutlineInputBorder(), ), ), ], ), ), ); } }