authentication screens layout

This commit is contained in:
MohammadTaha Basiri 2021-12-11 10:32:44 +03:30
parent fc0745abfe
commit 9b49dc5f1a
4 changed files with 191 additions and 199 deletions

View File

@ -1,9 +1,8 @@
import 'package:didvan/pages/authentication/authentication_state.dart';
import 'package:didvan/pages/authentication/widgets/authentication_app_bar.dart';
import 'package:didvan/pages/authentication/widgets/authentication_layout.dart';
import 'package:didvan/widgets/didvan/button.dart';
import 'package:didvan/widgets/didvan/text.dart';
import 'package:didvan/widgets/didvan/text_field.dart';
import 'package:didvan/widgets/logos/didvan_horizontal_logo.dart';
import 'package:flutter/material.dart';
import 'package:provider/provider.dart';
@ -13,53 +12,36 @@ class PasswordInput extends StatelessWidget {
@override
Widget build(BuildContext context) {
final AuthenticationState state = context.read<AuthenticationState>();
return SingleChildScrollView(
padding: const EdgeInsets.symmetric(horizontal: 20),
child: SizedBox(
height: MediaQuery.of(context).size.height,
child: Column(
children: [
AuthenticationAppBar(
title: 'ورود با شماره موبایل ' + state.phoneNumber,
),
const Padding(
padding: EdgeInsets.only(
bottom: 44,
top: 34,
left: 100,
right: 100,
),
child: DidvanVerticalLogo(),
),
DidvanTextField(
onChanged: (value) => state.password = value,
autoFocus: true,
title: 'کلمه عبور',
hintText: 'کلمه عبور',
obsecureText: true,
),
const SizedBox(
height: 32,
),
GestureDetector(
onTap: () => state.currentPageIndex++,
child: DidvanText(
'فراموشی رمز عبور',
style: Theme.of(context).textTheme.subtitle2,
color: Theme.of(context).primaryColor,
),
),
const Spacer(),
DidvanButton(
onPressed: () {},
title: 'ورود',
),
const SizedBox(
height: 48,
),
],
return AuthenticationLayout(
appBarTitle: 'ورود با شماره موبایل ' + state.phoneNumber,
children: [
DidvanTextField(
onChanged: (value) => state.password = value,
autoFocus: true,
title: 'کلمه عبور',
hintText: 'کلمه عبور',
obsecureText: true,
),
),
const SizedBox(
height: 32,
),
GestureDetector(
onTap: () => state.currentPageIndex++,
child: DidvanText(
'فراموشی رمز عبور',
style: Theme.of(context).textTheme.subtitle2,
color: Theme.of(context).primaryColor,
),
),
const Spacer(),
DidvanButton(
onPressed: () {},
title: 'ورود',
),
const SizedBox(
height: 48,
),
],
);
}
}

View File

@ -1,7 +1,7 @@
import 'package:didvan/pages/authentication/authentication_state.dart';
import 'package:didvan/pages/authentication/widgets/authentication_layout.dart';
import 'package:didvan/widgets/didvan/button.dart';
import 'package:didvan/widgets/didvan/text_field.dart';
import 'package:didvan/widgets/logos/didvan_horizontal_logo.dart';
import 'package:flutter/gestures.dart';
import 'package:flutter/material.dart';
import 'package:provider/provider.dart';
@ -14,83 +14,67 @@ class PhoneNumberInput extends StatelessWidget {
@override
Widget build(BuildContext context) {
final AuthenticationState state = context.read<AuthenticationState>();
return SingleChildScrollView(
physics: const NeverScrollableScrollPhysics(),
padding: const EdgeInsets.all(20),
child: SizedBox(
height: MediaQuery.of(context).size.height,
child: Column(
children: [
const Padding(
padding: EdgeInsets.only(
top: 80,
left: 100,
right: 100,
bottom: 40,
),
child: DidvanVerticalLogo(),
),
DidvanTextField(
title: 'شماره موبایل',
textInputType: TextInputType.phone,
hintText: 'شماره موبایل',
textAlign: TextAlign.center,
onChanged: (value) {
state.phoneNumber = value;
},
),
const SizedBox(
height: 20,
),
DidvanButton(
title: 'ورود',
onPressed: () {
state.currentPageIndex = 1;
},
),
const Spacer(),
Padding(
padding: const EdgeInsets.symmetric(horizontal: 60),
child: RichText(
textAlign: TextAlign.center,
text: TextSpan(
style: Theme.of(context).textTheme.caption,
children: [
const TextSpan(text: 'با ثبت نام و ورود به دیدوان،'),
TextSpan(
text: ' شرایط ',
style: Theme.of(context)
.textTheme
.caption!
.copyWith(color: Theme.of(context).primaryColor),
recognizer: TapGestureRecognizer()
..onTap = () {
//TODO: Needs implementaion
},
),
const TextSpan(text: 'و\n'),
TextSpan(
text: ' قوانین حریم خصوصی ',
style: Theme.of(context)
.textTheme
.caption!
.copyWith(color: Theme.of(context).primaryColor),
recognizer: TapGestureRecognizer()
..onTap = () {
//TODO: Needs implementaion
},
),
const TextSpan(text: 'را می‌پذیرم'),
],
),
),
),
const SizedBox(
height: 48,
),
],
return AuthenticationLayout(
children: [
DidvanTextField(
title: 'شماره موبایل',
textInputType: TextInputType.phone,
hintText: 'شماره موبایل',
textAlign: TextAlign.center,
onChanged: (value) {
state.phoneNumber = value;
},
),
),
const SizedBox(
height: 20,
),
DidvanButton(
title: 'ورود',
onPressed: () {
state.currentPageIndex = 1;
},
),
const Spacer(),
Padding(
padding: const EdgeInsets.symmetric(horizontal: 60),
child: RichText(
textAlign: TextAlign.center,
text: TextSpan(
style: Theme.of(context).textTheme.caption,
children: [
const TextSpan(text: 'با ثبت نام و ورود به دیدوان،'),
TextSpan(
text: ' شرایط ',
style: Theme.of(context)
.textTheme
.caption!
.copyWith(color: Theme.of(context).primaryColor),
recognizer: TapGestureRecognizer()
..onTap = () {
//TODO: Needs implementaion
},
),
const TextSpan(text: 'و\n'),
TextSpan(
text: ' قوانین حریم خصوصی ',
style: Theme.of(context)
.textTheme
.caption!
.copyWith(color: Theme.of(context).primaryColor),
recognizer: TapGestureRecognizer()
..onTap = () {
//TODO: Needs implementaion
},
),
const TextSpan(text: 'را می‌پذیرم'),
],
),
),
),
const SizedBox(
height: 48,
),
],
);
}
}

View File

@ -1,9 +1,8 @@
import 'package:didvan/config/design_config.dart';
import 'package:didvan/pages/authentication/authentication_state.dart';
import 'package:didvan/pages/authentication/widgets/authentication_app_bar.dart';
import 'package:didvan/pages/authentication/widgets/authentication_layout.dart';
import 'package:didvan/widgets/didvan/button.dart';
import 'package:didvan/widgets/didvan/text.dart';
import 'package:didvan/widgets/logos/didvan_horizontal_logo.dart';
import 'package:flutter/material.dart';
import 'package:pin_code_fields/pin_code_fields.dart';
import 'package:provider/provider.dart';
@ -14,79 +13,61 @@ class Verification extends StatelessWidget {
@override
Widget build(BuildContext context) {
final AuthenticationState state = context.read<AuthenticationState>();
return SingleChildScrollView(
physics: const NeverScrollableScrollPhysics(),
padding: const EdgeInsets.symmetric(horizontal: 20),
child: SizedBox(
height: MediaQuery.of(context).size.height,
child: Column(
children: [
const AuthenticationAppBar(
title: 'تغییر رمز عبور',
),
const Padding(
padding: EdgeInsets.only(
bottom: 24,
top: 34,
left: 100,
right: 100,
),
child: DidvanVerticalLogo(),
),
DidvanText(
'کد 6 رقممی ارسال شده به موبایل',
style: Theme.of(context).textTheme.subtitle2,
fontWeight: FontWeight.normal,
),
const SizedBox(
height: 8,
),
DidvanText(
state.phoneNumber,
style: Theme.of(context).textTheme.subtitle1,
),
const SizedBox(
height: 8,
),
DidvanText(
'را وارد کنید:',
style: Theme.of(context).textTheme.subtitle2,
fontWeight: FontWeight.normal,
),
const SizedBox(
height: 24,
),
Directionality(
textDirection: TextDirection.ltr,
child: PinCodeTextField(
keyboardType: TextInputType.number,
animationType: AnimationType.scale,
pinTheme: PinTheme(
fieldHeight: 48,
fieldWidth: 48,
inactiveColor: DesignConfig.greyColor4,
activeFillColor: Theme.of(context).primaryColorLight,
activeColor: Theme.of(context).primaryColor,
borderRadius: DesignConfig.lowBorderRadius,
borderWidth: 1,
shape: PinCodeFieldShape.box,
),
appContext: context,
length: 6,
onChanged: (value) => state.verificationCode = value,
),
),
const Spacer(),
DidvanButton(
onPressed: () {},
title: 'تایید',
),
const SizedBox(
height: 48,
),
],
return AuthenticationLayout(
appBarTitle: 'تغییر رمز عبور',
children: [
DidvanText(
'کد 6 رقممی ارسال شده به موبایل',
style: Theme.of(context).textTheme.subtitle2,
fontWeight: FontWeight.normal,
),
),
const SizedBox(
height: 8,
),
DidvanText(
state.phoneNumber,
style: Theme.of(context).textTheme.subtitle1,
),
const SizedBox(
height: 8,
),
DidvanText(
'را وارد کنید:',
style: Theme.of(context).textTheme.subtitle2,
fontWeight: FontWeight.normal,
),
const SizedBox(
height: 24,
),
Directionality(
textDirection: TextDirection.ltr,
child: PinCodeTextField(
keyboardType: TextInputType.number,
animationType: AnimationType.scale,
pinTheme: PinTheme(
fieldHeight: 48,
fieldWidth: 48,
inactiveColor: DesignConfig.greyColor4,
activeFillColor: Theme.of(context).primaryColorLight,
activeColor: Theme.of(context).primaryColor,
borderRadius: DesignConfig.lowBorderRadius,
borderWidth: 1,
shape: PinCodeFieldShape.box,
),
appContext: context,
length: 6,
onChanged: (value) => state.verificationCode = value,
),
),
const Spacer(),
DidvanButton(
onPressed: () {},
title: 'تایید',
),
const SizedBox(
height: 48,
),
],
);
}
}

View File

@ -0,0 +1,45 @@
import 'package:didvan/pages/authentication/widgets/authentication_app_bar.dart';
import 'package:didvan/widgets/logos/didvan_horizontal_logo.dart';
import 'package:flutter/material.dart';
class AuthenticationLayout extends StatelessWidget {
final List<Widget> children;
final String? appBarTitle;
const AuthenticationLayout(
{Key? key, required this.children, this.appBarTitle})
: super(key: key);
@override
Widget build(BuildContext context) {
return SingleChildScrollView(
padding: const EdgeInsets.symmetric(horizontal: 20),
physics: const NeverScrollableScrollPhysics(),
child: SizedBox(
height: MediaQuery.of(context).size.height,
child: Column(
children: [
if (appBarTitle != null)
AuthenticationAppBar(
title: appBarTitle,
),
if (appBarTitle == null)
const SizedBox(
height: 66,
),
const Padding(
padding: EdgeInsets.only(
top: 44,
left: 100,
right: 100,
bottom: 40,
),
child: DidvanVerticalLogo(),
),
...children,
],
),
),
);
}
}