feedback Service done
parent
29768feefd
commit
cfd5b2ccff
@ -0,0 +1,120 @@
|
||||
class COCItem {
|
||||
Null appointment;
|
||||
String appointmentClinicName;
|
||||
String appointmentDate;
|
||||
String appointmentProjectName;
|
||||
String cOCID;
|
||||
String cOCTitle;
|
||||
String channel;
|
||||
dynamic clinic;
|
||||
String clinicID;
|
||||
String date;
|
||||
dynamic detail;
|
||||
dynamic doctor;
|
||||
String doctorID;
|
||||
String formType;
|
||||
int formTypeID;
|
||||
dynamic identificationNo;
|
||||
int itemID;
|
||||
dynamic mobileNo;
|
||||
dynamic naturename;
|
||||
dynamic patientID;
|
||||
dynamic patientName;
|
||||
dynamic project;
|
||||
dynamic projectID;
|
||||
String solution;
|
||||
String status;
|
||||
String statusAr;
|
||||
dynamic statusEn;
|
||||
|
||||
COCItem(
|
||||
{this.appointment,
|
||||
this.appointmentClinicName,
|
||||
this.appointmentDate,
|
||||
this.appointmentProjectName,
|
||||
this.cOCID,
|
||||
this.cOCTitle,
|
||||
this.channel,
|
||||
this.clinic,
|
||||
this.clinicID,
|
||||
this.date,
|
||||
this.detail,
|
||||
this.doctor,
|
||||
this.doctorID,
|
||||
this.formType,
|
||||
this.formTypeID,
|
||||
this.identificationNo,
|
||||
this.itemID,
|
||||
this.mobileNo,
|
||||
this.naturename,
|
||||
this.patientID,
|
||||
this.patientName,
|
||||
this.project,
|
||||
this.projectID,
|
||||
this.solution,
|
||||
this.status,
|
||||
this.statusAr,
|
||||
this.statusEn});
|
||||
|
||||
COCItem.fromJson(Map<String, dynamic> json) {
|
||||
appointment = json['Appointment'];
|
||||
appointmentClinicName = json['AppointmentClinicName'];
|
||||
appointmentDate = json['AppointmentDate'];
|
||||
appointmentProjectName = json['AppointmentProjectName'];
|
||||
cOCID = json['COCID'];
|
||||
cOCTitle = json['COCTitle'];
|
||||
channel = json['Channel'];
|
||||
clinic = json['Clinic'];
|
||||
clinicID = json['ClinicID'];
|
||||
date = json['Date'];
|
||||
detail = json['Detail'];
|
||||
doctor = json['Doctor'];
|
||||
doctorID = json['DoctorID'];
|
||||
formType = json['FormType'];
|
||||
formTypeID = json['FormTypeID'];
|
||||
identificationNo = json['IdentificationNo'];
|
||||
itemID = json['ItemID'];
|
||||
mobileNo = json['MobileNo'];
|
||||
naturename = json['Naturename'];
|
||||
patientID = json['PatientID'];
|
||||
patientName = json['PatientName'];
|
||||
project = json['Project'];
|
||||
projectID = json['ProjectID'];
|
||||
solution = json['Solution'];
|
||||
status = json['Status'];
|
||||
statusAr = json['StatusAr'];
|
||||
statusEn = json['StatusEn'];
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
final Map<String, dynamic> data = new Map<String, dynamic>();
|
||||
data['Appointment'] = this.appointment;
|
||||
data['AppointmentClinicName'] = this.appointmentClinicName;
|
||||
data['AppointmentDate'] = this.appointmentDate;
|
||||
data['AppointmentProjectName'] = this.appointmentProjectName;
|
||||
data['COCID'] = this.cOCID;
|
||||
data['COCTitle'] = this.cOCTitle;
|
||||
data['Channel'] = this.channel;
|
||||
data['Clinic'] = this.clinic;
|
||||
data['ClinicID'] = this.clinicID;
|
||||
data['Date'] = this.date;
|
||||
data['Detail'] = this.detail;
|
||||
data['Doctor'] = this.doctor;
|
||||
data['DoctorID'] = this.doctorID;
|
||||
data['FormType'] = this.formType;
|
||||
data['FormTypeID'] = this.formTypeID;
|
||||
data['IdentificationNo'] = this.identificationNo;
|
||||
data['ItemID'] = this.itemID;
|
||||
data['MobileNo'] = this.mobileNo;
|
||||
data['Naturename'] = this.naturename;
|
||||
data['PatientID'] = this.patientID;
|
||||
data['PatientName'] = this.patientName;
|
||||
data['Project'] = this.project;
|
||||
data['ProjectID'] = this.projectID;
|
||||
data['Solution'] = this.solution;
|
||||
data['Status'] = this.status;
|
||||
data['StatusAr'] = this.statusAr;
|
||||
data['StatusEn'] = this.statusEn;
|
||||
return data;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,132 @@
|
||||
class RequestInsertCOCItem {
|
||||
bool isUserLoggedIn;
|
||||
String mobileNo;
|
||||
int identificationNo;
|
||||
int patientID;
|
||||
int patientOutSA;
|
||||
int patientTypeID;
|
||||
String tokenID;
|
||||
String patientName;
|
||||
int projectID;
|
||||
String fileName;
|
||||
String attachment;
|
||||
String uILanguage;
|
||||
String browserInfo;
|
||||
String cOCTypeName;
|
||||
String formTypeID;
|
||||
String details;
|
||||
String deviceInfo;
|
||||
String deviceType;
|
||||
String title;
|
||||
String resolution;
|
||||
double versionID;
|
||||
int channel;
|
||||
int languageID;
|
||||
String iPAdress;
|
||||
String generalid;
|
||||
String sessionID;
|
||||
bool isDentalAllowedBackend;
|
||||
int deviceTypeID;
|
||||
int patientType;
|
||||
double appVersion;
|
||||
|
||||
RequestInsertCOCItem(
|
||||
{this.isUserLoggedIn,
|
||||
this.mobileNo,
|
||||
this.identificationNo,
|
||||
this.patientID,
|
||||
this.patientOutSA,
|
||||
this.patientTypeID,
|
||||
this.tokenID,
|
||||
this.patientName,
|
||||
this.projectID,
|
||||
this.fileName,
|
||||
this.attachment,
|
||||
this.uILanguage,
|
||||
this.browserInfo,
|
||||
this.cOCTypeName,
|
||||
this.formTypeID,
|
||||
this.details,
|
||||
this.deviceInfo,
|
||||
this.deviceType,
|
||||
this.title,
|
||||
this.resolution,
|
||||
this.versionID,
|
||||
this.channel,
|
||||
this.languageID,
|
||||
this.iPAdress,
|
||||
this.generalid,
|
||||
this.sessionID,
|
||||
this.isDentalAllowedBackend,
|
||||
this.deviceTypeID,
|
||||
this.patientType,
|
||||
this.appVersion});
|
||||
|
||||
RequestInsertCOCItem.fromJson(Map<String, dynamic> json) {
|
||||
isUserLoggedIn = json['IsUserLoggedIn'];
|
||||
mobileNo = json['MobileNo'];
|
||||
identificationNo = json['IdentificationNo'];
|
||||
patientID = json['PatientID'];
|
||||
patientOutSA = json['PatientOutSA'];
|
||||
patientTypeID = json['PatientTypeID'];
|
||||
tokenID = json['TokenID'];
|
||||
patientName = json['PatientName'];
|
||||
projectID = json['ProjectID'];
|
||||
fileName = json['FileName'];
|
||||
attachment = json['Attachment'];
|
||||
uILanguage = json['UILanguage'];
|
||||
browserInfo = json['BrowserInfo'];
|
||||
cOCTypeName = json['COCTypeName'];
|
||||
formTypeID = json['FormTypeID'];
|
||||
details = json['Details'];
|
||||
deviceInfo = json['DeviceInfo'];
|
||||
deviceType = json['DeviceType'];
|
||||
title = json['Title'];
|
||||
resolution = json['Resolution'];
|
||||
versionID = json['VersionID'];
|
||||
channel = json['Channel'];
|
||||
languageID = json['LanguageID'];
|
||||
iPAdress = json['IPAdress'];
|
||||
generalid = json['generalid'];
|
||||
sessionID = json['SessionID'];
|
||||
isDentalAllowedBackend = json['isDentalAllowedBackend'];
|
||||
deviceTypeID = json['DeviceTypeID'];
|
||||
patientType = json['PatientType'];
|
||||
appVersion = json['AppVersion'];
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
final Map<String, dynamic> data = new Map<String, dynamic>();
|
||||
data['IsUserLoggedIn'] = this.isUserLoggedIn;
|
||||
data['MobileNo'] = this.mobileNo;
|
||||
data['IdentificationNo'] = this.identificationNo;
|
||||
data['PatientID'] = this.patientID;
|
||||
data['PatientOutSA'] = this.patientOutSA;
|
||||
data['PatientTypeID'] = this.patientTypeID;
|
||||
data['TokenID'] = this.tokenID;
|
||||
data['PatientName'] = this.patientName;
|
||||
data['ProjectID'] = this.projectID;
|
||||
data['FileName'] = this.fileName;
|
||||
data['Attachment'] = this.attachment;
|
||||
data['UILanguage'] = this.uILanguage;
|
||||
data['BrowserInfo'] = this.browserInfo;
|
||||
data['COCTypeName'] = this.cOCTypeName;
|
||||
data['FormTypeID'] = this.formTypeID;
|
||||
data['Details'] = this.details;
|
||||
data['DeviceInfo'] = this.deviceInfo;
|
||||
data['DeviceType'] = this.deviceType;
|
||||
data['Title'] = this.title;
|
||||
data['Resolution'] = this.resolution;
|
||||
data['VersionID'] = this.versionID;
|
||||
data['Channel'] = this.channel;
|
||||
data['LanguageID'] = this.languageID;
|
||||
data['IPAdress'] = this.iPAdress;
|
||||
data['generalid'] = this.generalid;
|
||||
data['SessionID'] = this.sessionID;
|
||||
data['isDentalAllowedBackend'] = this.isDentalAllowedBackend;
|
||||
data['DeviceTypeID'] = this.deviceTypeID;
|
||||
data['PatientType'] = this.patientType;
|
||||
data['AppVersion'] = this.appVersion;
|
||||
return data;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,65 @@
|
||||
import 'dart:io';
|
||||
|
||||
import 'package:diplomaticquarterapp/config/config.dart';
|
||||
import 'package:diplomaticquarterapp/core/model/feedback/COC_items.dart';
|
||||
import 'package:diplomaticquarterapp/core/model/feedback/request_insert_coc_item.dart';
|
||||
import 'package:diplomaticquarterapp/core/service/base_service.dart';
|
||||
|
||||
class FeedbackService extends BaseService {
|
||||
List<COCItem> cOCItemList = List();
|
||||
RequestInsertCOCItem _requestInsertCOCItem = RequestInsertCOCItem();
|
||||
|
||||
Future sendCOCItem(
|
||||
{String title,
|
||||
String details,
|
||||
String cOCTypeName,
|
||||
String attachment}) async {
|
||||
hasError = false;
|
||||
|
||||
_requestInsertCOCItem.attachment = attachment;
|
||||
_requestInsertCOCItem.title = title;
|
||||
_requestInsertCOCItem.details = details;
|
||||
_requestInsertCOCItem.cOCTypeName = cOCTypeName;
|
||||
_requestInsertCOCItem.formTypeID = cOCTypeName;
|
||||
_requestInsertCOCItem.mobileNo =
|
||||
"966537503378"; //TODO Change it to be dynamic
|
||||
_requestInsertCOCItem.isUserLoggedIn = true;
|
||||
_requestInsertCOCItem.projectID = 1231755;
|
||||
_requestInsertCOCItem.patientName = "TAMER FANASHEH";
|
||||
_requestInsertCOCItem.fileName = "";
|
||||
_requestInsertCOCItem.uILanguage = "ar"; //TODO Change it to be dynamic
|
||||
_requestInsertCOCItem.browserInfo = Platform.localHostname;
|
||||
_requestInsertCOCItem.deviceInfo = Platform.localHostname;
|
||||
_requestInsertCOCItem.resolution = "400x847";
|
||||
_requestInsertCOCItem.projectID = 0;
|
||||
_requestInsertCOCItem.identificationNo = 2344670985;
|
||||
|
||||
await baseAppClient
|
||||
.post(SEND_FEEDBACK, onSuccess: (dynamic response, int statusCode) {
|
||||
var asd = "";
|
||||
},
|
||||
onFailure: (String error, int statusCode) {
|
||||
hasError = true;
|
||||
super.error = error;
|
||||
}, body: _requestInsertCOCItem.toJson());
|
||||
}
|
||||
|
||||
Future getStatusCOC() async {
|
||||
hasError = false;
|
||||
Map<String, dynamic> body = new Map<String, dynamic>();
|
||||
body['IdentificationNo'] = '2344670985';
|
||||
body['MobileNo'] = '966537503378';
|
||||
body['Searching_type'] = '1';
|
||||
|
||||
await baseAppClient.post(GET_STATUS_FOR_COCO,
|
||||
onSuccess: (dynamic response, int statusCode) {
|
||||
cOCItemList = [];
|
||||
response['ListCOCItems'].forEach((cOC) {
|
||||
cOCItemList.add(COCItem.fromJson(cOC));
|
||||
});
|
||||
}, onFailure: (String error, int statusCode) {
|
||||
hasError = true;
|
||||
super.error = error;
|
||||
}, body: body);
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,46 @@
|
||||
import 'package:diplomaticquarterapp/core/enum/viewstate.dart';
|
||||
import 'package:diplomaticquarterapp/core/model/feedback/COC_items.dart';
|
||||
import 'package:diplomaticquarterapp/core/service/feedback/feedback_service.dart';
|
||||
import 'package:diplomaticquarterapp/core/viewModels/base_view_model.dart';
|
||||
|
||||
import '../../../locator.dart';
|
||||
|
||||
class FeedbackViewModel extends BaseViewModel {
|
||||
FeedbackService _feedbackService = locator<FeedbackService>();
|
||||
|
||||
List<COCItem> get cOCItemList => _feedbackService.cOCItemList;
|
||||
|
||||
Future<bool> sendCOCItem(
|
||||
{String title,
|
||||
String details,
|
||||
String cOCTypeName,
|
||||
String attachment}) async {
|
||||
setState(ViewState.BusyLocal);
|
||||
await _feedbackService.sendCOCItem(
|
||||
title: title,
|
||||
details: details,
|
||||
cOCTypeName: cOCTypeName,
|
||||
attachment: attachment);
|
||||
if (_feedbackService.hasError) {
|
||||
error = _feedbackService.error;
|
||||
setState(ViewState.ErrorLocal);
|
||||
return false;
|
||||
} else {
|
||||
getCOC();
|
||||
setState(ViewState.Idle);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
getCOC({bool call = true}) async {
|
||||
setState(ViewState.Busy);
|
||||
await _feedbackService.getStatusCOC();
|
||||
if (_feedbackService.hasError) {
|
||||
error = _feedbackService.error;
|
||||
setState(ViewState.Error);
|
||||
} else {
|
||||
setState(ViewState.Idle);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,98 @@
|
||||
import 'package:diplomaticquarterapp/core/enum/viewstate.dart';
|
||||
import 'package:diplomaticquarterapp/core/viewModels/feedback/feedback_view_model.dart';
|
||||
import 'package:diplomaticquarterapp/pages/base/base_view.dart';
|
||||
import 'package:diplomaticquarterapp/widgets/buttons/button.dart';
|
||||
import 'package:diplomaticquarterapp/widgets/data_display/text.dart';
|
||||
import 'package:diplomaticquarterapp/widgets/others/app_scaffold_widget.dart';
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
class StatusFeedbackPage extends StatefulWidget {
|
||||
@override
|
||||
_StatusFeedbackPageState createState() => _StatusFeedbackPageState();
|
||||
}
|
||||
|
||||
class _StatusFeedbackPageState extends State<StatusFeedbackPage> {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return BaseView<FeedbackViewModel>(
|
||||
onModelReady: (model) => model.getCOC(),
|
||||
builder: (_, model, widget) => AppScaffold(
|
||||
baseViewModel: model,
|
||||
body: Container(
|
||||
margin: EdgeInsets.all(8.0),
|
||||
padding: EdgeInsets.all(15.0),
|
||||
child: ListView.builder(
|
||||
itemCount: model.cOCItemList.length,
|
||||
itemBuilder: (context, index) => Container(
|
||||
decoration: BoxDecoration(
|
||||
shape: BoxShape.rectangle,
|
||||
border: Border.all(color: Colors.white, width: 0.5),
|
||||
borderRadius: BorderRadius.all(Radius.circular(5)),
|
||||
color: Colors.white,
|
||||
),
|
||||
margin: EdgeInsets.all(4),
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(8.0),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: <Widget>[
|
||||
SizedBox(height: 8,),
|
||||
Row(
|
||||
mainAxisAlignment:
|
||||
MainAxisAlignment.spaceBetween,
|
||||
children: <Widget>[
|
||||
Column(
|
||||
crossAxisAlignment:
|
||||
CrossAxisAlignment.start,
|
||||
children: <Widget>[
|
||||
Texts('${model.cOCItemList[index].cOCTitle}'),
|
||||
Texts(
|
||||
'Number :${model.cOCItemList[index].itemID}',
|
||||
variant: 'overline',
|
||||
),
|
||||
],
|
||||
),
|
||||
Column(
|
||||
crossAxisAlignment:
|
||||
CrossAxisAlignment.start,
|
||||
children: <Widget>[
|
||||
Texts('${model.cOCItemList[index].status}'),
|
||||
Texts(
|
||||
'${model.cOCItemList[index].date}',
|
||||
variant: 'overline',
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
Texts('${model.cOCItemList[index].formType}'),
|
||||
Divider(height: 4.5,color: Colors.grey[500],)
|
||||
],
|
||||
),
|
||||
),
|
||||
)),
|
||||
),
|
||||
bottomSheet: Container(
|
||||
height: MediaQuery.of(context).size.height * 0.13,
|
||||
width: double.infinity,
|
||||
padding: EdgeInsets.all(8.0),
|
||||
child: Center(
|
||||
child: Container(
|
||||
height: MediaQuery.of(context).size.height * 0.1,
|
||||
width: MediaQuery.of(context).size.width * 0.8,
|
||||
child: Button(
|
||||
label: 'Search',
|
||||
loading: model.state == ViewState.BusyLocal,
|
||||
onTap: () {
|
||||
//TODO When come back
|
||||
},
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,118 @@
|
||||
import 'dart:ui';
|
||||
|
||||
import 'package:diplomaticquarterapp/pages/feedback/send_feedback_page.dart';
|
||||
import 'package:diplomaticquarterapp/widgets/data_display/text.dart';
|
||||
import 'package:diplomaticquarterapp/widgets/others/app_scaffold_widget.dart';
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import 'Status_feedback_page.dart';
|
||||
|
||||
class FeedbackHomePage extends StatefulWidget {
|
||||
@override
|
||||
_FeedbackHomePageState createState() => _FeedbackHomePageState();
|
||||
}
|
||||
|
||||
class _FeedbackHomePageState extends State<FeedbackHomePage>
|
||||
with SingleTickerProviderStateMixin {
|
||||
TabController _tabController;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
_tabController = TabController(length: 2, vsync: this);
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
super.dispose();
|
||||
_tabController.dispose();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return AppScaffold(
|
||||
isShowAppBar: true,
|
||||
appBarTitle: 'Feedback',
|
||||
body: Scaffold(
|
||||
extendBodyBehindAppBar: true,
|
||||
appBar: PreferredSize(
|
||||
preferredSize: Size.fromHeight(65.0),
|
||||
child: Stack(
|
||||
children: <Widget>[
|
||||
Positioned(
|
||||
bottom: 1,
|
||||
left: 0,
|
||||
right: 0,
|
||||
child: BackdropFilter(
|
||||
filter: ImageFilter.blur(sigmaX: 10, sigmaY: 10),
|
||||
child: Container(
|
||||
color: Theme.of(context)
|
||||
.scaffoldBackgroundColor
|
||||
.withOpacity(0.8),
|
||||
height: 70.0,
|
||||
),
|
||||
),
|
||||
),
|
||||
Center(
|
||||
child: Container(
|
||||
height: 60.0,
|
||||
margin: EdgeInsets.only(top: 10.0),
|
||||
width: MediaQuery.of(context).size.width * 0.9,
|
||||
decoration: BoxDecoration(
|
||||
border: Border(
|
||||
bottom: BorderSide(
|
||||
color: Theme.of(context).dividerColor,
|
||||
width: 0.7),
|
||||
),
|
||||
color: Colors.white),
|
||||
child: Center(
|
||||
child: TabBar(
|
||||
isScrollable: true,
|
||||
controller: _tabController,
|
||||
indicatorWeight: 5.0,
|
||||
indicatorSize: TabBarIndicatorSize.label,
|
||||
indicatorColor: Colors.red[800],
|
||||
labelColor: Theme.of(context).primaryColor,
|
||||
labelPadding:
|
||||
EdgeInsets.only(top: 4.0, left: 18.0, right: 18.0),
|
||||
unselectedLabelColor: Colors.grey[800],
|
||||
tabs: [
|
||||
Container(
|
||||
width: MediaQuery.of(context).size.width * 0.30,
|
||||
child: Center(
|
||||
child: Texts('Send'),
|
||||
),
|
||||
),
|
||||
Container(
|
||||
width: MediaQuery.of(context).size.width * 0.30,
|
||||
child: Center(
|
||||
child: Texts('Status'),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
body: Column(
|
||||
children: <Widget>[
|
||||
Expanded(
|
||||
child: TabBarView(
|
||||
physics: BouncingScrollPhysics(),
|
||||
controller: _tabController,
|
||||
children: <Widget>[
|
||||
SendFeedbackPage(),
|
||||
StatusFeedbackPage()
|
||||
],
|
||||
),
|
||||
)
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,141 @@
|
||||
import 'dart:convert';
|
||||
import 'dart:io';
|
||||
|
||||
import 'package:diplomaticquarterapp/widgets/data_display/text.dart';
|
||||
import 'package:feather_icons_flutter/feather_icons_flutter.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:image_picker/image_picker.dart';
|
||||
|
||||
class ImageOptions {
|
||||
static showImageOptions(BuildContext context, Function(String) image) {
|
||||
showModalBottomSheet(
|
||||
backgroundColor: Colors.transparent,
|
||||
context: context,
|
||||
builder: (BuildContext bc) {
|
||||
return _BottomSheet(
|
||||
children: <Widget>[
|
||||
_BottomSheetItem(
|
||||
title: "Select file souse",
|
||||
),
|
||||
_BottomSheetItem(
|
||||
title: "Gallery",
|
||||
icon: FeatherIcons.image,
|
||||
onTap: () async {
|
||||
File _image =
|
||||
await ImagePicker.pickImage(source: ImageSource.gallery);
|
||||
String fileName = _image.path;
|
||||
final bytes = File(fileName).readAsBytesSync();
|
||||
String base64Encode = base64.encode(bytes);
|
||||
if (base64Encode != null) {
|
||||
image(base64Encode);
|
||||
}
|
||||
},
|
||||
),
|
||||
_BottomSheetItem(
|
||||
title: "Camera",
|
||||
icon: FeatherIcons.camera,
|
||||
onTap: () async {
|
||||
File _image =
|
||||
await ImagePicker.pickImage(source: ImageSource.camera);
|
||||
String fileName = _image.path;
|
||||
final bytes = File(fileName).readAsBytesSync();
|
||||
String base64Encode = base64.encode(bytes);
|
||||
if (base64Encode != null) {
|
||||
image(base64Encode);
|
||||
}
|
||||
},
|
||||
),
|
||||
_BottomSheetItem(
|
||||
title: "Cancel",
|
||||
onTap: (){},
|
||||
)
|
||||
],
|
||||
);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
class _BottomSheet extends StatelessWidget {
|
||||
final List<Widget> children;
|
||||
|
||||
_BottomSheet({Key key, @required this.children}) : super(key: key);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Container(
|
||||
padding: EdgeInsets.symmetric(vertical: 12.0),
|
||||
decoration: BoxDecoration(
|
||||
color: Theme.of(context).backgroundColor,
|
||||
borderRadius: BorderRadius.only(
|
||||
topLeft: Radius.circular(16.0), topRight: Radius.circular(16.0))),
|
||||
child: SafeArea(
|
||||
top: false,
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: <Widget>[
|
||||
Container(
|
||||
decoration: BoxDecoration(
|
||||
color: Theme.of(context).dividerColor,
|
||||
borderRadius: BorderRadius.circular(3.0)),
|
||||
width: 40.0,
|
||||
height: 6.0,
|
||||
),
|
||||
...children
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class _BottomSheetItem extends StatelessWidget {
|
||||
final Function onTap;
|
||||
final IconData icon;
|
||||
final String title;
|
||||
final ITEM_COLOR color;
|
||||
|
||||
_BottomSheetItem(
|
||||
{Key key,
|
||||
this.onTap,
|
||||
@required this.title,
|
||||
this.icon,
|
||||
this.color = ITEM_COLOR.primary})
|
||||
: super(key: key);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return InkWell(
|
||||
onTap: () {
|
||||
if (onTap != null) {
|
||||
Navigator.pop(context);
|
||||
onTap();
|
||||
}
|
||||
},
|
||||
child: Padding(
|
||||
padding: EdgeInsets.symmetric(horizontal: 18.0, vertical: 18.0),
|
||||
child: Row(
|
||||
children: <Widget>[
|
||||
if (icon != null)
|
||||
Icon(
|
||||
icon,
|
||||
color: color == ITEM_COLOR.error
|
||||
? Theme.of(context).errorColor
|
||||
: Theme.of(context).primaryColor,
|
||||
size: 18.0,
|
||||
),
|
||||
if (icon != null) SizedBox(width: 24.0),
|
||||
Texts(
|
||||
title ?? "",
|
||||
style: "bodyText2",
|
||||
color: color == ITEM_COLOR.error
|
||||
? Theme.of(context).errorColor
|
||||
: null,
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
enum ITEM_COLOR { primary, error }
|
||||
Loading…
Reference in New Issue