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
74dfb88c
Commit
74dfb88c
authored
May 10, 2023
by
Rathnayake K.U.R.S.D
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added crop diseases screens
parent
6118d66e
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
347 additions
and
0 deletions
+347
-0
FrontEnd/lib/screens/menu_screens/crop_diseases/disease_details_screen.dart
...ns/menu_screens/crop_diseases/disease_details_screen.dart
+192
-0
FrontEnd/lib/screens/menu_screens/crop_diseases/diseases_screen.dart
...b/screens/menu_screens/crop_diseases/diseases_screen.dart
+155
-0
No files found.
FrontEnd/lib/screens/menu_screens/crop_diseases/disease_details_screen.dart
0 → 100644
View file @
74dfb88c
import
'package:flutter/material.dart'
;
import
'package:govimithura/providers/disease_provider.dart'
;
import
'package:govimithura/providers/img_util_provider.dart'
;
import
'package:govimithura/utils/loading_overlay.dart'
;
import
'package:govimithura/utils/screen_size.dart'
;
import
'package:govimithura/widgets/utils/common_widget.dart'
;
import
'package:provider/provider.dart'
;
import
'../../../utils/utils.dart'
;
class
DiseaseDetailsScreen
extends
StatefulWidget
{
final
int
leafId
;
final
int
diseaseId
;
const
DiseaseDetailsScreen
(
{
super
.
key
,
required
this
.
leafId
,
required
this
.
diseaseId
});
@override
State
<
DiseaseDetailsScreen
>
createState
()
=>
_DiseaseDetailsScreenState
();
}
class
_DiseaseDetailsScreenState
extends
State
<
DiseaseDetailsScreen
>
with
SingleTickerProviderStateMixin
{
late
DiseaseProvider
pDisease
;
late
AnimationController
_controller
;
late
Animation
<
double
>
_animation
;
@override
void
dispose
()
{
_controller
.
dispose
();
super
.
dispose
();
}
@override
void
initState
()
{
super
.
initState
();
_controller
=
AnimationController
(
duration:
const
Duration
(
seconds:
2
),
vsync:
this
,
);
final
curvedAnimation
=
CurvedAnimation
(
parent:
_controller
,
curve:
Curves
.
easeInOut
);
_animation
=
Tween
<
double
>(
begin:
0
,
end:
1
).
animate
(
curvedAnimation
);
_controller
.
forward
();
pDisease
=
Provider
.
of
<
DiseaseProvider
>(
context
,
listen:
false
);
Future
.
delayed
(
Duration
.
zero
,
()
=>
initialize
());
}
@override
Widget
build
(
BuildContext
context
)
{
return
Scaffold
(
appBar:
AppBar
(
title:
const
Text
(
"Crop Disease Details"
),
centerTitle:
true
,
),
body:
SingleChildScrollView
(
child:
Padding
(
padding:
const
EdgeInsets
.
all
(
20
),
child:
Consumer
<
DiseaseProvider
>(
builder:
(
context
,
disease
,
child
)
{
return
Column
(
children:
[
Material
(
color:
Colors
.
white
,
borderRadius:
BorderRadius
.
circular
(
70
),
child:
SizedBox
(
height:
150
,
child:
Row
(
children:
[
spacingWidget
(
20
,
SpaceDirection
.
horizontal
),
CircleAvatar
(
onBackgroundImageError:
(
exception
,
stackTrace
)
=>
Utils
.
showSnackBar
(
context
,
'Error loading image'
),
backgroundColor:
Theme
.
of
(
context
).
primaryColor
,
radius:
50
,
backgroundImage:
Provider
.
of
<
ImageUtilProvider
>(
context
,
listen:
false
)
.
image
,
),
spacingWidget
(
20
,
SpaceDirection
.
horizontal
),
Flexible
(
child:
Column
(
mainAxisAlignment:
MainAxisAlignment
.
center
,
crossAxisAlignment:
CrossAxisAlignment
.
start
,
children:
[
Text
(
disease
.
leafEntity
.
description
,
style:
const
TextStyle
(
fontSize:
25
,
fontWeight:
FontWeight
.
bold
,
),
),
const
Text
(
"Leaf Name"
,
style:
TextStyle
(
fontSize:
16
,
color:
Colors
.
grey
,
),
),
],
),
),
],
),
),
),
if
(!
disease
.
diseaseEntity
.
name
.
toLowerCase
()
.
startsWith
(
"healthy"
))
Column
(
children:
[
const
SizedBox
(
height:
15
,
),
Text
(
disease
.
diseaseEntity
.
name
,
style:
const
TextStyle
(
fontWeight:
FontWeight
.
w600
,
fontSize:
20
,
),
),
spacingWidget
(
20
,
SpaceDirection
.
vertical
),
if
(
disease
.
diseaseEntity
.
image
.
isNotEmpty
)
Container
(
decoration:
BoxDecoration
(
borderRadius:
BorderRadius
.
circular
(
10
),
image:
DecorationImage
(
image:
NetworkImage
(
disease
.
diseaseEntity
.
image
),
fit:
BoxFit
.
cover
),
),
height:
ScreenSize
.
height
*
0.3
,
width:
ScreenSize
.
width
,
),
spacingWidget
(
20
,
SpaceDirection
.
vertical
),
Text
(
disease
.
diseaseEntity
.
description
,
style:
const
TextStyle
(
fontSize:
16
,
),
),
],
)
else
_successIntro
()
],
);
},
)),
),
);
}
Widget
_successIntro
()
{
return
ScaleTransition
(
scale:
_animation
,
child:
SizedBox
(
height:
ScreenSize
.
height
*
0.6
,
child:
Column
(
mainAxisAlignment:
MainAxisAlignment
.
center
,
children:
[
Container
(
width:
200
,
height:
200
,
decoration:
const
BoxDecoration
(
shape:
BoxShape
.
circle
,
color:
Colors
.
green
,
),
child:
const
Icon
(
Icons
.
check_rounded
,
size:
120
,
color:
Colors
.
white
,
),
),
spacingWidget
(
20
,
SpaceDirection
.
vertical
),
const
Text
(
"This leaf is Healthy"
,
style:
TextStyle
(
fontSize:
30
,
fontWeight:
FontWeight
.
bold
),
),
],
),
),
);
}
Future
<
void
>
initialize
()
async
{
await
LoadingOverlay
.
of
(
context
).
during
(
pDisease
.
getLeafsById
(
widget
.
leafId
,
widget
.
diseaseId
,
context
),
);
}
}
FrontEnd/lib/screens/menu_screens/crop_diseases/diseases_screen.dart
0 → 100644
View file @
74dfb88c
import
'package:flutter/material.dart'
;
import
'package:govimithura/providers/ml_provider.dart'
;
import
'package:govimithura/utils/loading_overlay.dart'
;
import
'package:govimithura/widgets/utils/buttons/custom_elevated_button.dart'
;
import
'package:image_picker/image_picker.dart'
;
import
'package:provider/provider.dart'
;
import
'../../../providers/img_util_provider.dart'
;
import
'../../../utils/screen_size.dart'
;
import
'../../../utils/utils.dart'
;
import
'../../../widgets/utils/common_widget.dart'
;
import
'../../../widgets/utils/image_util.dart'
;
import
'disease_details_screen.dart'
;
class
DiseasesScreen
extends
StatefulWidget
{
const
DiseasesScreen
({
super
.
key
});
@override
State
<
DiseasesScreen
>
createState
()
=>
_DiseasesScreenState
();
}
class
_DiseasesScreenState
extends
State
<
DiseasesScreen
>
{
@override
Widget
build
(
BuildContext
context
)
{
Size
imageSize
=
Size
(
ScreenSize
.
width
,
ScreenSize
.
height
*
0.45
);
return
Consumer
<
ImageUtilProvider
>(
builder:
(
context
,
pImage
,
child
)
{
return
Stack
(
children:
[
Container
(
height:
ScreenSize
.
height
,
width:
ScreenSize
.
width
,
color:
Theme
.
of
(
context
).
primaryColor
,
child:
Column
(
children:
const
[
CustomAssetImage
(
assetName:
"diseases_home.png"
)
],
),
),
Positioned
(
top:
ScreenSize
.
height
*
0.12
,
height:
ScreenSize
.
height
*
0.725
,
width:
ScreenSize
.
width
,
child:
Container
(
padding:
EdgeInsets
.
symmetric
(
horizontal:
ScreenSize
.
width
*
0.05
,
vertical:
ScreenSize
.
height
*
0.02
,
),
decoration:
const
BoxDecoration
(
color:
Colors
.
white
,
borderRadius:
BorderRadius
.
only
(
topLeft:
Radius
.
circular
(
20
),
topRight:
Radius
.
circular
(
20
)),
),
child:
Column
(
children:
[
ButtonBar
(
children:
[
CustomElevatedButton
(
text:
"Predict"
,
onPressed:
()
async
{
if
(
pImage
.
imagePath
==
null
)
{
Utils
.
showSnackBar
(
context
,
"Please select an image"
);
return
;
}
MLProvider
pML
=
Provider
.
of
<
MLProvider
>(
context
,
listen:
false
);
LoadingOverlay
overlay
=
LoadingOverlay
.
of
(
context
);
int
leafId
=
await
overlay
.
during
(
pML
.
predictLeaf
(
context
));
if
(
mounted
)
{
int
diseaseId
=
await
overlay
.
during
(
pML
.
predictDisease
(
context
,
leafId
));
if
(
mounted
&&
leafId
>=
0
&&
diseaseId
>=
0
)
{
Navigator
.
push
(
context
,
MaterialPageRoute
(
builder:
(
context
)
=>
DiseaseDetailsScreen
(
leafId:
leafId
,
diseaseId:
diseaseId
,
),
),
);
}
}
},
),
],
),
spacingWidget
(
10
,
SpaceDirection
.
vertical
),
Container
(
height:
imageSize
.
height
,
width:
imageSize
.
width
,
decoration:
BoxDecoration
(
image:
DecorationImage
(
image:
pImage
.
image
??
const
AssetImage
(
"assets/images/diseases_home.png"
),
fit:
BoxFit
.
cover
),
),
),
ButtonBar
(
alignment:
MainAxisAlignment
.
spaceAround
,
children:
[
FloatingActionButton
(
heroTag:
'gallery'
,
backgroundColor:
Theme
.
of
(
context
)
.
floatingActionButtonTheme
.
backgroundColor
,
onPressed:
()
async
{
await
Utils
.
pickImage
(
ImageSource
.
gallery
,
imageSize
,
context
);
},
child:
const
Icon
(
Icons
.
image_rounded
,
),
),
FloatingActionButton
.
large
(
heroTag:
'camera'
,
backgroundColor:
Theme
.
of
(
context
)
.
floatingActionButtonTheme
.
backgroundColor
,
onPressed:
()
async
{
await
Utils
.
pickImage
(
ImageSource
.
camera
,
imageSize
,
context
);
},
child:
const
Icon
(
Icons
.
photo_camera_rounded
,
size:
50
,
),
),
FloatingActionButton
(
heroTag:
'crop'
,
backgroundColor:
Theme
.
of
(
context
)
.
floatingActionButtonTheme
.
backgroundColor
,
onPressed:
()
async
{
await
Utils
.
cropImage
(
context
,
imageSize
);
},
child:
const
Icon
(
Icons
.
crop
,
),
),
],
),
],
),
),
),
],
);
},
);
}
}
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