Nuevos cambios hechos de diseño
This commit is contained in:
@@ -0,0 +1,346 @@
|
||||
import 'dart:convert';
|
||||
|
||||
import 'package:active_ecommerce_seller_app/custom/buttons.dart';
|
||||
import 'package:active_ecommerce_seller_app/custom/device_info.dart';
|
||||
import 'package:active_ecommerce_seller_app/custom/localization.dart';
|
||||
import 'package:active_ecommerce_seller_app/custom/my_app_bar.dart';
|
||||
import 'package:active_ecommerce_seller_app/custom/my_widget.dart';
|
||||
import 'package:active_ecommerce_seller_app/custom/submitButton.dart';
|
||||
import 'package:active_ecommerce_seller_app/custom/toast_component.dart';
|
||||
import 'package:active_ecommerce_seller_app/helpers/file_helper.dart';
|
||||
import 'package:active_ecommerce_seller_app/my_theme.dart';
|
||||
import 'package:active_ecommerce_seller_app/repositories/file_upload_repository.dart';
|
||||
import 'package:active_ecommerce_seller_app/repositories/shop_repository.dart';
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:image_picker/image_picker.dart';
|
||||
import 'package:permission_handler/permission_handler.dart';
|
||||
import 'package:toast/toast.dart';
|
||||
|
||||
class ShopBannerSettings extends StatefulWidget {
|
||||
const ShopBannerSettings({Key? key}) : super(key: key);
|
||||
|
||||
@override
|
||||
State<ShopBannerSettings> createState() => _ShopBannerSettingsState();
|
||||
}
|
||||
|
||||
class _ShopBannerSettingsState extends State<ShopBannerSettings> {
|
||||
|
||||
late BuildContext loadingContext;
|
||||
|
||||
List<String> _imageUrls = [];
|
||||
List<String>? _imageIds = [];
|
||||
List<String> _errors=[];
|
||||
//for image uploading
|
||||
final ImagePicker _picker = ImagePicker();
|
||||
XFile? _file;
|
||||
|
||||
Future<bool> _getAccountInfo() async {
|
||||
var response = await ShopRepository().getShopInfo();
|
||||
Navigator.pop(loadingContext);
|
||||
|
||||
_imageUrls.addAll(response.shopInfo!.sliders!) ;
|
||||
|
||||
if(response.shopInfo!.slidersId!=null)
|
||||
_imageIds= response.shopInfo!.slidersId.split(",");
|
||||
|
||||
print(_imageIds!.join(','));
|
||||
setState(() {});
|
||||
return true;
|
||||
}
|
||||
|
||||
updateInfo()async{
|
||||
var postBody = jsonEncode({
|
||||
"sliders": _imageIds!.join(','),
|
||||
});
|
||||
loadingShow(context);
|
||||
var response = await ShopRepository().updateShopSetting(postBody);
|
||||
Navigator.pop(loadingContext);
|
||||
|
||||
ToastComponent.showDialog(response.message,
|
||||
bgColor: MyTheme.white, duration: Toast.lengthLong, gravity: Toast.center);
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
resetData(){
|
||||
cleanData();
|
||||
faceData();
|
||||
}
|
||||
cleanData(){
|
||||
_imageUrls = [];
|
||||
_imageIds = [];
|
||||
_errors=[];
|
||||
//for image uploading
|
||||
}
|
||||
|
||||
faceData(){
|
||||
WidgetsBinding.instance
|
||||
.addPostFrameCallback((_) => loadingShow(context));
|
||||
_getAccountInfo();
|
||||
}
|
||||
/*
|
||||
chooseAndUploadImage(context) async {
|
||||
var status = await Permission.photos.request();
|
||||
|
||||
if (status.isDenied) {
|
||||
// We didn't ask for permission yet.
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (BuildContext context) => CupertinoAlertDialog(
|
||||
title: Text(LangText(context: context)
|
||||
.getLocal()
|
||||
.common_photo_permission),
|
||||
content: Text(
|
||||
LangText(context:context).getLocal().common_app_needs_permission),
|
||||
actions: <Widget>[
|
||||
CupertinoDialogAction(
|
||||
child:
|
||||
Text(LangText(context: context).getLocal().common_deny),
|
||||
onPressed: () => Navigator.of(context).pop(),
|
||||
),
|
||||
CupertinoDialogAction(
|
||||
child: Text(
|
||||
LangText(context: context).getLocal().common_settings),
|
||||
onPressed: () => openAppSettings(),
|
||||
),
|
||||
],
|
||||
));
|
||||
} else if (status.isRestricted) {
|
||||
ToastComponent.showDialog(
|
||||
LangText(context: context).getLocal().common_give_photo_permission,
|
||||
|
||||
gravity: Toast.center,
|
||||
duration: Toast.lengthLong);
|
||||
} else if (status.isGranted) {
|
||||
//file = await ImagePicker.pickImage(source: ImageSource.camera);
|
||||
_file = await _picker.pickImage(source: ImageSource.gallery);
|
||||
|
||||
if (_file == null) {
|
||||
ToastComponent.showDialog(
|
||||
LangText(context:context).getLocal().common_no_file_chosen,
|
||||
gravity: Toast.center, duration: Toast.lengthLong);
|
||||
return;
|
||||
}
|
||||
|
||||
//return;
|
||||
String base64Image = FileHelper.getBase64FormateFile(_file.path);
|
||||
String fileName = _file.path.split("/").last;
|
||||
|
||||
var imageUploadResponse = await FileUploadRepository().imageUpload(
|
||||
base64Image,
|
||||
fileName,
|
||||
);
|
||||
|
||||
if (imageUploadResponse.result == false) {
|
||||
ToastComponent.showDialog(imageUploadResponse.message,
|
||||
gravity: Toast.center, duration: Toast.lengthLong);
|
||||
return;
|
||||
} else {
|
||||
ToastComponent.showDialog(imageUploadResponse.message,
|
||||
gravity: Toast.center, duration: Toast.lengthLong);
|
||||
|
||||
_imageUrls.add(imageUploadResponse.path);
|
||||
_imageIds.add(imageUploadResponse.upload_id.toString());
|
||||
setState(() {
|
||||
});
|
||||
|
||||
}
|
||||
}
|
||||
}*/
|
||||
|
||||
|
||||
formValidation(){
|
||||
_errors=[];
|
||||
if(_imageIds!.isEmpty){
|
||||
_errors.add(LangText(context: context).getLocal()!.shop_banner_image_is_required);
|
||||
}
|
||||
setState(() {
|
||||
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
Future onRefresh(){
|
||||
faceData();
|
||||
return Future.delayed(Duration(seconds: 0));
|
||||
}
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
faceData();
|
||||
// TODO: implement initState
|
||||
super.initState();
|
||||
}
|
||||
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
appBar: MyAppBar(
|
||||
context: context,
|
||||
title: LangText(context: context)
|
||||
.getLocal()!
|
||||
.banner_settings)
|
||||
.show(),
|
||||
body: RefreshIndicator(
|
||||
onRefresh: onRefresh,
|
||||
child: SingleChildScrollView(
|
||||
physics: AlwaysScrollableScrollPhysics(),
|
||||
child: Container(
|
||||
padding: EdgeInsets.symmetric(horizontal: 15),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
SizedBox(height: 20,),
|
||||
Text(
|
||||
LangText(context: context)
|
||||
.getLocal()!
|
||||
.banner_1500_x_450,
|
||||
style: TextStyle(
|
||||
fontSize: 12,
|
||||
color: MyTheme.font_grey,
|
||||
fontWeight: FontWeight.bold),
|
||||
),
|
||||
SizedBox(
|
||||
height: 10,
|
||||
),
|
||||
Buttons(
|
||||
padding: EdgeInsets.zero,
|
||||
onPressed: (){
|
||||
|
||||
// chooseAndUploadImage(context);
|
||||
},
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(6)),
|
||||
child: MyWidget().myContainer(
|
||||
width: DeviceInfo(context).getWidth(),
|
||||
height: 36,
|
||||
borderRadius: 6.0,
|
||||
borderColor: MyTheme.light_grey,
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(left: 14.0),
|
||||
child: Text(
|
||||
"Choose file",
|
||||
style: TextStyle(
|
||||
fontSize: 12, color: MyTheme.grey_153),
|
||||
),
|
||||
),
|
||||
Container(
|
||||
alignment: Alignment.center,
|
||||
height: 36,
|
||||
width: 80,
|
||||
color: MyTheme.light_grey,
|
||||
child: Text(
|
||||
"Browse",
|
||||
style: TextStyle(
|
||||
fontSize: 12, color: MyTheme.grey_153),
|
||||
)),
|
||||
],
|
||||
)),
|
||||
),
|
||||
],
|
||||
),
|
||||
SizedBox(
|
||||
height: 10,
|
||||
),
|
||||
Text(
|
||||
LangText(context: context)
|
||||
.getLocal()!
|
||||
.banner_1500_x_450_des,
|
||||
style: TextStyle(fontSize: 8, color: MyTheme.grey_153),
|
||||
),
|
||||
SizedBox(
|
||||
height: 10,
|
||||
),
|
||||
Wrap(
|
||||
spacing: 10,
|
||||
children: List.generate(_imageUrls.length, (index) => Stack(
|
||||
children: [
|
||||
MyWidget.imageWithPlaceholder(height: 60.0,width: 60.0,url: _imageUrls[index]),
|
||||
Positioned(
|
||||
child: Container(
|
||||
height: 15,
|
||||
width: 15,
|
||||
decoration: BoxDecoration(
|
||||
borderRadius: BorderRadius.circular(30),
|
||||
color: MyTheme.white
|
||||
),
|
||||
child: InkWell(
|
||||
onTap: (){
|
||||
_imageUrls.removeAt(index);
|
||||
_imageIds!.removeAt(index);
|
||||
setState(() {
|
||||
});
|
||||
},
|
||||
child: Icon(Icons.close,size: 12,color: MyTheme.red,),),
|
||||
),
|
||||
top: 0,
|
||||
right: 5,
|
||||
),
|
||||
],
|
||||
),),
|
||||
),
|
||||
SizedBox(height: 14,),
|
||||
|
||||
Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: List.generate(_errors.length, (index) => Text(_errors[index],style: TextStyle(fontSize: 15,color: MyTheme.red),)),
|
||||
),
|
||||
SizedBox(
|
||||
height: 20,
|
||||
),
|
||||
SubmitBtn.show(
|
||||
alignment: Alignment.center,
|
||||
onTap: (){
|
||||
formValidation();
|
||||
if(_errors.isEmpty){
|
||||
updateInfo();
|
||||
}
|
||||
},height: 48,
|
||||
backgroundColor: MyTheme.app_accent_color,
|
||||
radius: 6.0,
|
||||
width: DeviceInfo(context).getWidth(),
|
||||
child:Text(
|
||||
LangText(context: context).getLocal()!.save_ucf,
|
||||
style: TextStyle(fontSize: 17, color: MyTheme.white),
|
||||
)
|
||||
),
|
||||
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
loadingShow(BuildContext myContext){
|
||||
return showDialog(
|
||||
//barrierDismissible: false,
|
||||
context: myContext,
|
||||
builder: (BuildContext context) {
|
||||
loadingContext = context;
|
||||
return AlertDialog(
|
||||
content: Row(
|
||||
children: [
|
||||
CircularProgressIndicator(),
|
||||
SizedBox(
|
||||
width: 10,
|
||||
),
|
||||
Text("${LangText(context: context).getLocal()!.please_wait_ucf}"),
|
||||
],
|
||||
));
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,469 @@
|
||||
import 'dart:async';
|
||||
import 'dart:convert';
|
||||
import 'dart:math';
|
||||
|
||||
import 'package:active_ecommerce_seller_app/custom/buttons.dart';
|
||||
import 'package:active_ecommerce_seller_app/custom/device_info.dart';
|
||||
import 'package:active_ecommerce_seller_app/custom/localization.dart';
|
||||
import 'package:active_ecommerce_seller_app/custom/my_app_bar.dart';
|
||||
import 'package:active_ecommerce_seller_app/custom/my_widget.dart';
|
||||
import 'package:active_ecommerce_seller_app/custom/submitButton.dart';
|
||||
|
||||
import 'package:active_ecommerce_seller_app/custom/toast_component.dart';
|
||||
import 'package:active_ecommerce_seller_app/my_theme.dart';
|
||||
import 'package:active_ecommerce_seller_app/other_config.dart';
|
||||
import 'package:active_ecommerce_seller_app/repositories/google_map_location_repository.dart';
|
||||
import 'package:active_ecommerce_seller_app/repositories/shop_repository.dart';
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_typeahead/flutter_typeahead.dart';
|
||||
import 'package:google_maps_place_picker_mb/google_maps_place_picker.dart';
|
||||
import 'package:toast/toast.dart';
|
||||
import 'package:google_maps_flutter/google_maps_flutter.dart';
|
||||
import 'dart:io' show Platform;
|
||||
|
||||
|
||||
class ShopDeliveryBoyPickupPoint extends StatefulWidget {
|
||||
const ShopDeliveryBoyPickupPoint({Key? key}) : super(key: key);
|
||||
|
||||
@override
|
||||
State<ShopDeliveryBoyPickupPoint> createState() =>
|
||||
_ShopDeliveryBoyPickupPointState();
|
||||
}
|
||||
|
||||
class _ShopDeliveryBoyPickupPointState
|
||||
extends State<ShopDeliveryBoyPickupPoint> {
|
||||
TextEditingController locationSearch = TextEditingController();
|
||||
|
||||
|
||||
late BuildContext loadingContext;
|
||||
|
||||
|
||||
String _lat="";
|
||||
String _lang="";
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
bool faceAllData = false;
|
||||
LatLng kInitialPosition = LatLng(51.52034098371205, -0.12637399200000668);
|
||||
|
||||
Future<bool> _getAccountInfo() async {
|
||||
var response = await ShopRepository().getShopInfo();
|
||||
_lat = response.shopInfo!.deliveryPickupLatitude.toString();
|
||||
_lang = response.shopInfo!.deliveryPickupLongitude.toString();
|
||||
|
||||
faceAllData = true;
|
||||
if ((_lat == "" && _lang == "") || (_lat == null && _lang == null)) {
|
||||
|
||||
setDummyInitialLocation();
|
||||
} else {
|
||||
setInitialLocation( response.shopInfo!.deliveryPickupLatitude.toString(),response.shopInfo!.deliveryPickupLongitude.toString());
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
setInitialLocation(lat ,lng) {
|
||||
kInitialPosition=LatLng(double.parse(lat), double.parse(lng));
|
||||
setState((){});
|
||||
}
|
||||
|
||||
setDummyInitialLocation() {
|
||||
kInitialPosition= LatLng(
|
||||
51.52034098371205, -0.12637399200000668);
|
||||
setState((){});
|
||||
}
|
||||
|
||||
faceData() {
|
||||
_getAccountInfo();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
changeLatLang(lat ,lng){
|
||||
setState((){
|
||||
_lat=lat;
|
||||
_lang=lng;
|
||||
});
|
||||
|
||||
|
||||
//kInitialPositionInput.add(LatLng(double.parse(lat), double.parse(lng)));
|
||||
}
|
||||
|
||||
/*
|
||||
updatePickupPoint(selectedPlace) async {
|
||||
|
||||
var postBody = jsonEncode({
|
||||
"delivery_pickup_longitude": selectedPlace.geometry.location.lng.toString(),
|
||||
"delivery_pickup_latitude": selectedPlace.geometry.location.lat.toString(),
|
||||
});
|
||||
var response = await ShopRepository().updateShopSetting(postBody);
|
||||
|
||||
ToastComponent.showDialog(response.message,
|
||||
gravity: Toast.center, duration: Toast.lengthLong);
|
||||
|
||||
|
||||
}*/
|
||||
|
||||
updateInfo()async{
|
||||
|
||||
if( _lat == null || _lat.isEmpty || _lang == null || _lang.isEmpty ){
|
||||
|
||||
ToastComponent.showDialog("Please Pick a Place",
|
||||
bgColor: MyTheme.white, duration: Toast.lengthLong, gravity: Toast.center);
|
||||
return;
|
||||
}
|
||||
var postBody = jsonEncode({
|
||||
"delivery_pickup_longitude": _lang,
|
||||
"delivery_pickup_latitude": _lat,
|
||||
});
|
||||
loadingShow(context);
|
||||
var response = await ShopRepository().updateShopSetting(postBody);
|
||||
Navigator.pop(loadingContext);
|
||||
|
||||
ToastComponent.showDialog(response.message,
|
||||
bgColor: MyTheme.white, duration: Toast.lengthLong, gravity: Toast.center);
|
||||
|
||||
|
||||
}
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
|
||||
faceData();
|
||||
// TODO: implement initState
|
||||
super.initState();
|
||||
}
|
||||
|
||||
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
|
||||
return Scaffold(
|
||||
appBar: MyAppBar(
|
||||
context: context,
|
||||
title: LangText(context: context)
|
||||
.getLocal()!
|
||||
.delivery_boy_pickup_point)
|
||||
.show(),
|
||||
body: SingleChildScrollView(
|
||||
child: SizedBox(
|
||||
child:
|
||||
faceAllData?buildBodyContainer():buildLoadingContainer(),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
Column buildBodyContainer() {
|
||||
|
||||
return Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
const SizedBox(
|
||||
height: 10,
|
||||
),
|
||||
SizedBox(
|
||||
height:DeviceInfo(context).getHeight()/2,
|
||||
child:
|
||||
buildMap(),
|
||||
),
|
||||
Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 8.0),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
const SizedBox(
|
||||
height: 10,
|
||||
),
|
||||
Text(
|
||||
LangText(context: context).getLocal()!.longitude_ucf,
|
||||
style: TextStyle(
|
||||
fontSize: 12,
|
||||
color: MyTheme.font_grey,
|
||||
fontWeight: FontWeight.bold),
|
||||
),
|
||||
const SizedBox(
|
||||
height: 10,
|
||||
),
|
||||
MyWidget.customCardView(
|
||||
height: 40.0,
|
||||
width: DeviceInfo(context).getWidth(),
|
||||
borderRadius: 10,
|
||||
backgroundColor: MyTheme.white,
|
||||
padding:
|
||||
EdgeInsets.symmetric(horizontal: 5, vertical: 5),
|
||||
alignment: Alignment.centerLeft,
|
||||
child: Text(_lat??"",
|
||||
//latLng.latitude.toString(),
|
||||
style: TextStyle(
|
||||
fontSize: 15, color: MyTheme.font_grey),
|
||||
)
|
||||
),
|
||||
const SizedBox(
|
||||
height: 10,
|
||||
),
|
||||
Text(
|
||||
LangText(context: context).getLocal()!.latitude_ucf,
|
||||
style: TextStyle(
|
||||
fontSize: 12,
|
||||
color: MyTheme.font_grey,
|
||||
fontWeight: FontWeight.bold),
|
||||
),
|
||||
const SizedBox(
|
||||
height: 10,
|
||||
),
|
||||
MyWidget.customCardView(
|
||||
height: 40.0,
|
||||
width: DeviceInfo(context).getWidth(),
|
||||
borderRadius: 10,
|
||||
backgroundColor: MyTheme.white,
|
||||
padding:
|
||||
EdgeInsets.symmetric(horizontal: 5, vertical: 5),
|
||||
alignment: Alignment.centerLeft,
|
||||
borderColor: MyTheme.noColor,
|
||||
child: Text(_lang??"",
|
||||
// latLng.longitude.toString(),
|
||||
style: TextStyle(
|
||||
fontSize: 15, color: MyTheme.font_grey),
|
||||
),
|
||||
),
|
||||
const SizedBox(
|
||||
height: 30,
|
||||
),
|
||||
SubmitBtn.show(
|
||||
width: DeviceInfo(context).getWidth(),
|
||||
backgroundColor: MyTheme.app_accent_color,
|
||||
height: 48,
|
||||
padding: EdgeInsets.zero,
|
||||
elevation: 5,
|
||||
radius: 10,
|
||||
alignment: Alignment.center,
|
||||
onTap: () {
|
||||
updateInfo();
|
||||
},
|
||||
child: Text(
|
||||
LangText(context: context)
|
||||
.getLocal()!
|
||||
.update_location,
|
||||
style: TextStyle(fontSize: 17, color: MyTheme.white),
|
||||
)),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
Padding buildLoadingContainer() {
|
||||
return Padding(
|
||||
padding: EdgeInsets.only(top:(DeviceInfo(context).getHeight()/2.5)),
|
||||
child: Center(
|
||||
child: CircularProgressIndicator(
|
||||
strokeWidth: 5,
|
||||
),),
|
||||
);
|
||||
}
|
||||
/*
|
||||
Widget buildSearchContainer(BuildContext context) {
|
||||
return Container(
|
||||
child: TypeAheadField(
|
||||
suggestionsCallback: (name) async {
|
||||
var countryResponse =
|
||||
await GoogleMapLocationRepository().getAutoCompleteAddress(name);
|
||||
return countryResponse.predictions;
|
||||
},
|
||||
loadingBuilder: (context) {
|
||||
return Container(
|
||||
height: 50,
|
||||
child: Center(
|
||||
child: Text(
|
||||
LangText(context: context).getLocal().common_no_more_Data,
|
||||
style: TextStyle(color: MyTheme.medium_grey))),
|
||||
);
|
||||
},
|
||||
itemBuilder: (context, location) {
|
||||
//print(suggestion.toString());
|
||||
return ListTile(
|
||||
dense: true,
|
||||
title: Text(
|
||||
location.description,
|
||||
style: TextStyle(color: MyTheme.font_grey),
|
||||
),
|
||||
);
|
||||
},
|
||||
noItemsFoundBuilder: (context) {
|
||||
return Container(
|
||||
height: 50,
|
||||
child: Center(
|
||||
child: Text(
|
||||
LangText(context: context).getLocal().common_no_more_Data,
|
||||
style: TextStyle(color: MyTheme.medium_grey))),
|
||||
);
|
||||
},
|
||||
onSuggestionSelected: (location) {
|
||||
// onSelectCountryDuringAdd(location);
|
||||
},
|
||||
textFieldConfiguration: TextFieldConfiguration(
|
||||
onTap: () {},
|
||||
//autofocus: true,
|
||||
controller: locationSearch,
|
||||
onSubmitted: (txt) {
|
||||
// keep this blank
|
||||
},
|
||||
decoration: InputDecoration(
|
||||
hintText:
|
||||
LangText(context: context).getLocal().common_search_address,
|
||||
hintStyle:
|
||||
TextStyle(fontSize: 12.0, color: MyTheme.textfield_grey),
|
||||
enabledBorder: OutlineInputBorder(
|
||||
borderSide:
|
||||
BorderSide(color: MyTheme.textfield_grey, width: 0.5),
|
||||
borderRadius: const BorderRadius.all(
|
||||
const Radius.circular(8.0),
|
||||
),
|
||||
),
|
||||
focusedBorder: OutlineInputBorder(
|
||||
borderSide:
|
||||
BorderSide(color: MyTheme.textfield_grey, width: 1.0),
|
||||
borderRadius: const BorderRadius.all(
|
||||
const Radius.circular(8.0),
|
||||
),
|
||||
),
|
||||
contentPadding: EdgeInsets.symmetric(horizontal: 8.0)),
|
||||
),
|
||||
),
|
||||
);
|
||||
}*/
|
||||
|
||||
|
||||
loadingShow(BuildContext myContext) {
|
||||
return showDialog(
|
||||
//barrierDismissible: false,
|
||||
context: myContext,
|
||||
builder: (BuildContext context) {
|
||||
loadingContext = context;
|
||||
return AlertDialog(
|
||||
content: Row(
|
||||
children: [
|
||||
CircularProgressIndicator(),
|
||||
SizedBox(
|
||||
width: 10,
|
||||
),
|
||||
Text("${LangText(context: context).getLocal()!.please_wait_ucf}"),
|
||||
],
|
||||
));
|
||||
});
|
||||
}
|
||||
|
||||
Widget buildMap() {
|
||||
|
||||
return PlacePicker(
|
||||
hintText: LangText(context: context)
|
||||
.getLocal()!
|
||||
.your_delivery_location,
|
||||
apiKey: OtherConfig.GOOGLE_MAP_API_KEY,
|
||||
initialPosition: kInitialPosition,
|
||||
useCurrentLocation: false,
|
||||
selectInitialPosition: true,
|
||||
onTapBack: (){},
|
||||
onPlacePicked: (pik){
|
||||
changeLatLang(pik.geometry!.location.lat.toString(), pik.geometry!.location.lng.toString());
|
||||
},
|
||||
|
||||
|
||||
selectedPlaceWidgetBuilder:
|
||||
(_, selectedPlace, state, isSearchBarFocused) {
|
||||
//print("state: $state, isSearchBarFocused: $isSearchBarFocused");
|
||||
//print(selectedPlace.toString());
|
||||
//print("-------------");
|
||||
/*
|
||||
if(!isSearchBarFocused && state != SearchingState.Searching){
|
||||
ToastComponent.showDialog("Hello", context,
|
||||
gravity: Toast.center, duration: Toast.lengthLong);
|
||||
}*/
|
||||
return isSearchBarFocused
|
||||
? Container()
|
||||
: FloatingCard(
|
||||
|
||||
height: 50,
|
||||
bottomPosition: 20.0,
|
||||
// MediaQuery.of(context) will cause rebuild. See MediaQuery document for the information.
|
||||
leftPosition: 0.0,
|
||||
rightPosition: 0.0,
|
||||
width: 500,
|
||||
borderRadius: const BorderRadius.only(
|
||||
topLeft: const Radius.circular(8.0),
|
||||
bottomLeft: const Radius.circular(8.0),
|
||||
topRight: const Radius.circular(8.0),
|
||||
bottomRight: const Radius.circular(8.0),
|
||||
),
|
||||
child: state == SearchingState.Searching
|
||||
? Center(
|
||||
child: Text(
|
||||
LangText(context: context).getLocal()!.calculating_ucf,
|
||||
style: TextStyle(color: MyTheme.font_grey),
|
||||
))
|
||||
: Padding(
|
||||
padding: const EdgeInsets.all(8.0),
|
||||
child: Row(
|
||||
children: [
|
||||
Expanded(
|
||||
flex: 2,
|
||||
child: Container(
|
||||
child: Center(
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.only(
|
||||
left: 2.0, right: 2.0),
|
||||
child: Text(
|
||||
selectedPlace!.formattedAddress!,
|
||||
maxLines: 2,
|
||||
style:
|
||||
TextStyle(color: MyTheme.medium_grey),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
Expanded(
|
||||
flex: 1,
|
||||
child: Buttons(
|
||||
color: MyTheme.app_accent_color,
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: const BorderRadius.only(
|
||||
topLeft: const Radius.circular(4.0),
|
||||
bottomLeft: const Radius.circular(4.0),
|
||||
topRight: const Radius.circular(4.0),
|
||||
bottomRight: const Radius.circular(4.0),
|
||||
)),
|
||||
child: Text(
|
||||
LangText(context: context).getLocal()!.pick_here_ucf,
|
||||
style: TextStyle(color: Colors.white),
|
||||
),
|
||||
onPressed: () {
|
||||
|
||||
changeLatLang(selectedPlace.geometry!.location.lat.toString(),selectedPlace.geometry!.location.lng.toString());
|
||||
},
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
|
||||
pinBuilder: (context, state) {
|
||||
return Image.asset(
|
||||
'assets/icon/delivery_map_icon.png',
|
||||
height: 60,
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,555 @@
|
||||
import 'dart:convert';
|
||||
|
||||
import 'package:active_ecommerce_seller_app/custom/device_info.dart';
|
||||
import 'package:active_ecommerce_seller_app/custom/input_decorations.dart';
|
||||
import 'package:active_ecommerce_seller_app/custom/localization.dart';
|
||||
import 'package:active_ecommerce_seller_app/custom/my_app_bar.dart';
|
||||
import 'package:active_ecommerce_seller_app/custom/my_widget.dart';
|
||||
import 'package:active_ecommerce_seller_app/custom/submitButton.dart';
|
||||
import 'package:active_ecommerce_seller_app/custom/toast_component.dart';
|
||||
import 'package:active_ecommerce_seller_app/data_model/uploaded_file_list_response.dart';
|
||||
import 'package:active_ecommerce_seller_app/helpers/file_helper.dart';
|
||||
import 'package:active_ecommerce_seller_app/my_theme.dart';
|
||||
import 'package:active_ecommerce_seller_app/repositories/file_upload_repository.dart';
|
||||
import 'package:active_ecommerce_seller_app/repositories/shop_repository.dart';
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:image_picker/image_picker.dart';
|
||||
import 'package:permission_handler/permission_handler.dart';
|
||||
import 'package:toast/toast.dart';
|
||||
|
||||
|
||||
class ShopGeneralSetting extends StatefulWidget {
|
||||
const ShopGeneralSetting({Key? key}) : super(key: key);
|
||||
|
||||
@override
|
||||
State<ShopGeneralSetting> createState() => _ShopGeneralSettingState();
|
||||
}
|
||||
|
||||
class _ShopGeneralSettingState extends State<ShopGeneralSetting> {
|
||||
|
||||
|
||||
|
||||
late BuildContext loadingContext;
|
||||
|
||||
String? avatar_original = "";
|
||||
String? _imageId = "";
|
||||
List<String> _errors=[];
|
||||
|
||||
bool _faceData=false;
|
||||
|
||||
|
||||
//for image uploading
|
||||
final ImagePicker _picker = ImagePicker();
|
||||
XFile? _file;
|
||||
|
||||
|
||||
TextEditingController nameEditingController = TextEditingController(text: "");
|
||||
TextEditingController addressEditingController = TextEditingController(text: "");
|
||||
TextEditingController titleEditingController = TextEditingController(text: "");
|
||||
TextEditingController phoneEditingController = TextEditingController(text: "");
|
||||
TextEditingController descriptionEditingController = TextEditingController(text: "");
|
||||
|
||||
Future<bool> _getAccountInfo() async {
|
||||
var response = await ShopRepository().getShopInfo();
|
||||
Navigator.pop(loadingContext);
|
||||
avatar_original=response.shopInfo!.logo;
|
||||
nameEditingController.text=response.shopInfo!.name!;
|
||||
addressEditingController.text=response.shopInfo!.address!;
|
||||
titleEditingController.text=response.shopInfo!.title!;
|
||||
descriptionEditingController.text=response.shopInfo!.description!;
|
||||
phoneEditingController.text=response.shopInfo!.phone!;
|
||||
_imageId = response.shopInfo!.uploadId;
|
||||
_faceData=true;
|
||||
setState(() {});
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
updateInfo()async{
|
||||
var postBody = jsonEncode({
|
||||
"name": nameEditingController.text.trim(),
|
||||
"address": addressEditingController.text.trim(),
|
||||
"phone": phoneEditingController.text.trim(),
|
||||
"meta_title": titleEditingController.text.trim(),
|
||||
"meta_description": descriptionEditingController.text.trim(),
|
||||
"logo": _imageId,
|
||||
});
|
||||
loadingShow(context);
|
||||
var response = await ShopRepository().updateShopSetting(postBody);
|
||||
Navigator.pop(loadingContext);
|
||||
|
||||
if (response.result!) {
|
||||
ToastComponent.showDialog(response.message,
|
||||
bgColor: MyTheme.white, duration: Toast.lengthLong, gravity: Toast.center);
|
||||
}else{
|
||||
ToastComponent.showDialog(response.message,
|
||||
bgColor: MyTheme.white, duration: Toast.lengthLong, gravity: Toast.center);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
faceData(){
|
||||
WidgetsBinding.instance
|
||||
.addPostFrameCallback((_) => loadingShow(context));
|
||||
_getAccountInfo();
|
||||
}
|
||||
/*
|
||||
chooseAndUploadImage(context) async {
|
||||
var status = await Permission.photos.request();
|
||||
|
||||
if (status.isDenied) {
|
||||
// We didn't ask for permission yet.
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (BuildContext context) => CupertinoAlertDialog(
|
||||
title: Text(LangText(context: context)
|
||||
.getLocal()
|
||||
.common_photo_permission),
|
||||
content: Text(
|
||||
LangText(context:context).getLocal().common_app_needs_permission),
|
||||
actions: <Widget>[
|
||||
CupertinoDialogAction(
|
||||
child:
|
||||
Text(LangText(context: context).getLocal().common_deny),
|
||||
onPressed: () => Navigator.of(context).pop(),
|
||||
),
|
||||
CupertinoDialogAction(
|
||||
child: Text(
|
||||
LangText(context: context).getLocal().common_settings),
|
||||
onPressed: () => openAppSettings(),
|
||||
),
|
||||
],
|
||||
));
|
||||
} else if (status.isRestricted) {
|
||||
ToastComponent.showDialog(
|
||||
LangText(context: context).getLocal().common_give_photo_permission,
|
||||
|
||||
gravity: Toast.center,
|
||||
duration: Toast.lengthLong);
|
||||
} else if (status.isGranted) {
|
||||
//file = await ImagePicker.pickImage(source: ImageSource.camera);
|
||||
_file = await _picker.pickImage(source: ImageSource.gallery);
|
||||
|
||||
if (_file == null) {
|
||||
ToastComponent.showDialog(
|
||||
LangText(context:context).getLocal().common_no_file_chosen,
|
||||
gravity: Toast.center, duration: Toast.lengthLong);
|
||||
return;
|
||||
}
|
||||
|
||||
//return;
|
||||
String base64Image = FileHelper.getBase64FormateFile(_file.path);
|
||||
String fileName = _file.path.split("/").last;
|
||||
|
||||
var imageUploadResponse = await FileUploadRepository().imageUpload(
|
||||
base64Image,
|
||||
fileName,
|
||||
);
|
||||
|
||||
if (imageUploadResponse.result == false) {
|
||||
ToastComponent.showDialog(imageUploadResponse.message,
|
||||
gravity: Toast.center, duration: Toast.lengthLong);
|
||||
return;
|
||||
} else {
|
||||
ToastComponent.showDialog(imageUploadResponse.message,
|
||||
gravity: Toast.center, duration: Toast.lengthLong);
|
||||
avatar_original=imageUploadResponse.path;
|
||||
_imageId=imageUploadResponse.upload_id.toString();
|
||||
setState(() {
|
||||
});
|
||||
|
||||
}
|
||||
}
|
||||
}*/
|
||||
|
||||
|
||||
formValidation(){
|
||||
_errors=[];
|
||||
if(nameEditingController.text.trim().isEmpty){
|
||||
|
||||
_errors.add(LangText(context: context).getLocal()!.shop_name_is_required);
|
||||
}
|
||||
if(phoneEditingController.text.trim().isEmpty){
|
||||
|
||||
_errors.add(LangText(context: context).getLocal()!.shop_phone_is_required);
|
||||
}
|
||||
if(addressEditingController.text.trim().isEmpty){
|
||||
_errors.add(LangText(context: context).getLocal()!.shop_address_is_required);
|
||||
}
|
||||
if(titleEditingController.text.trim().isEmpty){
|
||||
|
||||
_errors.add(LangText(context: context).getLocal()!.shop_title_is_required);
|
||||
}
|
||||
if(descriptionEditingController.text.trim().isEmpty){
|
||||
|
||||
_errors.add(LangText(context: context).getLocal()!.shop_description_is_required);
|
||||
}
|
||||
if(_imageId!.isEmpty){
|
||||
_errors.add(LangText(context: context).getLocal()!.shop_logo_is_required);
|
||||
}
|
||||
|
||||
setState(() {
|
||||
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
Future<void> onRefresh(){
|
||||
faceData();
|
||||
return Future.delayed(Duration(seconds: 0));
|
||||
}
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
faceData();
|
||||
// TODO: implement initState
|
||||
super.initState();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
appBar: MyAppBar(
|
||||
context: context,
|
||||
title: LangText(context: context)
|
||||
.getLocal()!
|
||||
.general_setting_ucf)
|
||||
.show(),
|
||||
body: RefreshIndicator(
|
||||
onRefresh: onRefresh,
|
||||
child: SingleChildScrollView(
|
||||
child: Container(
|
||||
padding: EdgeInsets.symmetric(horizontal: 15),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
SizedBox(height: 20,),
|
||||
buildShopName(context),
|
||||
SizedBox(
|
||||
height: 14,
|
||||
),
|
||||
buildShopLogo(context),
|
||||
SizedBox(
|
||||
height: 14,
|
||||
),
|
||||
buildShopPhone(context),
|
||||
SizedBox(
|
||||
height: 14,
|
||||
),buildShopAddress(context),
|
||||
SizedBox(
|
||||
height: 14,
|
||||
),
|
||||
buildShopTitle(context),
|
||||
SizedBox(
|
||||
height: 14,
|
||||
),
|
||||
buildShopDes(context),
|
||||
SizedBox(height: 14,),
|
||||
|
||||
Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: List.generate(_errors.length, (index) => Text(_errors[index],style: TextStyle(fontSize: 15,color: MyTheme.red),)),
|
||||
),
|
||||
SizedBox(height: 20,),
|
||||
SubmitBtn.show(
|
||||
radius:6,
|
||||
elevation: 5,
|
||||
alignment: Alignment.center,
|
||||
width: DeviceInfo(context).getWidth(),
|
||||
backgroundColor: MyTheme.app_accent_color,
|
||||
height: 48,
|
||||
padding: EdgeInsets.zero,
|
||||
onTap: (){
|
||||
formValidation();
|
||||
if(_errors.isEmpty){
|
||||
updateInfo();
|
||||
}
|
||||
}, child: Text(LangText(context: context).getLocal()!.save_ucf,style: TextStyle(fontSize: 17,color: MyTheme.white),)),
|
||||
SizedBox(height: 20,),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Column buildShopDes(BuildContext context) {
|
||||
return Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
LangText(context: context)
|
||||
.getLocal()!
|
||||
.shop_description,
|
||||
style: TextStyle(
|
||||
fontSize: 12,
|
||||
color: MyTheme.font_grey,
|
||||
fontWeight: FontWeight.bold),
|
||||
),
|
||||
SizedBox(
|
||||
height: 10,
|
||||
),
|
||||
MyWidget.customCardView(
|
||||
|
||||
width: DeviceInfo(context).getWidth(),
|
||||
backgroundColor: MyTheme.white,
|
||||
|
||||
height: 80,
|
||||
|
||||
padding: EdgeInsets.symmetric(horizontal: 6,vertical: 6),
|
||||
borderColor: MyTheme.noColor,
|
||||
borderRadius: 6,
|
||||
child: TextField(
|
||||
controller: descriptionEditingController,
|
||||
decoration: InputDecoration.collapsed(hintText: "There are many variations of passages of Lorem Ipsum available, but the majority have suffered alteration in some form, by injected humour, or randomised words which don't look even slightly believable",hintStyle: TextStyle(color: MyTheme.grey_153,fontSize: 12)),
|
||||
maxLines: 6,
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
Column buildShopTitle(BuildContext context) {
|
||||
return Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
LangText(context: context)
|
||||
.getLocal()!
|
||||
.shop_title,
|
||||
style: TextStyle(
|
||||
fontSize: 12,
|
||||
color: MyTheme.font_grey,
|
||||
fontWeight: FontWeight.bold),
|
||||
),
|
||||
SizedBox(
|
||||
height: 10,
|
||||
),
|
||||
MyWidget.customCardView(
|
||||
height: 40,
|
||||
width: DeviceInfo(context).getWidth(),
|
||||
backgroundColor: MyTheme.white,
|
||||
borderRadius: 10,
|
||||
child: TextField(
|
||||
controller: titleEditingController,
|
||||
decoration: InputDecorations.buildInputDecoration_1(
|
||||
hint_text: "Filon Asset Store",
|
||||
borderColor: MyTheme.noColor,
|
||||
hintTextColor: MyTheme.grey_153),
|
||||
),
|
||||
),
|
||||
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
Column buildShopPhone(BuildContext context) {
|
||||
return Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
LangText(context: context)
|
||||
.getLocal()!
|
||||
.shop_phone,
|
||||
style: TextStyle(
|
||||
fontSize: 12,
|
||||
color: MyTheme.font_grey,
|
||||
fontWeight: FontWeight.bold),
|
||||
),
|
||||
SizedBox(
|
||||
height: 10,
|
||||
),
|
||||
MyWidget.customCardView(
|
||||
elevation: 5,
|
||||
padding: EdgeInsets.symmetric(horizontal: 12,vertical: 10),
|
||||
borderWidth: 0,
|
||||
backgroundColor: MyTheme.white,
|
||||
height: 40,
|
||||
width: DeviceInfo(context).getWidth(),
|
||||
borderColor: MyTheme.light_grey,
|
||||
borderRadius: 6,
|
||||
child: TextField(
|
||||
controller: phoneEditingController,
|
||||
keyboardType: TextInputType.phone,
|
||||
decoration: InputDecoration.collapsed(hintText: "01.....",hintStyle: TextStyle(color: MyTheme.grey_153,fontSize: 12)),
|
||||
maxLines: 6,
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
Column buildShopAddress(BuildContext context) {
|
||||
return Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
LangText(context: context)
|
||||
.getLocal()!
|
||||
.shop_address,
|
||||
style: TextStyle(
|
||||
fontSize: 12,
|
||||
color: MyTheme.font_grey,
|
||||
fontWeight: FontWeight.bold),
|
||||
),
|
||||
SizedBox(
|
||||
height: 10,
|
||||
),
|
||||
MyWidget.customCardView(
|
||||
alignment: Alignment.center,
|
||||
backgroundColor: MyTheme.white,
|
||||
elevation: 5,
|
||||
height:65,
|
||||
padding: EdgeInsets.symmetric(vertical: 6,horizontal: 6),
|
||||
width: DeviceInfo(context).getWidth(),
|
||||
borderColor: MyTheme.light_grey,
|
||||
borderRadius: 6,
|
||||
child: TextField(
|
||||
|
||||
controller: addressEditingController,
|
||||
decoration: InputDecoration.collapsed(hintText: "1348 Fancher Drive Dallas, TX 75225",hintStyle: TextStyle(color: MyTheme.grey_153,fontSize: 12)),
|
||||
maxLines: 6,
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
Column buildShopName(BuildContext context) {
|
||||
return Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
LangText(context: context)
|
||||
.getLocal()!
|
||||
.shop_name_ucf,
|
||||
style: TextStyle(
|
||||
fontSize: 12,
|
||||
color: MyTheme.font_grey,
|
||||
fontWeight: FontWeight.bold),
|
||||
),
|
||||
SizedBox(
|
||||
height: 10,
|
||||
),
|
||||
MyWidget.customCardView(
|
||||
backgroundColor: MyTheme.white,
|
||||
width: DeviceInfo(context).getWidth(),
|
||||
height: 45,
|
||||
borderRadius: 10,
|
||||
elevation: 5,
|
||||
child: TextField(
|
||||
controller: nameEditingController,
|
||||
decoration: InputDecorations.buildInputDecoration_1(
|
||||
hint_text: "Filon Asset Store",
|
||||
borderColor: MyTheme.light_grey,
|
||||
hintTextColor: MyTheme.grey_153),
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
Widget buildShopLogo(BuildContext context) {
|
||||
return Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
LangText(context: context)
|
||||
.getLocal()!
|
||||
.shop_logo_ucf,
|
||||
style: TextStyle(
|
||||
fontSize: 12,
|
||||
color: MyTheme.font_grey,
|
||||
fontWeight: FontWeight.bold),
|
||||
),
|
||||
SizedBox(
|
||||
height: 10,
|
||||
),
|
||||
InkWell(
|
||||
onTap: (){
|
||||
//chooseAndUploadImage(context);
|
||||
},
|
||||
child:
|
||||
MyWidget.customCardView(
|
||||
backgroundColor: MyTheme.white,
|
||||
width: DeviceInfo(context).getWidth(),
|
||||
height: 36,
|
||||
borderRadius: 6,
|
||||
elevation: 5,
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(left: 14.0),
|
||||
child: Text(
|
||||
"Choose file",
|
||||
style: TextStyle(fontSize: 12, color: MyTheme.grey_153),
|
||||
),
|
||||
),
|
||||
Container(
|
||||
alignment: Alignment.center,
|
||||
height: 36,
|
||||
width: 80,
|
||||
decoration: BoxDecoration(
|
||||
color: MyTheme.light_grey,
|
||||
borderRadius: BorderRadius.only(bottomRight: Radius.circular(6),topRight: Radius.circular(6),)
|
||||
),
|
||||
child: Text(
|
||||
"Browse",
|
||||
style: TextStyle(fontSize: 12, color: MyTheme.grey_153),
|
||||
)),
|
||||
],
|
||||
)),
|
||||
),
|
||||
SizedBox(height: 6,),
|
||||
Visibility(
|
||||
visible: avatar_original!.isNotEmpty,
|
||||
child: MyWidget.customCardView(
|
||||
height: 120,width: 120,
|
||||
elevation: 5,
|
||||
backgroundColor: MyTheme.white,
|
||||
child: Stack(
|
||||
children: [
|
||||
|
||||
MyWidget.imageWithPlaceholder(height: 120.0,width: 120.0,url: avatar_original),
|
||||
Positioned(
|
||||
child: InkWell(
|
||||
onTap: (){
|
||||
avatar_original="";
|
||||
_imageId = "";
|
||||
setState(() {
|
||||
});
|
||||
},
|
||||
child: Icon(Icons.close,size: 15,color: MyTheme.red,),),
|
||||
top: 0,
|
||||
right: 5,
|
||||
),
|
||||
],
|
||||
),
|
||||
)),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
loadingShow(BuildContext myContext){
|
||||
return showDialog(
|
||||
//barrierDismissible: false,
|
||||
context: myContext,
|
||||
builder: (BuildContext context) {
|
||||
loadingContext = context;
|
||||
return AlertDialog(
|
||||
content: Row(
|
||||
children: [
|
||||
CircularProgressIndicator(),
|
||||
SizedBox(
|
||||
width: 10,
|
||||
),
|
||||
Text("${LangText(context: context).getLocal()!.please_wait_ucf}"),
|
||||
],
|
||||
));
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,209 @@
|
||||
import 'package:active_ecommerce_seller_app/custom/buttons.dart';
|
||||
import 'package:active_ecommerce_seller_app/custom/device_info.dart';
|
||||
import 'package:active_ecommerce_seller_app/custom/localization.dart';
|
||||
import 'package:active_ecommerce_seller_app/custom/my_app_bar.dart';
|
||||
import 'package:active_ecommerce_seller_app/custom/route_transaction.dart';
|
||||
import 'package:active_ecommerce_seller_app/custom/toast_component.dart';
|
||||
import 'package:active_ecommerce_seller_app/helpers/file_helper.dart';
|
||||
import 'package:active_ecommerce_seller_app/helpers/shared_value_helper.dart';
|
||||
import 'package:active_ecommerce_seller_app/my_theme.dart';
|
||||
import 'package:active_ecommerce_seller_app/repositories/file_upload_repository.dart';
|
||||
import 'package:active_ecommerce_seller_app/repositories/profile_repository.dart';
|
||||
import 'package:active_ecommerce_seller_app/screens/shop_settings/shop_banner_settings.dart';
|
||||
import 'package:active_ecommerce_seller_app/screens/shop_settings/shop_delivery_boy_pickup_point_setting.dart';
|
||||
import 'package:active_ecommerce_seller_app/screens/shop_settings/shop_general_setting.dart';
|
||||
import 'package:active_ecommerce_seller_app/screens/shop_settings/shop_social_media_setting.dart';
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_gen/gen_l10n/app_localizations.dart';
|
||||
|
||||
class ShopSettings extends StatefulWidget {
|
||||
const ShopSettings({Key? key}) : super(key: key);
|
||||
|
||||
@override
|
||||
_ShopSettingsState createState() => _ShopSettingsState();
|
||||
}
|
||||
|
||||
class _ShopSettingsState extends State<ShopSettings> {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
appBar: MyAppBar(
|
||||
title: AppLocalizations.of(context)!.shop_settings_ucf,
|
||||
context: context)
|
||||
.show(),
|
||||
body: SingleChildScrollView(
|
||||
child: Container(
|
||||
padding: EdgeInsets.symmetric(horizontal: 15),
|
||||
child: Column(
|
||||
children: [
|
||||
SizedBox(
|
||||
height: 20,
|
||||
),
|
||||
Buttons(
|
||||
color: MyTheme.app_accent_color,
|
||||
width: DeviceInfo(context).getWidth(),
|
||||
height: 75,
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(10)),
|
||||
onPressed: () {
|
||||
MyTransaction(context: context).push(ShopGeneralSetting());
|
||||
},
|
||||
child: Container(
|
||||
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(right: 8.0,left: 4),
|
||||
child: Image.asset("assets/icon/general_setting.png",height: 17,width: 17,),
|
||||
),
|
||||
|
||||
Text(
|
||||
LangText(context: context)
|
||||
.getLocal()!
|
||||
.general_setting_ucf,
|
||||
style: TextStyle(
|
||||
fontSize: 14,
|
||||
color: MyTheme.white,
|
||||
fontWeight: FontWeight.bold),
|
||||
),
|
||||
Spacer(),
|
||||
Icon(
|
||||
Icons.navigate_next_rounded,
|
||||
size: 20,
|
||||
color: MyTheme.white,
|
||||
)
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
|
||||
|
||||
Visibility(
|
||||
visible: delivery_boy_addon.$,
|
||||
child: Column(
|
||||
children: [
|
||||
SizedBox(
|
||||
height: 20,
|
||||
),
|
||||
Buttons(
|
||||
color: MyTheme.app_accent_color,
|
||||
width: DeviceInfo(context).getWidth(),
|
||||
height: 75,
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(10)),
|
||||
onPressed: () {
|
||||
MyTransaction(context: context)
|
||||
.push(ShopDeliveryBoyPickupPoint());
|
||||
},
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(right: 8.0,left: 4),
|
||||
child: Image.asset("assets/icon/delivery_boy_setting.png",height: 17,width: 17,),
|
||||
),
|
||||
Text(
|
||||
LangText(context: context)
|
||||
.getLocal()!
|
||||
.delivery_boy_pickup_point,
|
||||
style: TextStyle(
|
||||
fontSize: 14,
|
||||
color: MyTheme.white,
|
||||
fontWeight: FontWeight.bold),
|
||||
),
|
||||
Spacer(),
|
||||
Icon(
|
||||
Icons.navigate_next_rounded,
|
||||
size: 20,
|
||||
color: MyTheme.white,
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
SizedBox(
|
||||
height: 20,
|
||||
),
|
||||
Buttons(
|
||||
color: MyTheme.app_accent_color,
|
||||
width: DeviceInfo(context).getWidth(),
|
||||
height: 75,
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(10)),
|
||||
onPressed: () {
|
||||
MyTransaction(context: context).push(ShopBannerSettings());
|
||||
},
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(right: 8.0,left: 4),
|
||||
child: Image.asset("assets/icon/banner_setting.png",height: 17,width: 17,),
|
||||
),
|
||||
|
||||
Text(
|
||||
LangText(context: context)
|
||||
.getLocal()!
|
||||
.banner_settings,
|
||||
style: TextStyle(
|
||||
fontSize: 14,
|
||||
color: MyTheme.white,
|
||||
fontWeight: FontWeight.bold),
|
||||
),
|
||||
Spacer(),
|
||||
Icon(
|
||||
Icons.navigate_next_rounded,
|
||||
size: 20,
|
||||
color: MyTheme.white,
|
||||
)
|
||||
],
|
||||
)),
|
||||
SizedBox(
|
||||
height: 20,
|
||||
),
|
||||
Buttons(
|
||||
color: MyTheme.app_accent_color,
|
||||
width: DeviceInfo(context).getWidth(),
|
||||
height: 75,
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(10)),
|
||||
onPressed: () {
|
||||
MyTransaction(context: context)
|
||||
.push(ShopSocialMedialSetting());
|
||||
},
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(right: 8.0,left: 4),
|
||||
child: Image.asset("assets/icon/social_setting.png",height: 17,width: 17,),
|
||||
),
|
||||
|
||||
Text(
|
||||
LangText(context: context)
|
||||
.getLocal()!
|
||||
.social_media_link,
|
||||
style: TextStyle(
|
||||
fontSize: 14,
|
||||
color: MyTheme.white,
|
||||
fontWeight: FontWeight.bold),
|
||||
),
|
||||
Spacer(),
|
||||
Icon(
|
||||
Icons.navigate_next_rounded,
|
||||
size: 20,
|
||||
color: MyTheme.white,
|
||||
)
|
||||
],
|
||||
)),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,385 @@
|
||||
import 'dart:convert';
|
||||
|
||||
import 'package:active_ecommerce_seller_app/custom/buttons.dart';
|
||||
import 'package:active_ecommerce_seller_app/custom/device_info.dart';
|
||||
import 'package:active_ecommerce_seller_app/custom/input_decorations.dart';
|
||||
import 'package:active_ecommerce_seller_app/custom/localization.dart';
|
||||
import 'package:active_ecommerce_seller_app/custom/my_app_bar.dart';
|
||||
import 'package:active_ecommerce_seller_app/custom/my_widget.dart';
|
||||
import 'package:active_ecommerce_seller_app/custom/toast_component.dart';
|
||||
import 'package:active_ecommerce_seller_app/my_theme.dart';
|
||||
import 'package:active_ecommerce_seller_app/repositories/shop_repository.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:toast/toast.dart';
|
||||
|
||||
class ShopSocialMedialSetting extends StatefulWidget {
|
||||
const ShopSocialMedialSetting({Key? key}) : super(key: key);
|
||||
|
||||
@override
|
||||
State<ShopSocialMedialSetting> createState() =>
|
||||
_ShopSocialMedialSettingState();
|
||||
}
|
||||
|
||||
class _ShopSocialMedialSettingState extends State<ShopSocialMedialSetting> {
|
||||
TextEditingController facebookEditController = TextEditingController();
|
||||
TextEditingController instagramEditController = TextEditingController();
|
||||
TextEditingController twitterEditController = TextEditingController();
|
||||
TextEditingController googleEditController = TextEditingController();
|
||||
TextEditingController youtubeEditController = TextEditingController();
|
||||
|
||||
|
||||
late BuildContext loadingContext;
|
||||
|
||||
|
||||
Future<bool> _getAccountInfo() async {
|
||||
var response = await ShopRepository().getShopInfo();
|
||||
Navigator.pop(loadingContext);
|
||||
facebookEditController.text=response.shopInfo!.facebook!;
|
||||
instagramEditController.text=response.shopInfo!.instagram;
|
||||
twitterEditController.text=response.shopInfo!.twitter!;
|
||||
googleEditController.text=response.shopInfo!.google!;
|
||||
youtubeEditController.text=response.shopInfo!.youtube!;
|
||||
|
||||
setState(() {});
|
||||
return true;
|
||||
}
|
||||
|
||||
faceData(){
|
||||
WidgetsBinding.instance
|
||||
.addPostFrameCallback((_) => loadingShow(context));
|
||||
_getAccountInfo();
|
||||
}
|
||||
|
||||
|
||||
|
||||
updateInfo()async{
|
||||
var postBody = jsonEncode({
|
||||
"facebook": facebookEditController.text.trim().toString(),
|
||||
"instagram": instagramEditController.text.trim().toString(),
|
||||
"google": googleEditController.text.trim().toString(),
|
||||
"twitter": twitterEditController.text.trim().toString(),
|
||||
"youtube": youtubeEditController.text.trim().toString(),
|
||||
});
|
||||
loadingShow(context);
|
||||
var response = await ShopRepository().updateShopSetting(postBody);
|
||||
Navigator.pop(loadingContext);
|
||||
|
||||
|
||||
ToastComponent.showDialog(response.message,
|
||||
bgColor: MyTheme.white, duration: Toast.lengthLong, gravity: Toast.center);
|
||||
|
||||
|
||||
}
|
||||
|
||||
Future onRefresh(){
|
||||
faceData();
|
||||
return Future.delayed(Duration(seconds: 0));
|
||||
}
|
||||
|
||||
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
faceData();
|
||||
// TODO: implement initState
|
||||
super.initState();
|
||||
}
|
||||
|
||||
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
appBar: MyAppBar(
|
||||
context: context,
|
||||
title: LangText(context: context)
|
||||
.getLocal()!
|
||||
.social_media_link)
|
||||
.show(),
|
||||
body: RefreshIndicator(
|
||||
onRefresh: onRefresh,
|
||||
child: SingleChildScrollView(
|
||||
physics: AlwaysScrollableScrollPhysics(),
|
||||
child: Container(
|
||||
padding: EdgeInsets.symmetric(horizontal: 15),
|
||||
child: Column(
|
||||
children: [
|
||||
SizedBox(height: 20,),
|
||||
buildFacebookContainer(context),
|
||||
SizedBox(
|
||||
height: 14,
|
||||
),
|
||||
buildInstagram(context),
|
||||
SizedBox(
|
||||
height: 14,
|
||||
),
|
||||
buildTwitter(context),
|
||||
SizedBox(
|
||||
height: 14,
|
||||
),
|
||||
buildGoogle(context),
|
||||
SizedBox(
|
||||
height: 14,
|
||||
),
|
||||
buildYoutube(context),
|
||||
SizedBox(
|
||||
height: 30,
|
||||
),
|
||||
Buttons(
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(6)),
|
||||
width: DeviceInfo(context).getWidth(),
|
||||
color: MyTheme.app_accent_color,
|
||||
height: 48,
|
||||
padding: EdgeInsets.zero,
|
||||
onPressed: () {
|
||||
updateInfo();
|
||||
},
|
||||
child: Text(
|
||||
LangText(context: context).getLocal()!.save_ucf,
|
||||
style: TextStyle(fontSize: 17, color: MyTheme.white),
|
||||
)),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Column buildYoutube(BuildContext context) {
|
||||
return Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
LangText(context: context)
|
||||
.getLocal()!
|
||||
.youtube_ucf,
|
||||
style: TextStyle(
|
||||
fontSize: 12,
|
||||
color: MyTheme.font_grey,
|
||||
fontWeight: FontWeight.bold),
|
||||
),
|
||||
SizedBox(
|
||||
height: 10,
|
||||
),
|
||||
MyWidget.customCardView(
|
||||
backgroundColor: MyTheme.white,
|
||||
width: DeviceInfo(context).getWidth(),
|
||||
height: 45,
|
||||
borderRadius: 10,
|
||||
elevation: 5,
|
||||
child: TextField(
|
||||
controller: youtubeEditController,
|
||||
decoration: InputDecorations.buildInputDecoration_1(
|
||||
hint_text: LangText(context: context)
|
||||
.getLocal()!
|
||||
.youtube_ucf,
|
||||
borderColor: MyTheme.light_grey,
|
||||
hintTextColor: MyTheme.grey_153),
|
||||
),
|
||||
),
|
||||
SizedBox(
|
||||
height: 10,
|
||||
),
|
||||
Text(
|
||||
"Insert link with https",
|
||||
style: TextStyle(fontSize: 8, color: MyTheme.grey_153),
|
||||
)
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
Column buildGoogle(BuildContext context) {
|
||||
return Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
LangText(context: context)
|
||||
.getLocal()!
|
||||
.google_ucf,
|
||||
style: TextStyle(
|
||||
fontSize: 12,
|
||||
color: MyTheme.font_grey,
|
||||
fontWeight: FontWeight.bold),
|
||||
),
|
||||
SizedBox(
|
||||
height: 10,
|
||||
),
|
||||
MyWidget.customCardView(
|
||||
backgroundColor: MyTheme.white,
|
||||
width: DeviceInfo(context).getWidth(),
|
||||
height: 45,
|
||||
borderRadius: 10,
|
||||
elevation: 5,
|
||||
child: TextField(
|
||||
controller: googleEditController,
|
||||
decoration: InputDecorations.buildInputDecoration_1(
|
||||
hint_text: LangText(context: context)
|
||||
.getLocal()!
|
||||
.google_ucf,
|
||||
borderColor: MyTheme.light_grey,
|
||||
hintTextColor: MyTheme.grey_153),
|
||||
),
|
||||
),
|
||||
SizedBox(
|
||||
height: 10,
|
||||
),
|
||||
Text(
|
||||
"Insert link with https",
|
||||
style: TextStyle(fontSize: 8, color: MyTheme.grey_153),
|
||||
)
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
Column buildTwitter(BuildContext context) {
|
||||
return Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
LangText(context: context)
|
||||
.getLocal()!
|
||||
.twitter_ucf,
|
||||
style: TextStyle(
|
||||
fontSize: 12,
|
||||
color: MyTheme.font_grey,
|
||||
fontWeight: FontWeight.bold),
|
||||
),
|
||||
SizedBox(
|
||||
height: 10,
|
||||
),
|
||||
MyWidget.customCardView(
|
||||
backgroundColor: MyTheme.white,
|
||||
width: DeviceInfo(context).getWidth(),
|
||||
height: 45,
|
||||
borderRadius: 10,
|
||||
elevation: 5,
|
||||
child: TextField(
|
||||
controller: twitterEditController,
|
||||
decoration: InputDecorations.buildInputDecoration_1(
|
||||
hint_text: LangText(context: context)
|
||||
.getLocal()!
|
||||
.twitter_ucf,
|
||||
borderColor: MyTheme.light_grey,
|
||||
hintTextColor: MyTheme.grey_153),
|
||||
),
|
||||
),
|
||||
SizedBox(
|
||||
height: 10,
|
||||
),
|
||||
Text(
|
||||
"Insert link with https",
|
||||
style: TextStyle(fontSize: 8, color: MyTheme.grey_153),
|
||||
)
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
Column buildInstagram(BuildContext context) {
|
||||
return Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
LangText(context: context)
|
||||
.getLocal()!
|
||||
.instagram_ucf,
|
||||
style: TextStyle(
|
||||
fontSize: 12,
|
||||
color: MyTheme.font_grey,
|
||||
fontWeight: FontWeight.bold),
|
||||
),
|
||||
SizedBox(
|
||||
height: 10,
|
||||
),
|
||||
MyWidget.customCardView(
|
||||
backgroundColor: MyTheme.white,
|
||||
width: DeviceInfo(context).getWidth(),
|
||||
height: 45,
|
||||
borderRadius: 10,
|
||||
elevation: 5,
|
||||
child: TextField(
|
||||
controller: instagramEditController,
|
||||
decoration: InputDecorations.buildInputDecoration_1(
|
||||
hint_text: LangText(context: context)
|
||||
.getLocal()!
|
||||
.instagram_ucf,
|
||||
borderColor: MyTheme.light_grey,
|
||||
hintTextColor: MyTheme.grey_153),
|
||||
),
|
||||
),
|
||||
SizedBox(
|
||||
height: 10,
|
||||
),
|
||||
Text(
|
||||
"Insert link with https",
|
||||
style: TextStyle(fontSize: 8, color: MyTheme.grey_153),
|
||||
)
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
Column buildFacebookContainer(BuildContext context) {
|
||||
return Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
LangText(context: context)
|
||||
.getLocal()!
|
||||
.facebook_ucf,
|
||||
style: TextStyle(
|
||||
fontSize: 12,
|
||||
color: MyTheme.font_grey,
|
||||
fontWeight: FontWeight.bold),
|
||||
),
|
||||
SizedBox(
|
||||
height: 10,
|
||||
),
|
||||
MyWidget.customCardView(
|
||||
backgroundColor: MyTheme.white,
|
||||
width: DeviceInfo(context).getWidth(),
|
||||
height: 45,
|
||||
borderRadius: 10,
|
||||
elevation: 5,
|
||||
child: TextField(
|
||||
controller: facebookEditController,
|
||||
decoration: InputDecorations.buildInputDecoration_1(
|
||||
hint_text: LangText(context: context)
|
||||
.getLocal()!
|
||||
.facebook_ucf,
|
||||
borderColor: MyTheme.light_grey,
|
||||
hintTextColor: MyTheme.grey_153),
|
||||
),
|
||||
),
|
||||
SizedBox(
|
||||
height: 10,
|
||||
),
|
||||
Text(
|
||||
"Insert link with https",
|
||||
style: TextStyle(fontSize: 8, color: MyTheme.grey_153),
|
||||
)
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
loadingShow(BuildContext myContext){
|
||||
return showDialog(
|
||||
//barrierDismissible: false,
|
||||
context: myContext,
|
||||
builder: (BuildContext context) {
|
||||
loadingContext = context;
|
||||
return AlertDialog(
|
||||
content: Row(
|
||||
children: [
|
||||
CircularProgressIndicator(),
|
||||
SizedBox(
|
||||
width: 10,
|
||||
),
|
||||
Text("${LangText(context: context).getLocal()!.please_wait_ucf}"),
|
||||
],
|
||||
));
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user