Skip to content
GitLab
Explore
Projects
Groups
Topics
Snippets
Projects
Groups
Topics
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Register
Sign in
Toggle navigation
Menu
UPSMF
uphrh-smf-mobile
Commits
ef0984a1
Commit
ef0984a1
authored
3 years ago
by
Shoaib
Browse files
Options
Download
Patches
Plain Diff
Integrated sumbitInspection API.
parent
3261673b
master
add-assessor-location
deps-update
two-lead-assessor
No related merge requests found
Changes
16
Hide whitespace changes
Inline
Side-by-side
Showing
16 changed files
lib/constants/api_endpoints.dart
+1
-0
lib/constants/api_endpoints.dart
lib/constants/color_constants.dart
+1
-0
lib/constants/color_constants.dart
lib/models/application_model.dart
+5
-1
lib/models/application_model.dart
lib/pages/application_details_page.dart
+74
-7
lib/pages/application_details_page.dart
lib/pages/home_page.dart
+26
-17
lib/pages/home_page.dart
lib/pages/inspection_summary.dart
+113
-16
lib/pages/inspection_summary.dart
lib/pages/login_email_page.dart
+3
-17
lib/pages/login_email_page.dart
lib/pages/login_otp_page.dart
+2
-21
lib/pages/login_otp_page.dart
lib/repositories/application_repository.dart
+15
-0
lib/repositories/application_repository.dart
lib/services/application_service.dart
+15
-8
lib/services/application_service.dart
lib/services/base_service.dart
+0
-4
lib/services/base_service.dart
lib/services/login_service.dart
+6
-3
lib/services/login_service.dart
lib/util/helper.dart
+37
-2
lib/util/helper.dart
lib/widgets/application_card.dart
+2
-0
lib/widgets/application_card.dart
lib/widgets/application_field.dart
+93
-55
lib/widgets/application_field.dart
lib/widgets/people_card.dart
+0
-76
lib/widgets/people_card.dart
with
393 additions
and
227 deletions
+393
-227
lib/constants/api_endpoints.dart
+
1
−
0
View file @
ef0984a1
...
...
@@ -3,4 +3,5 @@ class ApiUrl {
static
const
getOtp
=
'
$baseUrl
/api/user/requestOTP'
;
static
const
validateOtp
=
'
$baseUrl
/api/signIn'
;
static
const
getAllApplications
=
'
$baseUrl
/api/forms/getAllApplications'
;
static
const
submitInspection
=
'
$baseUrl
/api/forms/submitInspection'
;
}
This diff is collapsed.
Click to expand it.
lib/constants/color_constants.dart
+
1
−
0
View file @
ef0984a1
...
...
@@ -2,6 +2,7 @@ import 'package:flutter/material.dart';
class
AppColors
{
static
const
scaffoldBackground
=
Color
.
fromRGBO
(
240
,
243
,
244
,
1
);
static
const
fieldBackground
=
Color
.
fromARGB
(
255
,
236
,
237
,
238
);
static
const
primaryBlue
=
Color
.
fromRGBO
(
4
,
93
,
173
,
1
);
static
const
radioSelected
=
Color
.
fromRGBO
(
0
,
116
,
182
,
0.2
);
static
const
primaryGreen
=
Color
.
fromRGBO
(
48
,
105
,
51
,
1
);
...
...
This diff is collapsed.
Click to expand it.
lib/models/application_model.dart
+
5
−
1
View file @
ef0984a1
...
...
@@ -7,6 +7,7 @@ class Application {
final
String
email
;
final
String
status
;
final
Map
dataObject
;
final
List
inspectors
;
final
String
scheduledDate
;
final
String
createdDate
;
final
String
createdBy
;
...
...
@@ -18,6 +19,7 @@ class Application {
required
this
.
email
,
required
this
.
status
,
required
this
.
dataObject
,
required
this
.
inspectors
,
required
this
.
scheduledDate
,
required
this
.
createdDate
,
required
this
.
createdBy
,
...
...
@@ -31,7 +33,8 @@ class Application {
email:
json
[
'email'
]
??
''
,
status:
json
[
'status'
],
dataObject:
json
[
'dataObject'
],
scheduledDate:
json
[
'scheduledDate'
]
??
'2022-02-15'
,
inspectors:
json
[
'inspection'
][
'assignedTo'
]
??
[],
scheduledDate:
json
[
'inspection'
][
'scheduledDate'
]
??
''
,
createdDate:
json
[
'createdDate'
]
!=
null
?
DateFormat
.
yMMMEd
()
.
format
(
DateTime
.
parse
(
json
[
'createdDate'
]))
:
''
,
...
...
@@ -46,6 +49,7 @@ class Application {
email
,
status
,
dataObject
,
inspectors
,
scheduledDate
,
createdDate
,
createdBy
...
...
This diff is collapsed.
Click to expand it.
lib/pages/application_details_page.dart
+
74
−
7
View file @
ef0984a1
import
'package:flutter/material.dart'
;
import
'package:google_fonts/google_fonts.dart'
;
import
'package:provider/provider.dart'
;
import
'package:smf_mobile/constants/color_constants.dart'
;
import
'package:smf_mobile/pages/inspection_summary.dart'
;
import
'package:smf_mobile/pages/login_email_page.dart'
;
import
'package:smf_mobile/repositories/application_repository.dart'
;
import
'package:smf_mobile/util/helper.dart'
;
import
'package:smf_mobile/widgets/application_field.dart'
;
import
'package:smf_mobile/widgets/silverappbar_delegate.dart'
;
class
ApplicationDetailsPage
extends
StatefulWidget
{
final
String
applicationId
;
final
String
applicationTitle
;
final
Map
applicationFields
;
final
List
applicationInspectors
;
const
ApplicationDetailsPage
({
Key
?
key
,
required
this
.
applicationId
,
required
this
.
applicationTitle
,
required
this
.
applicationFields
,
required
this
.
applicationInspectors
,
})
:
super
(
key:
key
);
@override
...
...
@@ -23,17 +31,18 @@ class _ApplicationDetailsPageState extends State<ApplicationDetailsPage>
final
GlobalKey
<
ScaffoldState
>
_scaffoldKey
=
GlobalKey
<
ScaffoldState
>();
TabController
?
_tabController
;
int
_activeTabIndex
=
0
;
final
Map
_data
=
{};
final
List
<
String
>
_tabs
=
[];
final
List
<
Map
>
_fields
=
[];
String
_errorMessage
=
''
;
@override
void
initState
()
{
super
.
initState
();
widget
.
applicationFields
.
forEach
((
key
,
value
)
=
>
_tabs
.
add
(
key
));
widget
.
applicationFields
.
forEach
((
key
,
value
)
=
>
_fields
.
add
(
value
));
// print(_fields);
_tabController
=
TabController
(
vsync:
this
,
length:
_tabs
.
length
);
_tabController
!.
addListener
(
_setActiveTabIndex
);
_populateFields
();
}
void
_setActiveTabIndex
()
{
...
...
@@ -42,6 +51,66 @@ class _ApplicationDetailsPageState extends State<ApplicationDetailsPage>
});
}
void
_populateFields
()
{
Map
updatedFields
=
{};
widget
.
applicationFields
.
forEach
((
key
,
value
)
=
>
{
updatedFields
=
{},
value
.
forEach
((
childKey
,
childValue
)
=
>
{
updatedFields
[
childKey
]
=
{
childValue:
{
'value'
:
'Correct'
,
'comments'
:
''
}
}
}),
_data
[
key
]
=
updatedFields
});
_data
.
forEach
((
key
,
value
)
=
>
_fields
.
add
(
value
));
}
void
updateField
(
Map
fieldData
)
{
_data
[
_data
.
keys
.
elementAt
(
_activeTabIndex
)]
.
forEach
((
key
,
value
)
=
>
{
if
(
key
==
fieldData
.
keys
.
elementAt
(
0
))
{
setState
(()
{
_data
[
_data
.
keys
.
elementAt
(
_activeTabIndex
)][
key
]
=
fieldData
[
fieldData
.
keys
.
elementAt
(
0
)];
_fields
[
_activeTabIndex
]
=
_data
[
_data
.
keys
.
elementAt
(
_activeTabIndex
)];
})
}
});
}
void
_validateUser
()
async
{
bool
tokenExpired
=
await
Helper
.
isTokenExpired
();
if
(
tokenExpired
)
{
Helper
.
toastMessage
(
'Your session has expired.'
);
Navigator
.
of
(
context
)
.
pushReplacement
(
MaterialPageRoute
(
builder:
(
context
)
=
>
const
LoginEmailPage
(),
));
}
}
Future
<
void
>
_submitInspection
()
async
{
_validateUser
();
Map
data
=
{
'applicationId'
:
widget
.
applicationId
,
'dataObject'
:
_data
};
try
{
final
responseCode
=
await
Provider
.
of
<
ApplicationRespository
>(
context
,
listen:
false
)
.
submitInspection
(
data
);
if
(
responseCode
==
200
)
{
Navigator
.
of
(
context
)
.
pushReplacement
(
MaterialPageRoute
(
builder:
(
context
)
=
>
InspectionSummaryPage
(
inspectors:
widget
.
applicationInspectors
)));
}
else
{
_errorMessage
=
Provider
.
of
<
ApplicationRespository
>(
context
,
listen:
false
)
.
errorMessage
;
Helper
.
toastMessage
(
_errorMessage
);
}
}
catch
(
err
)
{
throw
Exception
(
err
);
}
}
@override
void
dispose
()
{
_tabController
?.
dispose
();
...
...
@@ -145,7 +214,8 @@ class _ApplicationDetailsPageState extends State<ApplicationDetailsPage>
itemBuilder:
(
context
,
i
)
{
return
ApplicationField
(
fieldName:
field
.
keys
.
elementAt
(
i
),
fieldValue:
field
[
field
.
keys
.
elementAt
(
i
)],
fieldData:
field
[
field
.
keys
.
elementAt
(
i
)],
parentAction:
updateField
,
);
})
]))))),
...
...
@@ -214,10 +284,7 @@ class _ApplicationDetailsPageState extends State<ApplicationDetailsPage>
))
:
TextButton
(
onPressed:
()
{
Navigator
.
of
(
context
)
.
pushReplacement
(
MaterialPageRoute
(
builder:
(
context
)
=
>
const
InspectionSummaryPage
()));
_submitInspection
();
},
style:
TextButton
.
styleFrom
(
// primary: Colors.white,
...
...
This diff is collapsed.
Click to expand it.
lib/pages/home_page.dart
+
26
−
17
View file @
ef0984a1
...
...
@@ -5,6 +5,7 @@ import 'package:provider/provider.dart';
import
'package:smf_mobile/constants/app_urls.dart'
;
import
'package:smf_mobile/constants/color_constants.dart'
;
import
'package:smf_mobile/models/application_model.dart'
;
import
'package:smf_mobile/pages/login_email_page.dart'
;
import
'package:smf_mobile/pages/past_applications.dart'
;
import
'package:smf_mobile/repositories/application_repository.dart'
;
import
'package:smf_mobile/util/helper.dart'
;
...
...
@@ -28,10 +29,20 @@ class _HomePageState extends State<HomePage> {
@override
void
initState
()
{
super
.
initState
();
_getApplications
(
context
);
}
void
_validateUser
()
async
{
bool
tokenExpired
=
await
Helper
.
isTokenExpired
();
if
(
tokenExpired
)
{
Helper
.
toastMessage
(
'Your session has expired.'
);
Navigator
.
of
(
context
)
.
pushReplacement
(
MaterialPageRoute
(
builder:
(
context
)
=
>
const
LoginEmailPage
(),
));
}
}
Future
<
dynamic
>
_getApplications
(
context
)
async
{
_validateUser
();
_allApplications
=
await
Provider
.
of
<
ApplicationRespository
>(
context
,
listen:
false
)
.
getApplications
();
...
...
@@ -42,26 +53,24 @@ class _HomePageState extends State<HomePage> {
_upcomingApplications
.
clear
();
_pastApplications
.
clear
();
if
(
_allApplications
.
isNotEmpty
)
{
List
temp
=
[];
for
(
Application
application
in
_allApplications
)
{
int
days
=
Helper
.
getDateDiffence
(
DateTime
.
now
(),
DateTime
.
parse
(
application
.
scheduledDate
));
if
(
days
==
0
)
{
_pendingApplications
.
add
(
application
);
}
else
if
(
days
>
0
)
{
_pastApplications
.
add
(
application
);
}
else
{
_upcomingApplications
.
add
(
application
);
if
(
application
.
scheduledDate
!=
''
)
{
temp
=
application
.
scheduledDate
.
split
(
"-"
);
temp
=
List
.
from
(
temp
.
reversed
);
int
days
=
Helper
.
getDateDiffence
(
DateTime
.
now
(),
DateTime
.
parse
(
temp
.
join
(
"-"
)));
if
(
days
==
0
)
{
_pendingApplications
.
add
(
application
);
}
else
if
(
days
>
0
)
{
_pastApplications
.
add
(
application
);
}
else
{
_upcomingApplications
.
add
(
application
);
}
}
}
}
else
if
(
_errorMessage
.
isNotEmpty
)
{
Fluttertoast
.
showToast
(
msg:
_errorMessage
,
toastLength:
Toast
.
LENGTH_SHORT
,
gravity:
ToastGravity
.
TOP
,
timeInSecForIosWeb:
2
,
backgroundColor:
Colors
.
red
,
textColor:
Colors
.
white
,
fontSize:
16.0
);
Helper
.
toastMessage
(
_errorMessage
);
}
return
_allApplications
;
}
...
...
This diff is collapsed.
Click to expand it.
lib/pages/inspection_summary.dart
+
113
−
16
View file @
ef0984a1
...
...
@@ -2,31 +2,47 @@ import 'package:flutter/material.dart';
import
'package:google_fonts/google_fonts.dart'
;
import
'package:smf_mobile/constants/app_urls.dart'
;
import
'package:smf_mobile/constants/color_constants.dart'
;
import
'package:smf_mobile/widgets/people_card.dart'
;
import
'package:smf_mobile/util/helper.dart'
;
import
'inspection_completed.dart'
;
// import 'dart:developer' as developer;
class
InspectionSummaryPage
extends
StatefulWidget
{
static
const
route
=
AppUrl
.
inspectionSummary
;
final
List
inspectors
;
const
InspectionSummaryPage
({
Key
?
key
})
:
super
(
key:
key
);
const
InspectionSummaryPage
({
Key
?
key
,
required
this
.
inspectors
})
:
super
(
key:
key
);
@override
_InspectionSummaryPageState
createState
()
=
>
_InspectionSummaryPageState
();
}
class
_InspectionSummaryPageState
extends
State
<
InspectionSummaryPage
>
{
final
List
<
String
>
_dropdownItems
=
[
'Select from the list'
,
'Somorjit Phuritshabam'
,
'Shoaib Muhammed'
];
String
_selectedItem
=
'Select from the list'
;
// final List<String> _dropdownItems = [
// 'Select from the list',
// 'Somorjit Phuritshabam',
// 'Shoaib Muhammed'
// ];
final
List
<
Map
>
_inspectors
=
[];
bool
_iAgree
=
false
;
@override
void
initState
()
{
super
.
initState
();
_populateInspectors
();
}
Future
<
void
>
_populateInspectors
()
async
{
String
userId
=
await
Helper
.
getUser
(
'id'
);
for
(
var
i
=
0
;
i
<
widget
.
inspectors
.
length
;
i
++
)
{
if
(
userId
!=
widget
.
inspectors
[
i
][
'id'
])
{
_inspectors
.
add
({
'name'
:
'
${widget.inspectors[i]['firstName']}
${widget.inspectors[i]['lastName']}
'
,
'designation'
:
'Inspector'
,
'isChecked'
:
false
});
}
}
}
@override
...
...
@@ -196,7 +212,88 @@ class _InspectionSummaryPageState extends State<InspectionSummaryPage> {
// ),
// ),
// ])),
for
(
int
i
=
0
;
i
<
3
;
i
++
)
const
PeopleCard
(),
for
(
int
i
=
0
;
i
<
_inspectors
.
length
;
i
++
)
Container
(
color:
Colors
.
white
,
// width: double.infinity,
margin:
const
EdgeInsets
.
only
(
left:
20
,
right:
20
,
bottom:
10.0
),
child:
Row
(
mainAxisAlignment:
MainAxisAlignment
.
spaceBetween
,
children:
[
Container
(
width:
MediaQuery
.
of
(
context
)
.
size
.
width
-
80
,
decoration:
BoxDecoration
(
color:
AppColors
.
black08
,
borderRadius:
BorderRadius
.
circular
(
4
),
// border: Border.all(color: AppColors.black08),
),
child:
Row
(
mainAxisAlignment:
MainAxisAlignment
.
start
,
children:
[
Padding
(
padding:
const
EdgeInsets
.
all
(
15.0
),
child:
Container
(
height:
48
,
width:
48
,
decoration:
const
BoxDecoration
(
color:
AppColors
.
primaryGreen
,
borderRadius:
BorderRadius
.
all
(
Radius
.
circular
(
4.0
)),
),
child:
Center
(
child:
Text
(
Helper
.
getInitials
(
_inspectors
[
i
][
'name'
]),
style:
GoogleFonts
.
lato
(
color:
Colors
.
white
)),
),
),
),
Row
(
mainAxisAlignment:
MainAxisAlignment
.
end
,
children:
[
Column
(
crossAxisAlignment:
CrossAxisAlignment
.
start
,
children:
[
Text
(
'
${_inspectors[i]['name']}
'
,
style:
GoogleFonts
.
lato
(
color:
AppColors
.
black87
,
fontSize:
14.0
,
fontWeight:
FontWeight
.
w700
),
),
Padding
(
padding:
const
EdgeInsets
.
only
(
top:
10.0
),
child:
Text
(
'
${_inspectors[i]['designation']}
'
,
style:
GoogleFonts
.
lato
(
color:
AppColors
.
black60
,
fontSize:
14.0
,
fontWeight:
FontWeight
.
w400
),
),
),
],
),
],
),
const
Spacer
(),
Checkbox
(
value:
_inspectors
[
i
][
'isChecked'
],
activeColor:
AppColors
.
primaryBlue
,
onChanged:
(
newValue
)
{
setState
(()
{
_inspectors
[
i
][
'isChecked'
]
=
newValue
!
;
});
}),
],
),
),
],
),
),
const
Divider
(),
Container
(
padding:
const
EdgeInsets
.
only
(
left:
10
,
bottom:
20
),
...
...
@@ -204,12 +301,12 @@ class _InspectionSummaryPageState extends State<InspectionSummaryPage> {
crossAxisAlignment:
CrossAxisAlignment
.
start
,
children:
<
Widget
>[
Checkbox
(
value:
tru
e
,
value:
_iAgre
e
,
activeColor:
AppColors
.
primaryBlue
,
onChanged:
(
newValue
)
{
//
setState(() {
// checkBoxValu
e = newValue;
//
});
),
setState
(()
{
_iAgre
e
=
newValue
!
;
});
}),
Container
(
padding:
const
EdgeInsets
.
only
(
top:
10
),
...
...
This diff is collapsed.
Click to expand it.
lib/pages/login_email_page.dart
+
3
−
17
View file @
ef0984a1
...
...
@@ -7,6 +7,7 @@ import 'package:google_fonts/google_fonts.dart';
import
'package:smf_mobile/pages/login_otp_page.dart'
;
import
'package:smf_mobile/repositories/login_repository.dart'
;
import
'package:fluttertoast/fluttertoast.dart'
;
import
'package:smf_mobile/util/helper.dart'
;
class
LoginEmailPage
extends
StatefulWidget
{
static
const
route
=
AppUrl
.
loginEmailPage
;
...
...
@@ -29,14 +30,7 @@ class _LoginEmailPageState extends State<LoginEmailPage> {
Future
<
void
>
_generateOtp
()
async
{
final
email
=
_emailController
.
text
;
if
(
email
==
''
)
{
Fluttertoast
.
showToast
(
msg:
'Please enter email.'
,
// toastLength: Toast.LENGTH_SHORT,
gravity:
ToastGravity
.
CENTER
,
timeInSecForIosWeb:
2
,
backgroundColor:
Colors
.
red
,
textColor:
Colors
.
white
,
fontSize:
16.0
);
Helper
.
toastMessage
(
'Please enter email.'
);
return
;
}
SystemChannels
.
textInput
.
invokeMethod
(
'TextInput.hide'
);
...
...
@@ -51,15 +45,7 @@ class _LoginEmailPageState extends State<LoginEmailPage> {
}
else
{
_errorMessage
=
Provider
.
of
<
LoginRespository
>(
context
,
listen:
false
)
.
errorMessage
;
Fluttertoast
.
showToast
(
msg:
_errorMessage
,
toastLength:
Toast
.
LENGTH_SHORT
,
gravity:
ToastGravity
.
TOP
,
timeInSecForIosWeb:
2
,
backgroundColor:
Colors
.
red
,
textColor:
Colors
.
white
,
fontSize:
16.0
);
// print(_errorMessage);
Helper
.
toastMessage
(
_errorMessage
);
}
}
catch
(
err
)
{
throw
Exception
(
err
);
...
...
This diff is collapsed.
Click to expand it.
lib/pages/login_otp_page.dart
+
2
−
21
View file @
ef0984a1
...
...
@@ -9,6 +9,7 @@ import 'package:otp_text_field/otp_field.dart';
import
'package:otp_text_field/style.dart'
;
import
'package:smf_mobile/repositories/login_repository.dart'
;
import
'package:fluttertoast/fluttertoast.dart'
;
import
'package:smf_mobile/util/helper.dart'
;
class
LoginOtpPage
extends
StatefulWidget
{
static
const
route
=
AppUrl
.
loginOtpPage
;
...
...
@@ -30,18 +31,6 @@ class _LoginOtpPageState extends State<LoginOtpPage> {
Future
<
void
>
_validateOtp
()
async
{
String
otp
=
_otp
;
// if (otp.length != 6) {
// Fluttertoast.showToast(
// msg: 'Please enter 6 digits.',
// // toastLength: Toast.LENGTH_SHORT,
// gravity: ToastGravity.CENTER,
// timeInSecForIosWeb: 2,
// backgroundColor: Colors.red,
// textColor: Colors.white,
// fontSize: 16.0);
// return;
// }
try
{
final
responseCode
=
await
Provider
.
of
<
LoginRespository
>(
context
,
listen:
false
)
...
...
@@ -53,15 +42,7 @@ class _LoginOtpPageState extends State<LoginOtpPage> {
}
else
{
_errorMessage
=
Provider
.
of
<
LoginRespository
>(
context
,
listen:
false
)
.
errorMessage
;
Fluttertoast
.
showToast
(
msg:
_errorMessage
,
toastLength:
Toast
.
LENGTH_SHORT
,
gravity:
ToastGravity
.
TOP
,
timeInSecForIosWeb:
2
,
backgroundColor:
Colors
.
red
,
textColor:
Colors
.
white
,
fontSize:
16.0
);
// print(_errorMessage);
Helper
.
toastMessage
(
_errorMessage
);
}
}
catch
(
err
)
{
throw
Exception
(
err
);
...
...
This diff is collapsed.
Click to expand it.
lib/repositories/application_repository.dart
+
15
−
0
View file @
ef0984a1
...
...
@@ -26,5 +26,20 @@ class ApplicationRespository with ChangeNotifier {
return
_applications
;
}
Future
<
dynamic
>
submitInspection
(
Map
data
)
async
{
try
{
final
request
=
await
ApplicationService
.
submitInspection
(
data
);
_data
=
json
.
decode
(
request
.
body
);
print
(
_data
);
}
catch
(
_
)
{
return
_
;
}
if
(
_data
[
'statusInfo'
][
'statusCode'
]
!=
200
)
{
_errorMessage
=
_data
[
'statusInfo'
][
'errorMessage'
];
}
return
_data
[
'statusInfo'
][
'statusCode'
];
}
String
get
errorMessage
=
>
_errorMessage
;
}
This diff is collapsed.
Click to expand it.
lib/services/application_service.dart
+
15
−
8
View file @
ef0984a1
...
...
@@ -3,8 +3,8 @@ import 'dart:io';
import
'package:http/http.dart'
as
http
;
import
'package:smf_mobile/constants/api_endpoints.dart'
;
import
'package:smf_mobile/services/base_service.dart'
;
import
'package:
flutter_secure_storage/flutter_secure_storage
.dart'
;
//
import 'dart:developer' as developer;
import
'package:
smf_mobile/util/helper
.dart'
;
import
'dart:developer'
as
developer
;
class
ApplicationService
extends
BaseService
{
ApplicationService
(
HttpClient
client
)
:
super
(
client
);
...
...
@@ -12,13 +12,20 @@ class ApplicationService extends BaseService {
static
Future
<
dynamic
>
getApplications
()
async
{
Map
requestData
=
{
'searchObjects'
:
[]};
var
body
=
json
.
encode
(
requestData
);
Map
<
String
,
String
>
headers
=
BaseService
.
defaultHeaders
;
const
_storage
=
FlutterSecureStorage
();
var
authToken
=
await
_storage
.
read
(
key:
'authToken'
);
headers
[
'Authorization'
]
=
'
$authToken
'
;
Map
<
String
,
String
>
headers
=
await
Helper
.
getHeaders
();
final
response
=
await
http
.
post
(
Uri
.
parse
(
ApiUrl
.
getAllApplications
),
headers:
BaseService
.
defaultHeaders
,
body:
body
);
// developer.log('$authToken');
headers:
headers
,
body:
body
);
// developer.log(response.body);
return
response
;
}
static
Future
<
dynamic
>
submitInspection
(
Map
data
)
async
{
var
body
=
json
.
encode
(
data
);
Map
<
String
,
String
>
headers
=
await
Helper
.
getHeaders
();
// developer.log(ApiUrl.submitInspection);
final
response
=
await
http
.
post
(
Uri
.
parse
(
ApiUrl
.
submitInspection
),
headers:
headers
,
body:
body
);
return
response
;
}
}
This diff is collapsed.
Click to expand it.
lib/services/base_service.dart
+
0
−
4
View file @
ef0984a1
...
...
@@ -2,9 +2,5 @@ import 'dart:io';
abstract
class
BaseService
{
final
HttpClient
client
;
static
Map
<
String
,
String
>
defaultHeaders
=
{
'Accept'
:
'application/json'
,
'Content-Type'
:
'application/json; charset=utf-8'
,
};
const
BaseService
(
this
.
client
);
}
This diff is collapsed.
Click to expand it.
lib/services/login_service.dart
+
6
−
3
View file @
ef0984a1
...
...
@@ -3,6 +3,7 @@ import 'dart:io';
import
'package:http/http.dart'
as
http
;
import
'package:smf_mobile/constants/api_endpoints.dart'
;
import
'package:smf_mobile/services/base_service.dart'
;
import
'package:smf_mobile/util/helper.dart'
;
// import 'dart:developer' as developer;
class
LoginService
extends
BaseService
{
...
...
@@ -13,16 +14,18 @@ class LoginService extends BaseService {
'username'
:
username
,
};
var
body
=
json
.
encode
(
requestData
);
final
response
=
await
http
.
post
(
Uri
.
parse
(
ApiUrl
.
getOtp
),
headers:
BaseService
.
defaultHeaders
,
body:
body
);
Map
<
String
,
String
>
headers
=
await
Helper
.
getHeaders
();
final
response
=
await
http
.
post
(
Uri
.
parse
(
ApiUrl
.
getOtp
),
headers:
headers
,
body:
body
);
return
response
;
}
static
Future
<
dynamic
>
validateOtp
(
String
username
,
String
otp
)
async
{
Map
requestData
=
{
'username'
:
username
,
'otp'
:
otp
};
var
body
=
json
.
encode
(
requestData
);
Map
<
String
,
String
>
headers
=
await
Helper
.
getHeaders
();
final
response
=
await
http
.
post
(
Uri
.
parse
(
ApiUrl
.
validateOtp
),
headers:
BaseService
.
defaultH
eaders
,
body:
body
);
headers:
h
eaders
,
body:
body
);
return
response
;
}
}
This diff is collapsed.
Click to expand it.
lib/util/helper.dart
+
37
−
2
View file @
ef0984a1
import
'package:flutter/material.dart'
;
import
'package:fluttertoast/fluttertoast.dart'
;
import
'package:jwt_decoder/jwt_decoder.dart'
;
import
'package:flutter_secure_storage/flutter_secure_storage.dart'
;
const
_storage
=
FlutterSecureStorage
();
class
Helper
{
static
String
getInitials
(
String
name
)
{
...
...
@@ -13,6 +18,11 @@ class Helper {
return
shortCode
;
}
static
Future
<
dynamic
>
getUser
(
String
key
)
async
{
var
value
=
await
_storage
.
read
(
key:
key
);
return
value
;
}
static
int
getDateDiffence
(
DateTime
today
,
DateTime
dateTimeCreatedAt
)
{
String
month
=
today
.
month
<
10
?
'0
${today.month}
'
:
'
${today.month}
'
;
DateTime
dateTimeNow
=
DateTime
.
parse
(
'
${today.year}
-
$month
-
${today.day}
'
);
...
...
@@ -20,8 +30,33 @@ class Helper {
return
differenceInDays
;
}
static
bool
isTokenExpired
(
String
token
)
{
bool
isTokenExpired
=
JwtDecoder
.
isExpired
(
token
);
static
Future
<
bool
>
isTokenExpired
()
async
{
bool
isTokenExpired
=
true
;
var
authToken
=
await
_storage
.
read
(
key:
'authToken'
);
isTokenExpired
=
JwtDecoder
.
isExpired
(
authToken
!
);
return
isTokenExpired
;
}
static
Future
<
Map
<
String
,
String
>>
getHeaders
()
async
{
Map
<
String
,
String
>
headers
=
{
'Accept'
:
'application/json'
,
'Content-Type'
:
'application/json; charset=utf-8'
,
};
var
authToken
=
await
_storage
.
read
(
key:
'authToken'
);
if
(
authToken
!=
''
&&
authToken
!=
null
)
{
headers
[
'Authorization'
]
=
authToken
;
}
return
headers
;
}
static
toastMessage
(
String
message
)
{
Fluttertoast
.
showToast
(
msg:
message
,
toastLength:
Toast
.
LENGTH_SHORT
,
gravity:
ToastGravity
.
TOP
,
timeInSecForIosWeb:
2
,
backgroundColor:
Colors
.
red
,
textColor:
Colors
.
white
,
fontSize:
16.0
);
}
}
This diff is collapsed.
Click to expand it.
lib/widgets/application_card.dart
+
2
−
0
View file @
ef0984a1
...
...
@@ -28,8 +28,10 @@ class _ApplicationCardState extends State<ApplicationCard> {
context
,
MaterialPageRoute
(
builder:
(
context
)
=
>
ApplicationDetailsPage
(
applicationId:
widget
.
application
.
applicationId
,
applicationTitle:
widget
.
application
.
title
,
applicationFields:
widget
.
application
.
dataObject
,
applicationInspectors:
widget
.
application
.
inspectors
,
)),
),
child:
Container
(
...
...
This diff is collapsed.
Click to expand it.
lib/widgets/application_field.dart
+
93
−
55
View file @
ef0984a1
...
...
@@ -5,24 +5,43 @@ import 'package:smf_mobile/constants/color_constants.dart';
class
ApplicationField
extends
StatefulWidget
{
final
String
fieldName
;
final
String
fieldValue
;
final
Map
fieldData
;
final
ValueChanged
<
Map
>
parentAction
;
const
ApplicationField
({
Key
?
key
,
required
this
.
fieldName
,
required
this
.
fieldValue
,
required
this
.
fieldData
,
required
this
.
parentAction
,
})
:
super
(
key:
key
);
@override
_ApplicationFieldState
createState
()
=
>
_ApplicationFieldState
();
}
class
_ApplicationFieldState
extends
State
<
ApplicationField
>
{
String
_radioValue
=
'Correct'
;
late
Map
_data
;
late
String
_radioValue
;
final
List
<
String
>
_options
=
[
'Correct'
,
'Incorrect'
];
final
TextEditingController
_noteController
=
TextEditingController
();
@override
void
initState
()
{
super
.
initState
();
_data
=
widget
.
fieldData
[
widget
.
fieldData
.
keys
.
elementAt
(
0
)];
_radioValue
=
_data
[
_data
.
keys
.
elementAt
(
0
)];
_noteController
.
text
=
_data
[
_data
.
keys
.
elementAt
(
1
)];
}
_triggerUpdate
()
{
Map
data
=
{
widget
.
fieldName
:
{
widget
.
fieldData
.
keys
.
elementAt
(
0
)
:
{
'value'
:
_radioValue
,
'comments'
:
_noteController
.
text
}
}
};
// print(data);
widget
.
parentAction
(
data
);
}
Future
_displayCommentDialog
()
{
...
...
@@ -32,15 +51,16 @@ class _ApplicationFieldState extends State<ApplicationField> {
return
Stack
(
children:
[
Align
(
alignment:
FractionalOffset
.
topCenter
,
child:
Container
(
alignment:
FractionalOffset
.
topCenter
,
child:
Container
(
margin:
const
EdgeInsets
.
only
(
top:
150
),
decoration:
BoxDecoration
(
color:
Colors
.
white
,
borderRadius:
BorderRadius
.
circular
(
4
)),
height:
285
,
width:
MediaQuery
.
of
(
context
)
.
size
.
width
-
40
,
child:
Padding
(
child:
Material
(
child:
Padding
(
padding:
const
EdgeInsets
.
all
(
20
),
child:
Column
(
crossAxisAlignment:
CrossAxisAlignment
.
start
,
...
...
@@ -128,6 +148,7 @@ class _ApplicationFieldState extends State<ApplicationField> {
child:
TextButton
(
onPressed:
()
{
Navigator
.
of
(
context
)
.
pop
(
false
);
_triggerUpdate
();
},
style:
TextButton
.
styleFrom
(
// primary: Colors.white,
...
...
@@ -156,7 +177,7 @@ class _ApplicationFieldState extends State<ApplicationField> {
],
),
)),
),
)
),
],
);
}));
...
...
@@ -164,7 +185,10 @@ class _ApplicationFieldState extends State<ApplicationField> {
@override
Widget
build
(
BuildContext
context
)
{
// print(widget.field);
// if (_data != widget.fieldData[widget.fieldData.keys.elementAt(0)]) {
// _radioValue = _data[_data.keys.elementAt(0)];
// _noteController.text = _data[_data.keys.elementAt(1)];
// }
return
SingleChildScrollView
(
reverse:
true
,
child:
Container
(
...
...
@@ -212,7 +236,7 @@ class _ApplicationFieldState extends State<ApplicationField> {
border:
Border
.
all
(
color:
AppColors
.
black16
),
),
child:
Text
(
widget
.
field
Value
,
widget
.
field
Data
.
keys
.
elementAt
(
0
)
,
style:
GoogleFonts
.
lato
(
color:
AppColors
.
black87
,
fontSize:
14.0
,
...
...
@@ -231,7 +255,7 @@ class _ApplicationFieldState extends State<ApplicationField> {
borderRadius:
BorderRadius
.
only
(
bottomLeft:
Radius
.
circular
(
4
),
bottomRight:
Radius
.
circular
(
4
)),
color:
AppColors
.
scaffo
ldBackground
,
color:
AppColors
.
fie
ldBackground
,
boxShadow:
[
BoxShadow
(
color:
AppColors
.
black16
,
...
...
@@ -263,54 +287,68 @@ class _ApplicationFieldState extends State<ApplicationField> {
// alignment: MainAxisAlignment.start,
children:
<
Widget
>[
for
(
int
i
=
0
;
i
<
_options
.
length
;
i
++
)
Container
(
padding:
const
EdgeInsets
.
only
(
right:
15
),
margin:
const
EdgeInsets
.
only
(
right:
15
),
decoration:
BoxDecoration
(
color:
_radioValue
==
_options
[
i
]
?
AppColors
.
radioSelected
:
Colors
.
transparent
,
borderRadius:
const
BorderRadius
.
all
(
Radius
.
circular
(
4.0
)),
border:
Border
.
all
(
color:
_radioValue
==
_options
[
i
]
InkWell
(
onTap:
()
{
setState
(()
{
_radioValue
=
_options
[
i
];
});
if
(
_options
[
i
]
==
'Incorrect'
)
{
_displayCommentDialog
();
}
_triggerUpdate
();
},
child:
Container
(
padding:
const
EdgeInsets
.
only
(
right:
15
),
margin:
const
EdgeInsets
.
only
(
right:
15
),
decoration:
BoxDecoration
(
color:
_radioValue
==
_options
[
i
]
?
AppColors
.
radioSelected
:
Colors
.
transparent
,
borderRadius:
const
BorderRadius
.
all
(
Radius
.
circular
(
4.0
)),
border:
Border
.
all
(
color:
_radioValue
==
_options
[
i
]
?
AppColors
.
primaryBlue
:
AppColors
.
black16
,
),
),
child:
Row
(
children:
[
Radio
(
value:
_options
[
i
],
groupValue:
_radioValue
,
activeColor:
AppColors
.
primaryBlue
,
materialTapTargetSize:
MaterialTapTargetSize
.
shrinkWrap
,
onChanged:
(
val
)
{
setState
(()
{
_radioValue
=
_options
[
i
];
});
if
(
_options
[
i
]
==
'Incorrect'
)
{
_displayCommentDialog
();
}
},
),
Text
(
_options
[
i
],
style:
GoogleFonts
.
lato
(
color:
AppColors
.
black87
,
fontWeight:
FontWeight
.
w400
,
fontSize:
14.0
,
letterSpacing:
0.25
,
),
),
),
])),
child:
Row
(
children:
[
Radio
(
value:
_options
[
i
],
groupValue:
_radioValue
,
activeColor:
AppColors
.
primaryBlue
,
materialTapTargetSize:
MaterialTapTargetSize
.
shrinkWrap
,
onChanged:
(
val
)
{
setState
(()
{
_radioValue
=
_options
[
i
];
});
_triggerUpdate
();
if
(
_options
[
i
]
==
'Incorrect'
)
{
_displayCommentDialog
();
}
},
),
Text
(
_options
[
i
],
style:
GoogleFonts
.
lato
(
color:
AppColors
.
black87
,
fontWeight:
FontWeight
.
w400
,
fontSize:
14.0
,
letterSpacing:
0.25
,
),
),
]))),
const
Spacer
(),
Padding
(
padding:
const
EdgeInsets
.
only
(
left:
0
),
...
...
This diff is collapsed.
Click to expand it.
lib/widgets/people_card.dart
deleted
100644 → 0
+
0
−
76
View file @
3261673b
import
'package:flutter/material.dart'
;
import
'package:google_fonts/google_fonts.dart'
;
import
'package:smf_mobile/constants/color_constants.dart'
;
class
PeopleCard
extends
StatelessWidget
{
const
PeopleCard
({
Key
?
key
})
:
super
(
key:
key
);
@override
Widget
build
(
BuildContext
context
)
{
return
Container
(
color:
Colors
.
white
,
// width: double.infinity,
margin:
const
EdgeInsets
.
only
(
left:
20
,
right:
20
,
bottom:
10.0
),
child:
Row
(
mainAxisAlignment:
MainAxisAlignment
.
spaceBetween
,
children:
[
Container
(
width:
MediaQuery
.
of
(
context
)
.
size
.
width
-
80
,
decoration:
BoxDecoration
(
color:
AppColors
.
black08
,
borderRadius:
BorderRadius
.
circular
(
4
),
// border: Border.all(color: AppColors.black08),
),
child:
Row
(
mainAxisAlignment:
MainAxisAlignment
.
start
,
children:
[
Padding
(
padding:
const
EdgeInsets
.
all
(
15.0
),
child:
Container
(
height:
48
,
width:
48
,
decoration:
const
BoxDecoration
(
color:
AppColors
.
primaryGreen
,
borderRadius:
BorderRadius
.
all
(
Radius
.
circular
(
4.0
)),
),
child:
Center
(
child:
Text
(
'SM'
,
style:
GoogleFonts
.
lato
(
color:
Colors
.
white
)),
),
),
),
Row
(
mainAxisAlignment:
MainAxisAlignment
.
end
,
children:
[
Column
(
crossAxisAlignment:
CrossAxisAlignment
.
start
,
children:
[
Text
(
'Shoaib Muhammed'
,
style:
GoogleFonts
.
lato
(
color:
AppColors
.
black87
,
fontSize:
14.0
,
fontWeight:
FontWeight
.
w700
),
),
Padding
(
padding:
const
EdgeInsets
.
only
(
top:
10.0
),
child:
Text
(
'Designation'
,
style:
GoogleFonts
.
lato
(
color:
AppColors
.
black60
,
fontSize:
14.0
,
fontWeight:
FontWeight
.
w400
),
),
),
],
),
],
),
],
),
),
],
),
);
}
}
This diff is collapsed.
Click to expand it.
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment
Menu
Explore
Projects
Groups
Topics
Snippets