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
fe4808b7
Commit
fe4808b7
authored
May 09, 2023
by
Kaushan H.K.R
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
added common widget and utils
parent
992bfd94
Changes
13
Hide whitespace changes
Inline
Side-by-side
Showing
13 changed files
with
467 additions
and
0 deletions
+467
-0
FrontEnd/lib/constants/images.dart
FrontEnd/lib/constants/images.dart
+5
-0
FrontEnd/lib/constants/post_status.dart
FrontEnd/lib/constants/post_status.dart
+6
-0
FrontEnd/lib/constants/post_types.dart
FrontEnd/lib/constants/post_types.dart
+3
-0
FrontEnd/lib/constants/storage_keys.dart
FrontEnd/lib/constants/storage_keys.dart
+3
-0
FrontEnd/lib/constants/user_types.dart
FrontEnd/lib/constants/user_types.dart
+4
-0
FrontEnd/lib/screens/splash_screen.dart
FrontEnd/lib/screens/splash_screen.dart
+58
-0
FrontEnd/lib/utils/loading_overlay.dart
FrontEnd/lib/utils/loading_overlay.dart
+46
-0
FrontEnd/lib/utils/screen_size.dart
FrontEnd/lib/utils/screen_size.dart
+20
-0
FrontEnd/lib/utils/utils.dart
FrontEnd/lib/utils/utils.dart
+66
-0
FrontEnd/lib/widgets/utils/buttons/custom_elevated_button.dart
...End/lib/widgets/utils/buttons/custom_elevated_button.dart
+18
-0
FrontEnd/lib/widgets/utils/common_widget.dart
FrontEnd/lib/widgets/utils/common_widget.dart
+158
-0
FrontEnd/lib/widgets/utils/image_util.dart
FrontEnd/lib/widgets/utils/image_util.dart
+16
-0
FrontEnd/lib/widgets/utils/text_fields/primary_textfield.dart
...tEnd/lib/widgets/utils/text_fields/primary_textfield.dart
+64
-0
No files found.
FrontEnd/lib/constants/images.dart
0 → 100644
View file @
fe4808b7
class
Images
{
static
const
logo
=
'assets/images/logo.png'
;
static
const
defaultAvatar
=
'https://firebasestorage.googleapis.com/v0/b/govi-mithura-412b5.appspot.com/o/profileImages%2Fuser.png?alt=media&token=4687627a-c350-4f45-b31b-ce764f6dd55d'
;
}
FrontEnd/lib/constants/post_status.dart
0 → 100644
View file @
fe4808b7
class
PostStatus
{
static
const
String
all
=
"All"
;
static
const
String
pending
=
"Pending"
;
static
const
String
approved
=
"Approved"
;
static
const
String
rejected
=
"Rejected"
;
}
FrontEnd/lib/constants/post_types.dart
0 → 100644
View file @
fe4808b7
class
PostType
{
static
const
String
pestControlMethod
=
"PEST_CONTROL_METHOD"
;
}
FrontEnd/lib/constants/storage_keys.dart
0 → 100644
View file @
fe4808b7
class
StorageKeys
{
static
const
userType
=
'USER_TYPE'
;
}
FrontEnd/lib/constants/user_types.dart
0 → 100644
View file @
fe4808b7
class
UserType
{
static
const
String
admin
=
"ADMIN"
;
static
const
String
user
=
"USER"
;
}
FrontEnd/lib/screens/splash_screen.dart
0 → 100644
View file @
fe4808b7
import
'package:flutter/material.dart'
;
import
'package:govimithura/constants/user_types.dart'
;
import
'package:govimithura/providers/authentication_provider.dart'
;
import
'package:govimithura/screens/admin_home.dart'
;
import
'package:govimithura/screens/home.dart'
;
import
'package:govimithura/screens/login.dart'
;
import
'package:govimithura/widgets/utils/common_widget.dart'
;
import
'package:provider/provider.dart'
;
import
'../utils/screen_size.dart'
;
class
SplashScreen
extends
StatefulWidget
{
const
SplashScreen
({
super
.
key
});
@override
State
<
SplashScreen
>
createState
()
=>
_SplashScreenState
();
}
class
_SplashScreenState
extends
State
<
SplashScreen
>
{
late
AuthenticationProvider
pAuthentication
;
@override
void
initState
()
{
super
.
initState
();
pAuthentication
=
Provider
.
of
<
AuthenticationProvider
>(
context
,
listen:
false
);
Future
.
delayed
(
const
Duration
(
seconds:
3
),
()
async
{
await
pAuthentication
.
getCurentUserModel
();
if
(
mounted
)
{
Navigator
.
pushReplacement
(
context
,
MaterialPageRoute
(
builder:
(
context
)
{
if
(
pAuthentication
.
isLoggedIn
())
{
if
(
pAuthentication
.
authModel
.
userType
==
UserType
.
admin
)
{
return
const
AdminHome
();
}
else
{
return
const
Home
();
}
}
else
{
return
const
LoginScreen
();
}
}),
);
}
});
}
@override
Widget
build
(
BuildContext
context
)
{
ScreenSize
.
init
(
context
);
ThemeData
theme
=
Theme
.
of
(
context
);
return
Scaffold
(
backgroundColor:
theme
.
primaryColor
,
body:
const
Center
(
child:
Logo
(),
),
);
}
}
FrontEnd/lib/utils/loading_overlay.dart
0 → 100644
View file @
fe4808b7
import
'package:flutter/material.dart'
;
class
LoadingOverlay
{
BuildContext
_context
;
void
hide
()
{
Navigator
.
of
(
_context
).
pop
();
}
void
show
()
{
showDialog
(
barrierDismissible:
false
,
context:
_context
,
useSafeArea:
false
,
builder:
(
BuildContext
context
)
{
return
_FullScreenLoader
();
},
);
}
Future
<
T
>
during
<
T
>(
Future
<
T
>
future
)
{
show
();
return
future
.
whenComplete
(()
=>
hide
());
}
LoadingOverlay
.
_create
(
this
.
_context
);
factory
LoadingOverlay
.
of
(
BuildContext
context
)
{
return
LoadingOverlay
.
_create
(
context
);
}
}
class
_FullScreenLoader
extends
StatelessWidget
{
@override
Widget
build
(
BuildContext
context
)
{
return
Container
(
width:
250
,
decoration:
const
BoxDecoration
(
color:
Color
.
fromRGBO
(
0
,
0
,
0
,
0.5
),
),
child:
const
Center
(
child:
CircularProgressIndicator
(),
),
);
}
}
FrontEnd/lib/utils/screen_size.dart
0 → 100644
View file @
fe4808b7
import
'package:flutter/material.dart'
;
class
ScreenSize
{
static
double
_width
=
0
;
static
double
_height
=
0
;
static
double
_appBarHeight
=
0
;
static
double
get
width
=>
_width
;
static
double
get
height
=>
_height
;
static
double
get
appBarHeight
=>
_appBarHeight
;
static
init
(
BuildContext
context
)
{
_width
=
MediaQuery
.
of
(
context
).
size
.
width
;
_height
=
MediaQuery
.
of
(
context
).
size
.
height
;
}
static
initAppBarHeight
(
AppBar
appBar
)
{
_appBarHeight
=
appBar
.
preferredSize
.
height
;
}
}
FrontEnd/lib/utils/utils.dart
0 → 100644
View file @
fe4808b7
import
'package:flutter/material.dart'
;
import
'package:govimithura/widgets/utils/buttons/custom_elevated_button.dart'
;
class
Utils
{
static
void
showSnackBar
(
BuildContext
context
,
String
message
)
{
ScaffoldMessenger
.
of
(
context
).
showSnackBar
(
SnackBar
(
content:
Text
(
reBuildExceptionMessage
(
message
)),
duration:
const
Duration
(
seconds:
5
),
),
);
}
static
void
showDialogBox
(
BuildContext
context
,
String
message
)
{
showDialog
(
barrierDismissible:
false
,
context:
context
,
builder:
(
context
)
{
return
AlertDialog
(
title:
const
Text
(
'Alert !'
),
content:
Text
(
message
),
actions:
[
CustomElevatedButton
(
text:
'OK'
,
onPressed:
()
{
Navigator
.
pop
(
context
);
})
],
);
});
}
static
String
toSnakeCase
(
String
text
)
{
return
text
.
split
(
' '
).
map
((
e
)
=>
e
.
toLowerCase
()).
toList
().
join
(
'_'
);
}
static
String
getAgoTime
(
DateTime
dateTime
)
{
Duration
duration
=
DateTime
.
now
().
difference
(
dateTime
);
if
(
duration
.
inDays
>
365
)
{
return
'
${(duration.inDays / 365).floor()}
years ago'
;
}
else
if
(
duration
.
inDays
>
30
)
{
return
'
${(duration.inDays / 30).floor()}
months ago'
;
}
else
if
(
duration
.
inDays
>
0
)
{
return
'
${duration.inDays}
days ago'
;
}
else
if
(
duration
.
inHours
>
0
)
{
return
'
${duration.inHours}
hours ago'
;
}
else
if
(
duration
.
inMinutes
>
0
)
{
return
'
${duration.inMinutes}
minutes ago'
;
}
else
{
return
'Just now'
;
}
}
static
String
getFormattedDateTime
(
DateTime
dateTime
)
{
return
'
${dateTime.year}
-
${dateTime.month.toString().padLeft(2, '0')}
-
${dateTime.day.toString().padLeft(2, '0')}
${dateTime.hour.toString().padLeft(2, '0')}
:
${dateTime.minute.toString().padLeft(2, '0')}
:
${dateTime.second.toString().padLeft(2, '0')}
'
;
}
static
String
reBuildExceptionMessage
(
String
message
)
{
if
(
message
.
startsWith
(
"Exception:"
))
{
return
message
.
substring
(
11
,
message
.
length
-
1
);
}
return
message
;
}
}
FrontEnd/lib/widgets/utils/buttons/custom_elevated_button.dart
0 → 100644
View file @
fe4808b7
import
'package:flutter/material.dart'
;
class
CustomElevatedButton
extends
StatelessWidget
{
final
String
text
;
final
VoidCallback
onPressed
;
const
CustomElevatedButton
(
{
super
.
key
,
required
this
.
text
,
required
this
.
onPressed
});
@override
Widget
build
(
BuildContext
context
)
{
ThemeData
theme
=
Theme
.
of
(
context
);
return
ElevatedButton
(
onPressed:
onPressed
,
style:
theme
.
elevatedButtonTheme
.
style
,
child:
Text
(
text
),
);
}
}
FrontEnd/lib/widgets/utils/common_widget.dart
0 → 100644
View file @
fe4808b7
import
'package:flutter/material.dart'
;
import
'package:govimithura/constants/post_status.dart'
;
import
'package:govimithura/utils/screen_size.dart'
;
import
'../../constants/images.dart'
;
class
Logo
extends
StatelessWidget
{
const
Logo
({
super
.
key
,
});
@override
Widget
build
(
BuildContext
context
)
{
return
Container
(
height:
200
,
width:
200
,
decoration:
const
BoxDecoration
(
borderRadius:
BorderRadius
.
only
(
bottomRight:
Radius
.
circular
(
20
),
topLeft:
Radius
.
circular
(
20
),
),
image:
DecorationImage
(
image:
AssetImage
(
Images
.
logo
),
fit:
BoxFit
.
cover
,
),
),
);
}
}
class
LogoText
extends
StatelessWidget
{
const
LogoText
({
super
.
key
,
});
@override
Widget
build
(
BuildContext
context
)
{
return
SizedBox
(
width:
ScreenSize
.
width
,
child:
Row
(
mainAxisAlignment:
MainAxisAlignment
.
center
,
children:
[
Container
(
height:
100
,
width:
100
,
decoration:
const
BoxDecoration
(
borderRadius:
BorderRadius
.
only
(
bottomRight:
Radius
.
circular
(
30
),
topLeft:
Radius
.
circular
(
30
),
),
image:
DecorationImage
(
image:
AssetImage
(
Images
.
logo
),
fit:
BoxFit
.
cover
,
),
),
),
spacingWidget
(
10
,
SpaceDirection
.
horizontal
),
Text
(
"Govi Mithura"
,
style:
Theme
.
of
(
context
).
textTheme
.
headlineMedium
?.
copyWith
(
color:
Theme
.
of
(
context
).
primaryColor
,
fontWeight:
FontWeight
.
w600
,
),
)
],
),
);
}
}
enum
SpaceDirection
{
horizontal
,
vertical
}
Widget
spacingWidget
(
double
size
,
SpaceDirection
direction
)
{
return
direction
==
SpaceDirection
.
horizontal
?
SizedBox
(
width:
size
)
:
SizedBox
(
height:
size
);
}
Widget
confirmationDialog
(
BuildContext
context
,
{
required
String
title
,
void
Function
()?
yesFunction
,
String
additionalText
=
""
})
{
return
AlertDialog
(
title:
Text
(
title
),
content:
Column
(
crossAxisAlignment:
CrossAxisAlignment
.
start
,
mainAxisSize:
MainAxisSize
.
min
,
mainAxisAlignment:
MainAxisAlignment
.
center
,
children:
[
if
(
additionalText
.
isNotEmpty
)
Text
(
additionalText
,
style:
const
TextStyle
(
fontSize:
18
),
),
const
Text
(
"Are you sure "
,
style:
TextStyle
(
fontSize:
18
),
),
],
),
actions:
[
TextButton
(
onPressed:
yesFunction
,
child:
const
Text
(
"Yes"
),
),
TextButton
(
onPressed:
()
{
Navigator
.
pop
(
context
);
},
child:
const
Text
(
"No"
),
),
],
);
}
class
SlidePageRoute
extends
PageRouteBuilder
{
final
Widget
page
;
SlidePageRoute
({
required
this
.
page
})
:
super
(
pageBuilder:
(
_
,
__
,
___
)
=>
page
,
transitionsBuilder:
(
_
,
animation
,
__
,
child
)
=>
SlideTransition
(
position:
Tween
<
Offset
>(
begin:
const
Offset
(
1.0
,
0.0
),
end:
Offset
.
zero
,
).
animate
(
animation
),
child:
child
,
),
);
}
Widget
postStatus
(
String
status
)
{
Color
color
=
Colors
.
green
;
if
(
status
==
PostStatus
.
pending
)
{
color
=
Colors
.
orange
;
}
if
(
status
==
PostStatus
.
rejected
)
{
color
=
Colors
.
red
;
}
return
Row
(
children:
[
const
Text
(
"Status: "
,
style:
TextStyle
(
fontWeight:
FontWeight
.
bold
),
),
Container
(
padding:
const
EdgeInsets
.
all
(
5
),
decoration:
BoxDecoration
(
color:
color
,
borderRadius:
BorderRadius
.
circular
(
5
),
),
child:
Text
(
status
,
style:
const
TextStyle
(
color:
Colors
.
white
),
),
),
],
);
}
FrontEnd/lib/widgets/utils/image_util.dart
0 → 100644
View file @
fe4808b7
import
'package:flutter/material.dart'
;
class
CustomAssetImage
extends
StatelessWidget
{
final
String
assetName
;
final
BoxFit
fit
;
const
CustomAssetImage
(
{
super
.
key
,
required
this
.
assetName
,
this
.
fit
=
BoxFit
.
cover
});
@override
Widget
build
(
BuildContext
context
)
{
return
Image
.
asset
(
"assets/images/
$assetName
"
,
fit:
fit
,
);
}
}
FrontEnd/lib/widgets/utils/text_fields/primary_textfield.dart
0 → 100644
View file @
fe4808b7
import
'package:flutter/material.dart'
;
class
PrimaryTextField
extends
StatefulWidget
{
final
Function
(
String
)?
onChanged
;
final
String
hintText
;
final
Widget
?
prefixIcon
;
final
Widget
?
suffixIcon
;
final
String
?
Function
(
String
?)?
validator
;
final
int
maxLines
;
final
bool
isPassword
;
final
String
?
initialValue
;
final
String
?
label
;
final
TextEditingController
?
controller
;
final
Function
()?
onTap
;
final
bool
isFilled
;
const
PrimaryTextField
({
super
.
key
,
this
.
onChanged
,
this
.
hintText
=
""
,
this
.
prefixIcon
,
this
.
suffixIcon
,
this
.
validator
,
this
.
maxLines
=
1
,
this
.
isPassword
=
false
,
this
.
initialValue
,
this
.
label
,
this
.
controller
,
this
.
onTap
,
this
.
isFilled
=
false
,
});
@override
State
<
PrimaryTextField
>
createState
()
=>
_PrimaryTextFieldState
();
}
class
_PrimaryTextFieldState
extends
State
<
PrimaryTextField
>
{
@override
Widget
build
(
BuildContext
context
)
{
InputDecorationTheme
inputDecorationTheme
=
Theme
.
of
(
context
).
inputDecorationTheme
;
return
TextFormField
(
onTap:
widget
.
onTap
,
initialValue:
widget
.
initialValue
,
controller:
widget
.
controller
,
maxLines:
widget
.
maxLines
,
onChanged:
widget
.
onChanged
,
validator:
widget
.
validator
,
obscureText:
widget
.
isPassword
,
decoration:
InputDecoration
(
filled:
widget
.
isFilled
,
label:
widget
.
label
!=
null
?
Text
(
widget
.
label
!)
:
null
,
border:
widget
.
isFilled
?
InputBorder
.
none
:
inputDecorationTheme
.
border
,
focusedBorder:
widget
.
isFilled
?
InputBorder
.
none
:
inputDecorationTheme
.
focusedBorder
,
hintText:
widget
.
hintText
,
prefixIcon:
widget
.
prefixIcon
,
suffixIcon:
widget
.
suffixIcon
,
focusColor:
inputDecorationTheme
.
focusColor
,
),
);
}
}
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