Added create an account screen

This commit is contained in:
Alex Vasilev 2023-05-30 04:09:23 +03:00
parent 3a691ddda4
commit 6921e30ecd
14 changed files with 373 additions and 41 deletions

View File

@ -1,5 +1,7 @@
import 'dart:io';
import 'package:drifter/pages/create_account_screen/create_account_screen.dart';
import 'package:drifter/pages/home_screen/home_screen_widget.dart';
import 'package:drifter/pages/login_screen/login_screen.dart';
import 'package:drifter/pages/main_screen/main_screen_widget.dart';
import 'package:drifter/pages/splash_screen/splash_screen.dart';
@ -22,6 +24,8 @@ class MyApp extends StatelessWidget {
title: 'Flutter Demo',
theme: ThemeData(
appBarTheme: const AppBarTheme(backgroundColor: AppColors.background),
textButtonTheme: TextButtonThemeData(
style: TextButton.styleFrom(foregroundColor: AppColors.background)),
bottomNavigationBarTheme: const BottomNavigationBarThemeData(
backgroundColor: AppColors.background,
selectedItemColor: AppColors.mainAccent,
@ -29,11 +33,13 @@ class MyApp extends StatelessWidget {
),
),
routes: {
'/': (context) => const WelcomeScreen()
'/': (context) => const Splash()
// Splash()
,
'/login': (context) => const LoginScreen(),
'/terms': (context) => const TermsOfServiceScreen(),
'/createAccount': (context) => const CreateAccountScreen(),
'/MainScreen': (context) => const MainScreenWidget(),
},
);
}

24
lib/models/models.dart Normal file
View File

@ -0,0 +1,24 @@
import 'package:flutter/material.dart';
import 'package:nostr_tools/nostr_tools.dart';
class Keys {
static String privateKey = '';
static String publicKey = '';
static String nsecKey = '';
static String npubKey = '';
static bool keysExist = false;
}
class Relay {
static final relay = RelayApi(relayUrl: 'wss://relay.damus.io');
}
final keyController = TextEditingController();
final formKey = GlobalKey<FormFieldState>();
final userNameController = TextEditingController();
final nameController = TextEditingController();
final descriptionController = TextEditingController();
class UserData {
static bool isLogin = true;
}

View File

@ -0,0 +1,164 @@
import 'package:dart_nostr/dart_nostr.dart';
import 'package:drifter/models/models.dart';
import 'package:drifter/pages/home_screen/widgets/message_text_button_widget.dart';
import 'package:drifter/pages/profile_screen/profile_screen.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/ok_button_widget.dart';
import 'package:drifter/widgets/btn_continue.dart';
import 'package:drifter/theme/app_colors.dart';
import 'package:drifter/utilities/assets.dart';
import 'package:flutter/material.dart';
import 'package:flutter_secure_storage/flutter_secure_storage.dart';
import 'package:flutter_svg/svg.dart';
import 'package:nostr_tools/nostr_tools.dart';
import 'package:sliding_switch/sliding_switch.dart';
import 'package:toggle_switch/toggle_switch.dart';
class CreateAccountScreen extends StatefulWidget {
const CreateAccountScreen({super.key});
@override
State<CreateAccountScreen> createState() => CreateAccountScreenState();
}
class CreateAccountScreenState extends State<CreateAccountScreen> {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
leading: IconButton(
icon: Icon(
Icons.arrow_back,
color: AppColors.topNavIconBack,
),
onPressed: () => Navigator.of(context).pop(),
),
actions: <Widget>[
TextButton(
onPressed: () {},
child: Text('Skip'),
)
],
elevation: 0,
backgroundColor: AppColors.mainBackground,
),
backgroundColor: AppColors.mainBackground,
body: Padding(
padding: const EdgeInsets.all(16.0),
child: Column(
children: [
const Text(
'Create an account',
style: TextStyle(fontSize: 20, fontWeight: FontWeight.w600),
),
const SizedBox(height: 13),
const Text(
'You can change this information later in your Profile.',
style: TextStyle(fontSize: 12, fontWeight: FontWeight.w400),
),
const SizedBox(height: 24),
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 (optional)',
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 (optional)',
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,
),
),
Expanded(child: SizedBox()),
SizedBox(
width: double.infinity,
height: 56,
child: ElevatedButton(
onPressed: () {
Navigator.pushNamedAndRemoveUntil(
context, '/MainScreen', (_) => false);
},
child: Text(
'Continue',
style: TextStyle(fontSize: 16),
),
style: ButtonStyle(
shape: MaterialStatePropertyAll(RoundedRectangleBorder(
borderRadius: BorderRadius.circular(100))),
backgroundColor: const MaterialStatePropertyAll(
AppColors.buttonPrimaryDefaultBg),
foregroundColor: const MaterialStatePropertyAll(
AppColors.buttonPrimaryDefaultText)),
)),
],
),
),
);
}
}
abstract class Note {
static final note = Text.rich(
TextSpan(
style: TextStyle(
height: 1.6,
fontSize: 10,
fontWeight: FontWeight.w400,
),
children: <TextSpan>[
TextSpan(
style: TextStyle(color: AppColors.noteText),
text:
"Your private key starts with “nsec” or “hex” and gives your full access to your account. That means, if you log in using your private key, you will be able to make posts and send and receive private messages.\n\n"
"Your public key starts with “npub” and gives your view-only access to account. If you log in using your public key, you wont be able to make posts or access private messages, but you will be able to view your feed. Go to “View only” tab to log in via your public key.")
]),
);
}

View File

@ -3,7 +3,7 @@ import 'dart:convert';
import 'package:flutter/material.dart';
import 'package:drifter/domain_models/domain_models.dart';
import 'package:drifter/models/keys.dart';
import 'package:drifter/models/models.dart';
import 'package:drifter/theme/app_colors.dart';
import 'package:drifter/pages/home_screen/widgets/message_ok_button_widget.dart';
import 'package:drifter/pages/home_screen/widgets/message_text_button_widget.dart';
@ -235,18 +235,10 @@ class DomainCard extends StatelessWidget {
Widget build(BuildContext context) {
final List<String>? imageLinks = extractImage(domain.content);
return Container(
margin: const EdgeInsets.all(8),
margin: const EdgeInsets.all(4),
decoration: BoxDecoration(
color: AppColors.mainLightBlue,
borderRadius: BorderRadius.circular(10),
boxShadow: [
BoxShadow(
color: Colors.grey.withOpacity(0.5),
spreadRadius: 2,
blurRadius: 5,
offset: const Offset(0, 3),
),
],
color: Colors.grey,
borderRadius: BorderRadius.circular(8),
),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,

View File

@ -1,12 +1,12 @@
import 'package:dart_nostr/dart_nostr.dart';
import 'package:drifter/models/keys.dart';
import 'package:drifter/models/models.dart';
import 'package:drifter/pages/home_screen/widgets/message_text_button_widget.dart';
import 'package:drifter/pages/profile_screen/profile_screen.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/ok_button_widget.dart';
import 'package:drifter/pages/terms_of_service/button_continue.dart';
import 'package:drifter/widgets/btn_continue.dart';
import 'package:drifter/theme/app_colors.dart';
import 'package:drifter/utilities/assets.dart';
@ -27,6 +27,7 @@ class LoginScreen extends StatefulWidget {
class LoginScreenState extends State<LoginScreen> {
final keyGenerator = KeyApi();
final nip19 = Nip19();
final indexToggle = 0;
@override
Widget build(BuildContext context) {
@ -39,6 +40,12 @@ class LoginScreenState extends State<LoginScreen> {
),
onPressed: () => Navigator.of(context).pop(),
),
actions: <Widget>[
TextButton(
onPressed: () {},
child: Text('Skip'),
)
],
elevation: 0,
backgroundColor: AppColors.mainBackground,
),
@ -70,7 +77,9 @@ class LoginScreenState extends State<LoginScreen> {
customTextStyles: [
TextStyle(fontSize: 14, fontWeight: FontWeight.w600)
],
onToggle: (index) {},
onToggle: (indexToggle) {
print(indexToggle);
},
),
SizedBox(
height: 56,

View File

@ -31,28 +31,28 @@ class _MainScreenWidgetState extends State<MainScreenWidget> {
return Scaffold(
backgroundColor: AppColors.mainBackground,
appBar: AppBar(
title: Row(
// mainAxisAlignment: MainAxisAlignment.center,
children: [
SvgPicture.asset(
Assets.svg.drifterIcon,
height: 30,
width: 30,
alignment: Alignment.centerLeft,
),
const SizedBox(
width: 125,
),
const Text(
"Drifter",
style: TextStyle(
color: AppColors.mainAccent,
),
// textAlign: TextAlign.center,
),
],
leading: IconButton(
icon: Icon(Icons.settings),
color: AppColors.topNavIconPtimary,
onPressed: () {},
),
actions: <Widget>[
IconButton(
icon: Icon(Icons.rss_feed),
color: AppColors.topNavIconPtimary,
onPressed: () {},
),
],
title: const Text(
"Drifter",
style: TextStyle(
color: AppColors.topNavText,
),
// textAlign: TextAlign.center,
),
centerTitle: true,
backgroundColor: AppColors.mainBackground,
elevation: 0,
),
body: IndexedStack(
index: _selectedTap,
@ -64,6 +64,9 @@ class _MainScreenWidgetState extends State<MainScreenWidget> {
],
),
bottomNavigationBar: BottomNavigationBar(
backgroundColor: AppColors.bottomNavBackground,
selectedItemColor: AppColors.bottomNavIconActive,
unselectedItemColor: AppColors.bottomNavIconDefault,
currentIndex: _selectedTap,
items: const [
BottomNavigationBarItem(

View File

@ -1,5 +1,5 @@
import 'package:dart_nostr/dart_nostr.dart';
import 'package:drifter/models/keys.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';

View File

@ -1,6 +1,7 @@
import 'dart:io';
import 'package:drifter/pages/main_screen/main_screen_widget.dart';
import 'package:drifter/pages/welcome_screen/welcome_screen.dart';
import 'package:drifter/theme/app_colors.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
@ -18,7 +19,7 @@ class _SplashState extends State<Splash> {
super.initState();
Future.delayed(const Duration(seconds: 3), () {
Navigator.pushReplacement(context,
MaterialPageRoute(builder: (context) => const MainScreenWidget()));
MaterialPageRoute(builder: (context) => const WelcomeScreen()));
});
}

View File

@ -0,0 +1,55 @@
import 'package:drifter/models/models.dart';
import 'package:drifter/theme/app_colors.dart';
import 'package:flutter/material.dart';
class DisabledElevatedButton extends StatelessWidget {
const DisabledElevatedButton({
super.key,
});
@override
Widget build(BuildContext context) {
return ElevatedButton(
onPressed: null,
child: Text(
'Continue',
style: TextStyle(fontSize: 16),
),
style: ButtonStyle(
shape: MaterialStatePropertyAll(
RoundedRectangleBorder(borderRadius: BorderRadius.circular(100))),
backgroundColor:
const MaterialStatePropertyAll(AppColors.buttonPrimaryDisabledBg),
foregroundColor: const MaterialStatePropertyAll(
AppColors.buttonPrimaryDisabledText)),
);
}
}
class ActiveElevatedButton extends StatelessWidget {
const ActiveElevatedButton({
super.key,
});
@override
Widget build(BuildContext context) {
return ElevatedButton(
onPressed: () {
UserData.isLogin
? Navigator.pushNamed(context, '/login')
: Navigator.pushNamed(context, '/createAccount');
},
child: Text(
'Continue',
style: TextStyle(fontSize: 16),
),
style: ButtonStyle(
shape: MaterialStatePropertyAll(
RoundedRectangleBorder(borderRadius: BorderRadius.circular(100))),
backgroundColor:
const MaterialStatePropertyAll(AppColors.buttonPrimaryDefaultBg),
foregroundColor: const MaterialStatePropertyAll(
AppColors.buttonPrimaryDefaultText)),
);
}
}

View File

@ -1,4 +1,4 @@
import 'package:drifter/pages/terms_of_service/button_continue.dart';
import 'package:drifter/pages/terms_of_service/btn_continue_terms_of_service.dart';
import 'package:drifter/pages/terms_of_service/terms_of_service_text.dart';
import 'package:drifter/theme/app_colors.dart';
import 'package:flutter/material.dart';

View File

@ -1,3 +1,4 @@
import 'package:drifter/models/models.dart';
import 'package:drifter/theme/app_colors.dart';
import 'package:flutter/material.dart';
@ -23,6 +24,7 @@ class WelcomeScreen extends StatelessWidget {
width: double.infinity,
child: ElevatedButton(
onPressed: () {
UserData.isLogin = true;
Navigator.pushNamed(context, '/terms');
},
child: Text(
@ -44,7 +46,10 @@ class WelcomeScreen extends StatelessWidget {
height: 56,
width: double.infinity,
child: OutlinedButton(
onPressed: () {},
onPressed: () {
UserData.isLogin = false;
Navigator.pushNamed(context, '/terms');
},
child: Text(
'Create an account',
style: TextStyle(fontSize: 16),

View File

@ -19,6 +19,13 @@ abstract class AppColors {
static const topNavIconBack = Color(0xFF4A40EC);
static const topNavIconBg = Color(0xFFE3E0F9);
// BottomNav
static const bottomNavIconDefault = Color(0xFF787680);
static const bottomNavIconActive = Color(0xFF4A40EC);
static const bottomNavBackground = Color(0xFFFFFFFF);
static const bottomNavShadow = Color(0xFFF2EFFF);
// Checkbox
static const checkboxCheckedIcon = Color(0xFFFFFFFF);
static const checkboxCheckedBg = Color(0xFF4A40EC);
@ -51,4 +58,18 @@ abstract class AppColors {
static const mainDarkBlue = Color.fromRGBO(3, 37, 65, 1);
static const mainLightBlue = Color.fromRGBO(48, 86, 117, 1);
// Post
static const postFullName = Color(0xFF302F38);
static const postUserName = Color(0xFFC8C5D0);
static const postBg = Color(0xFFF9F8FF);
static const postTime = Color(0xFFC8C5D0);
static const postMoreIcon = Color(0xFF323232);
static const postBodyText = Color(0xFF000000);
static const postBodyLink = Color(0xFF3A00E5);
static const postActionNumber = Color(0xFFC8C5D0);
static const postActionIconDefault = Color(0xFFC8C5D0);
static const postActionIconPressed = Color(0xFFFE82B1);
static const postBookmark = Color(0xFF8482FF);
}

View File

@ -0,0 +1,52 @@
import 'package:drifter/theme/app_colors.dart';
import 'package:flutter/material.dart';
class DisabledElevatedButton extends StatelessWidget {
const DisabledElevatedButton({
super.key,
});
@override
Widget build(BuildContext context) {
return ElevatedButton(
onPressed: null,
child: Text(
'Continue',
style: TextStyle(fontSize: 16),
),
style: ButtonStyle(
shape: MaterialStatePropertyAll(
RoundedRectangleBorder(borderRadius: BorderRadius.circular(100))),
backgroundColor:
const MaterialStatePropertyAll(AppColors.buttonPrimaryDisabledBg),
foregroundColor: const MaterialStatePropertyAll(
AppColors.buttonPrimaryDisabledText)),
);
}
}
class ActiveElevatedButton extends StatelessWidget {
const ActiveElevatedButton({
super.key,
});
@override
Widget build(BuildContext context) {
return ElevatedButton(
onPressed: () {
Navigator.pushNamed(context, '/login');
},
child: Text(
'Continue',
style: TextStyle(fontSize: 16),
),
style: ButtonStyle(
shape: MaterialStatePropertyAll(
RoundedRectangleBorder(borderRadius: BorderRadius.circular(100))),
backgroundColor:
const MaterialStatePropertyAll(AppColors.buttonPrimaryDefaultBg),
foregroundColor: const MaterialStatePropertyAll(
AppColors.buttonPrimaryDefaultText)),
);
}
}

View File

@ -64,7 +64,7 @@ flutter:
# To add assets to your application, add an assets section, like this:
assets:
- assets/images/logo/welcome.png
- assets/images/logo/
# - images/a_dot_ham.jpeg