Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
2
22_23-J 21
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
22_23-J 21
22_23-J 21
Commits
fa272058
Commit
fa272058
authored
May 09, 2023
by
Karunarathna K.M.D.Y.K
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added register screens
parent
55d24997
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
193 additions
and
0 deletions
+193
-0
FrontEnd/lib/screens/register.dart
FrontEnd/lib/screens/register.dart
+193
-0
No files found.
FrontEnd/lib/screens/register.dart
0 → 100644
View file @
fa272058
import
'package:flutter/gestures.dart'
;
import
'package:flutter/material.dart'
;
import
'package:govimithura/models/error_model.dart'
;
import
'package:govimithura/screens/login.dart'
;
import
'package:govimithura/utils/loading_overlay.dart'
;
import
'package:govimithura/utils/utils.dart'
;
import
'package:provider/provider.dart'
;
import
'../providers/authentication_provider.dart'
;
import
'../utils/screen_size.dart'
;
import
'../widgets/utils/buttons/custom_elevated_button.dart'
;
import
'../widgets/utils/common_widget.dart'
;
import
'../widgets/utils/text_fields/primary_textfield.dart'
;
class
RegisterScreen
extends
StatefulWidget
{
const
RegisterScreen
({
super
.
key
});
@override
State
<
RegisterScreen
>
createState
()
=>
_RegisterScreenState
();
}
class
_RegisterScreenState
extends
State
<
RegisterScreen
>
{
late
AuthenticationProvider
pAuthentication
;
GlobalKey
<
FormState
>
registerFormKey
=
GlobalKey
<
FormState
>();
@override
void
initState
()
{
super
.
initState
();
pAuthentication
=
Provider
.
of
<
AuthenticationProvider
>(
context
,
listen:
false
);
}
@override
Widget
build
(
BuildContext
context
)
{
return
Scaffold
(
body:
SingleChildScrollView
(
child:
SizedBox
(
height:
ScreenSize
.
height
,
width:
ScreenSize
.
width
,
child:
Form
(
key:
registerFormKey
,
child:
Column
(
mainAxisSize:
MainAxisSize
.
max
,
mainAxisAlignment:
MainAxisAlignment
.
center
,
children:
[
Padding
(
padding:
const
EdgeInsets
.
symmetric
(
horizontal:
20
),
child:
Column
(
children:
[
const
LogoText
(),
spacingWidget
(
30
,
SpaceDirection
.
vertical
),
Text
(
'Welcome to Govimithura'
,
style:
Theme
.
of
(
context
).
textTheme
.
titleLarge
,
),
spacingWidget
(
20
,
SpaceDirection
.
vertical
),
PrimaryTextField
(
hintText:
"First name"
,
validator:
(
value
)
{
if
(
value
==
null
||
value
.
isEmpty
)
{
return
'Required'
;
}
return
null
;
},
onChanged:
(
value
)
{
pAuthentication
.
setFirstName
(
value
.
trim
());
},
),
spacingWidget
(
20
,
SpaceDirection
.
vertical
),
PrimaryTextField
(
hintText:
"Last name"
,
validator:
(
value
)
{
if
(
value
==
null
||
value
.
isEmpty
)
{
return
'Required'
;
}
return
null
;
},
onChanged:
(
value
)
{
pAuthentication
.
setLastName
(
value
.
trim
());
},
),
spacingWidget
(
20
,
SpaceDirection
.
vertical
),
PrimaryTextField
(
hintText:
"Email address"
,
validator:
(
value
)
{
if
(
value
==
null
||
value
.
isEmpty
)
{
return
'Required'
;
}
else
if
(!(
value
.
contains
(
"@"
)
&&
value
.
contains
(
"."
)))
{
return
'Enter valid Email Address'
;
}
return
null
;
},
onChanged:
(
value
)
{
pAuthentication
.
setEmail
(
value
.
trim
());
},
),
spacingWidget
(
20
,
SpaceDirection
.
vertical
),
PrimaryTextField
(
isPassword:
true
,
hintText:
"Password"
,
validator:
(
value
)
{
if
(
value
==
null
||
value
.
isEmpty
)
{
return
'Required'
;
}
return
null
;
},
onChanged:
(
value
)
{
pAuthentication
.
setPassWord
(
value
.
trim
());
},
),
spacingWidget
(
20
,
SpaceDirection
.
vertical
),
PrimaryTextField
(
isPassword:
true
,
hintText:
"Confirm password"
,
validator:
(
value
)
{
if
(
value
==
null
||
value
.
isEmpty
)
{
return
'Required'
;
}
else
if
(
value
!=
pAuthentication
.
authModel
.
password
)
{
return
"Password doesn't match"
;
}
return
null
;
},
onChanged:
(
value
)
{
pAuthentication
.
setConfirmPassword
(
value
.
trim
());
},
),
spacingWidget
(
30
,
SpaceDirection
.
vertical
),
CustomElevatedButton
(
text:
"Register "
,
onPressed:
()
async
{
if
(
registerFormKey
.
currentState
!.
validate
())
{
LoadingOverlay
overlay
=
LoadingOverlay
.
of
(
context
);
bool
success
=
await
overlay
.
during
(
pAuthentication
.
register
());
if
(
success
)
{
if
(
context
.
mounted
)
{
Navigator
.
pushReplacement
(
context
,
MaterialPageRoute
(
builder:
(
context
)
=>
const
LoginScreen
(),
),
);
}
}
else
{
if
(
context
.
mounted
)
{
Utils
.
showSnackBar
(
context
,
ErrorModel
.
errorMessage
);
}
}
}
},
),
spacingWidget
(
20
,
SpaceDirection
.
vertical
),
RichText
(
text:
TextSpan
(
text:
"Already have an account? "
,
style:
Theme
.
of
(
context
).
textTheme
.
bodyLarge
,
children:
[
TextSpan
(
text:
"Login"
,
style:
Theme
.
of
(
context
)
.
textTheme
.
bodyLarge
?.
copyWith
(
color:
Theme
.
of
(
context
).
primaryColor
,
),
recognizer:
TapGestureRecognizer
()
..
onTap
=
()
{
Navigator
.
pushReplacement
(
context
,
MaterialPageRoute
(
builder:
(
context
)
=>
const
LoginScreen
(),
),
);
},
),
],
),
)
],
),
),
],
),
),
),
),
);
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment