Nuevos cambios hechos de diseño

This commit is contained in:
ellecio2
2023-08-23 17:33:44 -04:00
parent 7a806f84ff
commit d2e9ba53ab
3485 changed files with 691106 additions and 0 deletions

View File

@@ -0,0 +1,474 @@
import 'dart:convert';
import 'package:active_ecommerce_seller_app/custom/buttons.dart';
import 'package:active_ecommerce_seller_app/custom/localization.dart';
import 'package:active_ecommerce_seller_app/custom/my_widget.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/data_model/shop_info_response.dart';
import 'package:active_ecommerce_seller_app/helpers/shared_value_helper.dart';
import 'package:active_ecommerce_seller_app/helpers/shimmer_helper.dart';
import 'package:active_ecommerce_seller_app/helpers/shop_info_helper.dart';
import 'package:active_ecommerce_seller_app/my_theme.dart';
import 'package:active_ecommerce_seller_app/repositories/auth_repository.dart';
import 'package:active_ecommerce_seller_app/repositories/shop_repository.dart';
import 'package:active_ecommerce_seller_app/screens/change_language.dart';
import 'package:active_ecommerce_seller_app/screens/commission_history.dart';
import 'package:active_ecommerce_seller_app/screens/login.dart';
import 'package:active_ecommerce_seller_app/screens/main.dart';
import 'package:active_ecommerce_seller_app/screens/orders.dart';
import 'package:active_ecommerce_seller_app/screens/product/products.dart';
import 'package:active_ecommerce_seller_app/screens/profile.dart';
import 'package:active_ecommerce_seller_app/screens/uploads/upload_file.dart';
import 'package:active_ecommerce_seller_app/screens/whole_sale_product/products.dart';
import 'package:flutter/material.dart';
import 'package:route_transitions/route_transitions.dart';
import 'package:toast/toast.dart';
class Account extends StatefulWidget {
const Account({Key? key}) : super(key: key);
@override
_AccountState createState() => _AccountState();
}
class _AccountState extends State<Account> with TickerProviderStateMixin{
late AnimationController controller;
Animation? animation;
bool? _verify=false;
bool _faceData= false;
String? _url="",_name="...",_email="...",_rating="...",_verified="..",_package="",_packageImg="";
Future<bool> _getAccountInfo() async {
ShopInfoHelper().setShopInfo();
setData();
return true;
}
getSellerPackage()async{
var _shopInfo = await ShopRepository().getShopInfo();
_package=_shopInfo.shopInfo!.sellerPackage;
_packageImg=_shopInfo.shopInfo!.sellerPackageImg;
print(_packageImg);
setState(() {
});
}
setData(){
//Map<String, dynamic> json = jsonDecode(shop_info.$.toString());
_url=shop_logo.$;
_name=shop_name.$;
_email=seller_email.$;
_verify=shop_verify.$;
_verified=_verify!?"Verified":"Unverified";
_rating=shop_rating.$;
_faceData = true;
setState(() {});
}
logoutReq()async{
var response = await AuthRepository().getLogoutResponse();
if(response.result!){
access_token.$="";
access_token.save();
is_logged_in.$=false;
is_logged_in.save();
Navigator.pushAndRemoveUntil(
context,
PageRouteBuilder(
pageBuilder: (context, animation, secondaryAnimation) => Login(),
transitionsBuilder:
(context, animation, secondaryAnimation, child) {
return FadeTransition(
opacity: animation,
child: child,
);
}),
(route) => false,
);
}else{
ToastComponent.showDialog(response.message!,
gravity: Toast.center,
duration: 3,
textStyle: TextStyle(color: MyTheme.black),
);
}
}
faceData(){
_getAccountInfo();
getSellerPackage();
}
loadData()async{
if(shop_name.$==""){
_getAccountInfo();
}else{
setData();
}
}
@override
void initState() {
if(seller_package_addon.$) {
getSellerPackage();
}
loadData();
controller = AnimationController(duration: Duration(seconds: 1), vsync: this);
animation = Tween(begin: 0.5, end: 1.0).animate(controller);
super.initState();
}
@override
Widget build(BuildContext context) {
return Container(
color: MyTheme.app_accent_color,
child: SafeArea(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
// This is the back button
buildBackButtonContainer(context),
Container(
color: MyTheme.app_accent_color_extra_light,
height: 1,
),
SizedBox(height: 20,),
//header
Container(
padding: EdgeInsets.symmetric(horizontal: 15),
child: Row(
children: [
MyWidget.roundImageWithPlaceholder(width: 48.0,height: 48.0,borderRadius:24.0,url: _url ,backgroundColor: MyTheme.noColor),
/*Container(
height: 48,
width: 48,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(24),
image: DecorationImage(
image: NetworkImage(
"https://demo.activeitzone.com/ecommerce_flutter_demo/public/uploads/all/999999999920220118113113.jpg"),
fit: BoxFit.cover)),
),*/
const SizedBox(width: 10,),
Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(""+_name.toString(),style: TextStyle(fontSize: 14,fontWeight: FontWeight.w500,color: MyTheme.white),),
Text(""+_email.toString(),style: TextStyle(fontSize: 12,fontWeight: FontWeight.w500,color: MyTheme.app_accent_border.withOpacity(0.8)),),
SizedBox(
height: 10,
),
Row(children: [
Image.asset('assets/icon/star.png',width: 16,height: 15,),
SizedBox(width: 5,),
Text(""+_rating!,style: TextStyle(fontSize: 12,color: MyTheme.app_accent_border),),
SizedBox(width: 10,),
// MyWidget.roundImageWithPlaceholder(width: 16.0,height: 16.0,borderRadius:10.0,url: _verifiedImg ),
_faceData?Image.asset(_verify!?'assets/icon/verify.png':'assets/icon/unverify.png',width: 16,height: 15,):Container(),
SizedBox(width: 5,),
Text(_verified!,style: TextStyle(fontSize: 12,color: MyTheme.app_accent_border),),
seller_package_addon.$ && _package!.isNotEmpty?Row(
children: [
SizedBox(width: 10,),
MyWidget.roundImageWithPlaceholder(width: 16.0,height: 15.0,borderRadius:0.0,url: _packageImg,backgroundColor: MyTheme.noColor,fit: BoxFit.fill ),
SizedBox(width: 5,),
Text(_package!,style: TextStyle(fontSize: 12,color: MyTheme.app_accent_border),),
],
):Container(),
],)
],
)
],
),
),
SizedBox(height: 20,),
Container(
color: MyTheme.app_accent_color_extra_light,
height: 1,
),
// SizedBox(height: 20,),
Container(
color: MyTheme.app_accent_color,
height: 1,
),
SizedBox(height: 20,),
buildItemFeature(context),
SizedBox(height: 20,),
Container(
color: MyTheme.app_accent_color_extra_light,
height: 1,
),
Container(
padding: EdgeInsets.symmetric(horizontal: 15),
height: 80,
alignment: Alignment.center,
child: Container(
height: 40,
child: Buttons(
onPressed: (){
logoutReq();
},
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children:
[
Row(
children: [
Image.asset('assets/icon/logout.png',width: 16,height: 16,color: MyTheme.app_accent_border,),
SizedBox(width: 26,),
Text(LangText(context: context).getLocal()!.logout_ucf,style: TextStyle(fontSize: 14,color: MyTheme.white),),
],
),
Icon(Icons.navigate_next_rounded,size: 20,color: MyTheme.app_accent_border,)
],
),
),
),),
Container(
color: MyTheme.app_accent_color_extra_light,
height: 1,
),
],
),
),
);
}
Container buildBackButtonContainer(BuildContext context) {
return Container(
height: 47,
alignment: Alignment.topRight,
child: SizedBox(
width: 47,
child: Buttons(
padding: EdgeInsets.zero,
onPressed: () {
pop(context);
},
child: Icon(
Icons.close,
size: 24,
color: MyTheme.app_accent_border,
),
),
),
);
}
Widget buildItemFeature(BuildContext context) {
return Container(
padding: EdgeInsets.symmetric(horizontal: 15),
child: Column(
children: [
Container(
height: 40,
child: Buttons(
onPressed: (){
MyTransaction(context: context).push(ProfileEdit());
},
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children:
[
Row(
children: [
Image.asset('assets/icon/profile.png',width: 16,height: 16,color: MyTheme.app_accent_border,),
SizedBox(width: 26,),
Text(LangText(context: context).getLocal()!.profile_ucf,style: TextStyle(fontSize: 14,color: MyTheme.white),),
],
),
Icon(Icons.navigate_next_rounded,size: 20,color: MyTheme.app_accent_border,)
],
),
),
),
Container(
height: 40,
child: Buttons(
onPressed: (){
MyTransaction(context: context).push(ChangeLanguage());
},
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children:
[
Row(
children: [
Image.asset('assets/icon/language.png',width: 16,height: 16,color: MyTheme.app_accent_border,),
SizedBox(width: 26,),
Text(LangText(context: context).getLocal()!.change_language_ucf,style: TextStyle(fontSize: 14,color: MyTheme.white),),
],
),
Icon(Icons.navigate_next_rounded,size: 20,color: MyTheme.app_accent_border,)
],
),
),
),
Container(
height: 40,
child: Buttons(
onPressed: (){
Navigator.pushAndRemoveUntil(context,PageRouteBuilder(pageBuilder: (context,animation,secondaryAnimation)=>Main(),transitionsBuilder: (context,animation,secondaryAnimation,child){
return FadeTransition(opacity:animation,child: child, );
}), (route) => false,);
},
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children:
[
Row(
children: [
Image.asset('assets/icon/dashboard.png',width: 16,height: 16,color: MyTheme.app_accent_border,),
SizedBox(width: 26,),
Text(LangText(context: context).getLocal()!.dashboard_ucf,style: TextStyle(fontSize: 14,color: MyTheme.white),),
],
),
Icon(Icons.navigate_next_rounded,size: 20,color: MyTheme.app_accent_border,)
],
),
),
),
Container(
height: 40,
child: Buttons(
onPressed: (){
MyTransaction(context: context).push(Orders());
},
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Row(
children: [
Image.asset('assets/icon/orders.png',width: 16,height: 16,color: MyTheme.app_accent_border,),
SizedBox(width: 26,),
Text(LangText(context: context).getLocal()!.orders_ucf,style: TextStyle(fontSize: 14,color: MyTheme.white),),
],
),
Icon(Icons.navigate_next_rounded,size: 20,color: MyTheme.app_accent_border,)
],
),
),
),
SizedBox(
height: 40,
child: Buttons(
onPressed: (){
MyTransaction(context: context).push(const Products());
},
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Row(
children: [
Image.asset('assets/icon/products.png',width: 16,height: 16,color: MyTheme.app_accent_border),
SizedBox(width: 26,),
Text(LangText(context: context).getLocal()!.products_ucf,style: TextStyle(fontSize: 14,color: MyTheme.white),),
],
),
Icon(Icons.navigate_next_rounded,size: 20,color: MyTheme.app_accent_border,)
],
),
),
),
if(wholesale_addon_installed.$)
optionModel(LangText(context: context).getLocal()!.wholesale_products_ucf,'assets/icon/wholesale.png',const WholeSaleProducts()),
SizedBox(
height: 40,
child: Buttons(
onPressed: (){
MyTransaction(context: context).push(CommissionHistory());
},
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Row(
children: [
Image.asset('assets/icon/commission_history.png',width: 16,height: 16,color: MyTheme.app_accent_border),
SizedBox(width: 26,),
Text(LangText(context: context).getLocal()!.commission_history_ucf,style: TextStyle(fontSize: 14,color: MyTheme.white),),
],
),
Icon(Icons.navigate_next_rounded,size: 20,color: MyTheme.app_accent_border,)
],
),
),
),
SizedBox(
height: 40,
child: Buttons(
onPressed: (){
MyTransaction(context: context).push(UploadFile());
},
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Row(
children: [
Icon(Icons.upload_file,size: 16,color: MyTheme.app_accent_border,),
//Image.asset('assets/icon/commission_history.png',width: 16,height: 16,color: MyTheme.app_accent_border),
SizedBox(width: 26,),
Text(LangText(context: context).getLocal()!.upload_file_ucf,style: TextStyle(fontSize: 14,color: MyTheme.white),),
],
),
Icon(Icons.navigate_next_rounded,size: 20,color: MyTheme.app_accent_border,)
],
),
),
),
],
),
);
}
SizedBox optionModel(String title,String logo,Widget route) {
return SizedBox(
height: 40,
child: Buttons(
onPressed: (){
MyTransaction(context: context).push(route);
},
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Row(
children: [
Image.asset(logo,width: 16,height: 16,color: MyTheme.app_accent_border),
const SizedBox(width: 26,),
Text(title,style: TextStyle(fontSize: 14,color: MyTheme.white),),
],
),
const Icon(Icons.navigate_next_rounded,size: 20,color: MyTheme.app_accent_border,)
],
),
),
);
}
}

View File

@@ -0,0 +1,285 @@
import 'package:active_ecommerce_seller_app/custom/decorations.dart';
import 'package:active_ecommerce_seller_app/helpers/shared_value_helper.dart';
import 'package:active_ecommerce_seller_app/helpers/shimmer_helper.dart';
import 'package:active_ecommerce_seller_app/my_theme.dart';
import 'package:active_ecommerce_seller_app/providers/locale_provider.dart';
import 'package:active_ecommerce_seller_app/repositories/language_repository.dart';
import 'package:active_ecommerce_seller_app/screens/main.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:toast/toast.dart';
import 'package:provider/provider.dart';
import 'package:flutter_gen/gen_l10n/app_localizations.dart';
class ChangeLanguage extends StatefulWidget {
ChangeLanguage({Key? key}) : super(key: key);
@override
_ChangeLanguageState createState() => _ChangeLanguageState();
}
class _ChangeLanguageState extends State<ChangeLanguage> {
var _selected_index = 0;
ScrollController _mainScrollController = ScrollController();
var _list = [];
bool _isInitial = true;
@override
void initState() {
// TODO: implement initState
super.initState();
fetchList();
}
@override
void dispose() {
super.dispose();
_mainScrollController.dispose();
}
fetchList() async {
var languageListResponse = await LanguageRepository().getLanguageList();
_list.addAll(languageListResponse.languages!);
var idx = 0;
if (_list.length > 0) {
_list.forEach((lang) {
if (lang.code == app_language.$) {
setState(() {
_selected_index = idx;
});
}
idx++;
});
}
_isInitial = false;
setState(() {});
}
reset() {
_list.clear();
_isInitial = true;
_selected_index = 0;
setState(() {});
}
Future<void> _onRefresh() async {
reset();
fetchList();
}
onPopped(value) {
reset();
fetchList();
}
onLanguageItemTap(index) {
if (index != _selected_index) {
setState(() {
_selected_index = index;
});
// if(Locale().)
app_language.$ = _list[_selected_index].code;
app_language.save();
app_mobile_language.$ = _list[_selected_index].mobile_app_code;
app_mobile_language.save();
app_language_rtl.$ = _list[_selected_index].rtl;
app_language_rtl.save();
// var local_provider = new LocaleProvider();
// local_provider.setLocale(_list[_selected_index].code);
Provider.of<LocaleProvider>(context, listen: false)
.setLocale(_list[_selected_index].mobile_app_code);
Navigator.pushAndRemoveUntil(context, MaterialPageRoute(builder: (context) {
return Main();
}),(route)=>false);
}
}
@override
Widget build(BuildContext context) {
return Directionality(
textDirection: app_language_rtl.$! ? TextDirection.rtl : TextDirection.ltr,
child: Scaffold(
backgroundColor: Colors.white,
appBar: buildAppBar(context),
body: Stack(
children: [
RefreshIndicator(
color: MyTheme.app_accent_color,
backgroundColor: Colors.white,
onRefresh: _onRefresh,
displacement: 0,
child: CustomScrollView(
controller: _mainScrollController,
physics: const BouncingScrollPhysics(
parent: AlwaysScrollableScrollPhysics()),
slivers: [
SliverList(
delegate: SliverChildListDelegate([
Padding(
padding: const EdgeInsets.all(18.0),
child: buildLanguageMethodList(),
),
]),
)
],
),
),
],
)),
);
}
AppBar buildAppBar(BuildContext context) {
return AppBar(
backgroundColor: Colors.white,
centerTitle: false,
leading: Builder(
builder: (context) => IconButton(
padding: EdgeInsets.zero,
icon: Image.asset(
'assets/icon/back_arrow.png',
height: 20,
width: 20,
color: MyTheme.app_accent_color,
//color: MyTheme.dark_grey,
),
onPressed: () => Navigator.of(context).pop(),
),
),
title: Text(
"${AppLocalizations.of(context)!.change_language_ucf} (${app_language.$}) - (${app_mobile_language.$})",
style: TextStyle(fontSize: 16, color: MyTheme.dark_grey,fontWeight: FontWeight.bold),
),
elevation: 0.0,
titleSpacing: 0,
);
}
buildLanguageMethodList() {
if (_isInitial && _list.length == 0) {
return SingleChildScrollView(
child: ShimmerHelper()
.buildListShimmer(item_count: 5, item_height: 100.0));
} else if (_list.length > 0) {
return SingleChildScrollView(
child: ListView.separated(
separatorBuilder: (context, index) {
return SizedBox(
height: 14,
);
},
itemCount: _list.length,
scrollDirection: Axis.vertical,
physics: NeverScrollableScrollPhysics(),
shrinkWrap: true,
itemBuilder: (context, index) {
return buildPaymentMethodItemCard(index);
},
),
);
} else if (!_isInitial && _list.length == 0) {
return Container(
height: 100,
child: Center(
child: Text(
AppLocalizations.of(context)!.no_language_is_added,
style: TextStyle(color: MyTheme.font_grey),
)));
}
}
GestureDetector buildPaymentMethodItemCard(index) {
return GestureDetector(
onTap: () {
onLanguageItemTap(index);
},
child: Stack(
children: [
AnimatedContainer(
duration: Duration(milliseconds: 400),
decoration: MDecoration.decoration1().copyWith(
border: Border.all(
color: _selected_index == index
? MyTheme.app_accent_color
: MyTheme.light_grey,
width: _selected_index == index ? 1.0 : 0.0)),
child: Row(
mainAxisAlignment: MainAxisAlignment.start,
children: <Widget>[
Container(
width: 50,
height: 50,
child: Padding(
padding: const EdgeInsets.all(16.0),
child:
/*Image.asset(
_list[index].image,
fit: BoxFit.fitWidth,
),*/
FadeInImage.assetNetwork(
placeholder: 'assets/placeholder.png',
image: _list[index].image,
fit: BoxFit.fitWidth,
))),
Container(
width: 150,
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Padding(
padding: EdgeInsets.only(left: 8.0),
child: Text(
"${_list[index].name} - ${_list[index].code} - ${_list[index].mobile_app_code}",
textAlign: TextAlign.left,
overflow: TextOverflow.ellipsis,
maxLines: 2,
style: TextStyle(
color: MyTheme.font_grey,
fontSize: 14,
height: 1.6,
fontWeight: FontWeight.w400),
),
),
],
),
),
]),
),
app_language_rtl.$!
? Positioned(
left: 16,
top: 16,
child: buildCheckContainer(_selected_index == index),
)
: Positioned(
right: 16,
top: 16,
child: buildCheckContainer(_selected_index == index),
)
],
),
);
}
Container buildCheckContainer(bool check) {
return check
? Container(
height: 16,
width: 16,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(16.0), color: Colors.green),
child: Padding(
padding: const EdgeInsets.all(3),
child: Icon(Icons.check, color: Colors.white, size: 10),
),
)
: Container();
}
}

View File

@@ -0,0 +1,217 @@
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/route_transaction.dart';
import 'package:active_ecommerce_seller_app/data_model/chat_list_response.dart';
import 'package:active_ecommerce_seller_app/dummy_data/chatList.dart';
import 'package:active_ecommerce_seller_app/helpers/shimmer_helper.dart';
import 'package:active_ecommerce_seller_app/my_theme.dart';
import 'package:active_ecommerce_seller_app/repositories/chat_repository.dart';
import 'package:active_ecommerce_seller_app/screens/conversation.dart';
import 'package:flutter/material.dart';
import 'package:shimmer/shimmer.dart';
class ChatList extends StatefulWidget {
const ChatList({Key? key}) : super(key: key);
@override
State<ChatList> createState() => _ChatListState();
}
class _ChatListState extends State<ChatList> {
List<Chat> _chatList= [];
bool _faceData= false;
getCouponList() async {
var response = await ChatRepository().getChatList();
_chatList.addAll(response.data!);
_faceData=true;
setState(() {});
}
faceData() {
getCouponList();
}
clearData() {
_chatList = [];
_faceData=false;
}
Future<bool> resetData() async{
clearData();
faceData();
return true;
}
Future<void> refresh()async {
await resetData();
return Future.delayed(const Duration(seconds: 1));
}
@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()!.chat_list)
.show(),
body: RefreshIndicator(
onRefresh: refresh,
child: CustomScrollView(
slivers: [
SliverToBoxAdapter(
child: Container(
width: DeviceInfo(context).getWidth(),
//height: DeviceInfo(context).getHeight(),
padding: EdgeInsets.symmetric(horizontal: 15.0),
child: _faceData?buildChatListView():chatListShimmer(),
),
),
],
),
),
);
}
Widget chatListShimmer(){
return Column(
children: List.generate(20, (index) =>
Container(
margin: EdgeInsets.only(bottom: 10),
child: Row(
children: [
Shimmer.fromColors(
baseColor: MyTheme.shimmer_base,
highlightColor: MyTheme.shimmer_highlighted,
child: Container(
height: 35,
width: 35,
margin: EdgeInsets.only(right: 14),
decoration: BoxDecoration(
color: MyTheme.red,
borderRadius: BorderRadius.circular(30),
),
),
),
ShimmerHelper().buildBasicShimmer(height: 35,width: DeviceInfo(context).getWidth()-80),
],
),
)
),
);
}
Widget buildChatListView() {
return ListView.builder(
physics: NeverScrollableScrollPhysics(),
shrinkWrap: true,
itemCount: _chatList.length,
itemBuilder: (context, index) {
return Container(
width: 100,
child: buildChatItem(
index,
_chatList[index].id,
_chatList[index].name!,
_chatList[index].image,
_chatList[index].title,
true));
});
}
Widget buildChatItem(index,conversationId,String userName, img, sms, bool isActive) {
return Container(
margin: EdgeInsets.only(top:index==0?20:0,bottom: 20),
child: Buttons(
padding: EdgeInsets.zero,
onPressed: (){
MyTransaction(context: context).push(Conversation(id: conversationId,userImgUrl: img,name: userName,));
},
child: Row(
children: [
Container(
width: 35,
height: 35,
margin: EdgeInsets.only(right: 14),
child: Stack(
children: [
MyWidget.roundImageWithPlaceholder(elevation: 4,
borderWidth: 1,
url: img, width: 35.0, height: 35.0, fit: BoxFit.cover,borderRadius: 16),
Visibility(
visible: false,
child: Positioned(
right: 1,
top: 2,
child: MyWidget().myContainer(
height: 7,
width: 7,
borderRadius: 7,
borderColor: Colors.white,
bgColor: isActive ? Colors.green : MyTheme.grey_153,
borderWith: 1)),
)
],
),
),
Container(
width: DeviceInfo(context).getWidth() - 80,
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Container(
width: DeviceInfo(context).getWidth(),
child: Text(
userName,
maxLines: 1,
overflow: TextOverflow.ellipsis,
style: TextStyle(
fontSize: 14,
fontWeight: FontWeight.w500,
color: MyTheme.app_accent_color),
),
),
Container(
child: Text(
sms,
maxLines: 1,
overflow: TextOverflow.ellipsis,
style: TextStyle(
fontSize: 12,
fontWeight: FontWeight.normal,
color: MyTheme.grey_153,
),
),
),
],
),
),
],
),
),
);
}
}

View File

@@ -0,0 +1,196 @@
import 'package:active_ecommerce_seller_app/const/app_style.dart';
import 'package:active_ecommerce_seller_app/custom/device_info.dart';
import 'package:active_ecommerce_seller_app/custom/loading.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/data_model/commission_history_response.dart';
import 'package:active_ecommerce_seller_app/helpers/shimmer_helper.dart';
import 'package:active_ecommerce_seller_app/my_theme.dart';
import 'package:active_ecommerce_seller_app/repositories/commission_repository.dart';
import 'package:flutter/material.dart';
import 'package:flutter_gen/gen_l10n/app_localizations.dart';
class CommissionHistory extends StatefulWidget {
const CommissionHistory({Key? key}) : super(key: key);
@override
_CommissionHistoryState createState() => _CommissionHistoryState();
}
class _CommissionHistoryState extends State<CommissionHistory> {
List<Commission> _commission = [];
bool _isFetchAllData=false;
bool _showMoreCommissionLoading=false;
ScrollController _scrollController = new ScrollController(initialScrollOffset: 0);
int _page =1;
Future<bool> getCommissionList() async {
var response = await CommissionRepository().getList(page: _page);
_commission.addAll(response.data!);
_showMoreCommissionLoading=false;
setState(() {});
return true;
}
Future<bool> fetchData() async{
await getCommissionList();
_isFetchAllData = true;
setState(() {
});
return true;
}
clearData() {
_scrollController = new ScrollController(initialScrollOffset: 0);
_page=1;
_isFetchAllData= false;
_commission = [];
setState(() {
});
}
Future<bool> resetData() {
clearData();
return fetchData();
}
Future<void>refresh()async{
await resetData();
return Future.delayed(const Duration(seconds: 0));
}
scrollControllerPosition(){
_scrollController.addListener(() {
//print("position: " + _xcrollController.position.pixels.toString());
//print("max: " + _xcrollController.position.maxScrollExtent.toString());
if (_scrollController.position.pixels ==
_scrollController.position.maxScrollExtent) {
_showMoreCommissionLoading = true;
setState(() {
_page++;
});
getCommissionList();
}
});
}
@override
void initState() {
// TODO: implement initState
scrollControllerPosition();
fetchData();
super.initState();
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: MyAppBar(
title: AppLocalizations.of(context)!.commission_history_ucf,
context: context)
.show(),
body: RefreshIndicator(
onRefresh: refresh,
child: SingleChildScrollView(
controller: _scrollController,
child: Column(
children: [
Container(
child: _isFetchAllData
? commissionListContainer()
: ShimmerHelper()
.buildListShimmer(item_count: 20, item_height: 80.0),
),
],
),
),
),
);
}
Widget commissionListContainer() {
return Container(
padding: EdgeInsets.symmetric(horizontal: 15),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
ListView.builder(
physics: NeverScrollableScrollPhysics(),
itemCount: _commission.length+1,
shrinkWrap: true,
itemBuilder: (context, index) {
// print(index);
if(index==_commission.length){
return Loading.bottomLoading(_showMoreCommissionLoading);
}
return commissionItem(
index,
_commission[index].orderCode!,
_commission[index].adminCommission.toString(),
_commission[index].createdAt!,
_commission[index].sellerEarning.toString());
}),
],
),
);
}
Container commissionItem(int index,String orderCode,String adminCommission,String date,String sellerEarning){
return MyWidget.customCardView(
backgroundColor: MyTheme.app_accent_color_extra_light,
elevation: 5,
height: 90,
alignment: Alignment.center,
padding: EdgeInsets.symmetric(horizontal: 14,vertical: 14),
width: DeviceInfo(context).getWidth(),
margin: EdgeInsets.only(bottom: 20,top: index==0?20:0),
borderColor: MyTheme.light_grey,
borderRadius: 6,
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisAlignment: MainAxisAlignment.center,
children: [
Text(orderCode,style: TextStyle(fontSize: 13,fontWeight: FontWeight.bold,color: MyTheme.app_accent_color),maxLines: 1,overflow: TextOverflow.ellipsis,),
SizedBox(height: 5,),
Container(
width: DeviceInfo(context).getWidth(),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Container(
width: DeviceInfo(context).getWidth()/2,
child: Row(
children: [
Text(LangText(context: context).getLocal()!.admin_commission_ucf+" : "+adminCommission,style: TextStyle(fontSize: 12,color: MyTheme.app_accent_color,),maxLines:1,overflow: TextOverflow.ellipsis,),
],
),
),
Text(sellerEarning,style: TextStyle(fontSize: 16,color: MyTheme.app_accent_color,fontWeight: AppStyles.bold,)),
],
),
),
SizedBox(height: 5,),
Container(
width: DeviceInfo(context).getWidth()/3,
child: Row(
children: [
Image.asset("assets/icon/calender.png",width: 12,height: 12,),
SizedBox(width: 8,),
Text(date,style: TextStyle(fontSize: 12,color: MyTheme.grey_153,),maxLines:1,overflow: TextOverflow.ellipsis,),
],
),
),
],
)
) as Container;
}
}

View File

@@ -0,0 +1,442 @@
import 'dart:async';
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/data_model/messages_response.dart';
import 'package:active_ecommerce_seller_app/my_theme.dart';
import 'package:active_ecommerce_seller_app/repositories/chat_repository.dart';
import 'package:flutter/material.dart';
import 'package:flutter_gen/gen_l10n/app_localizations.dart';
import 'package:shimmer/shimmer.dart';
class Conversation extends StatefulWidget {
final id;
final userImgUrl;
final name;
const Conversation({Key? key, this.id, this.userImgUrl, this.name}) : super(key: key);
@override
_ConversationState createState() => _ConversationState();
}
class _ConversationState extends State<Conversation> {
List<Message> _messages = [];
bool _faceData = false;
Timer? timer;
TextEditingController messageTextController = TextEditingController();
String _messege = "";
getMessages() async {
var response = await ChatRepository().getMessages(widget.id);
_messages.addAll(response.data!);
_faceData = true;
setState(() {});
}
clearTypeSMSTextController(){
messageTextController.text ="";
setState(() {
});
}
sendMessage()async{
clearTypeSMSTextController();
var response = await ChatRepository().sendMessages(widget.id,_messege);
if(response.result!){
refresh();
}
}
faceData() {
getMessages();
}
clearData() {
_messages = [];
}
Future<bool> resetData() async {
clearData();
faceData();
return true;
}
Future<void> refresh() async {
print("refresh");
await resetData();
return Future.delayed(const Duration(seconds: 1));
}
@override
void initState() {
faceData();
timer = Timer.periodic(const Duration(seconds: 10), (Timer t) => refresh());
// TODO: implement initState
super.initState();
}
@override
void dispose() {
timer?.cancel();
super.dispose();
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: buildAppBar(context),
body: Stack(
children: [
_faceData ? conversations(): chatShimmer(),
typeSmsSection(),
],
),
);
}
AppBar buildAppBar(BuildContext context) {
return AppBar(
leadingWidth: 40,
centerTitle: false,
elevation: 8,
title: Container(
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Row(
children: [
Container(
width: 35,
height: 35,
margin: EdgeInsets.only(right: 14),
child: Stack(
children: [
MyWidget.roundImageWithPlaceholder(elevation: 4,
borderWidth: 1,
url: widget.userImgUrl, width: 35.0, height: 35.0, fit: BoxFit.cover,borderRadius: 16),
Visibility(
visible: false,
child: Positioned(
right: 1,
top: 2,
child: MyWidget().myContainer(
height: 7,
width: 7,
borderRadius: 7,
borderColor: Colors.white,
bgColor: true ? Colors.green : MyTheme.grey_153,
borderWith: 1)),
)
],
),
),
Container(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Container(
width: DeviceInfo(context).getWidth() / 3,
child: Text(
widget.name,
maxLines: 1,
overflow: TextOverflow.ellipsis,
style:const TextStyle(
fontSize: 14,
fontWeight: FontWeight.w500,
color: MyTheme.app_accent_color),
),
),
],
),
),
],
),
/*Row(
children: [
IconButton(
splashRadius: 20.0,
padding: EdgeInsets.zero,
onPressed: () {},
icon: Image.asset(
"assets/icon/audio_call.png",
width: 20,
height: 20,
)),
IconButton(
padding: EdgeInsets.zero,
splashRadius: 20.0,
onPressed: () {},
icon: Image.asset(
"assets/icon/video_call.png",
width: 20,
height: 20,
)),
],
),*/
],
),
),
backgroundColor: Colors.white,
leading: Container(
margin: EdgeInsets.only(left: 10),
child: Buttons(
padding: EdgeInsets.zero,
onPressed: () {
Navigator.pop(context);
},
child: Image.asset(
'assets/icon/back_arrow.png',
height: 20,
width: 20,
//color: MyTheme.dark_grey,
),
),
),
);
}
conversations() {
return SingleChildScrollView(
reverse: true,
child: Container(
margin:const EdgeInsets.only(bottom: 60),
child: ListView.builder(
reverse: true,
itemCount: _messages.length,
shrinkWrap: true,
padding: const EdgeInsets.only(top: 10, bottom: 10),
physics: const NeverScrollableScrollPhysics(),
itemBuilder: (context, index) {
//print(_messages[index+1].year.toString());
return Container(
padding:
const EdgeInsets.only(left: 14, right: 14, top: 10, bottom: 10),
//margin: EdgeInsets.only(right: messages[index].messageType == "receiver"?0:50,left:messages[index].messageType == "receiver"? 50:0),
child: Column(
children: [
(index==_messages.length-1) || _messages[index].year!=_messages[index+1].year || _messages[index].month!=_messages[index+1].month?
MyWidget().myContainer(
width: 100,
height: 20,
borderRadius: 5,
borderColor: MyTheme.light_grey,
child: Text(""+
_messages[index].date.toString(),
style:const TextStyle(fontSize: 8, color: Colors.grey),
),
):Container(),
const SizedBox(height: 5,),
Align(
alignment: (_messages[index].sendType=="seller"
? Alignment.topRight
: Alignment.topLeft),
child: smsContainer(index),
),
],
),
);
},
),
),
);
}
Container smsContainer(int index) {
return Container(
constraints: BoxConstraints(
minWidth: 80,
maxWidth: DeviceInfo(context).getWidth()/1.6,
),
padding: const EdgeInsets.only(top: 8, bottom: 3, right: 10, left: 10),
decoration: BoxDecoration(
border: Border.all(width: 1,color:MyTheme.noColor),
borderRadius: BorderRadius.only(
topLeft: Radius.circular(16),
topRight: Radius.circular(16),
bottomLeft:
_messages[index].sendType=="seller" ? Radius.circular(16) : Radius.circular(0),
bottomRight:
_messages[index].sendType=="seller" ? Radius.circular(0) : Radius.circular(16),
),
color: (_messages[index].sendType=="seller"
? MyTheme.app_accent_color
: MyTheme.app_accent_color_extra_light),
),
child: Stack(
children: [
Positioned(
bottom: 2,
right: _messages[index].sendType=="seller" ? 2 : null,
left: _messages[index].sendType=="seller" ? null : 2,
child: Text(_messages[index].dayOfMonth.toString()
+" "+_messages[index].time.toString(),
style: TextStyle(fontSize: 8, color: (_messages[index].sendType=="seller"
? MyTheme.light_grey
: MyTheme.grey_153),
),
)),
Padding(
padding: const EdgeInsets.only(bottom: 15.0),
child: Text(" "+
_messages[index].message.toString(),
style: TextStyle(fontSize: 12, color: (_messages[index].sendType=="seller"
? MyTheme.white
: Colors.black),
),
),)
],
),
);
}
Widget typeSmsSection() {
return Align(
alignment: Alignment.bottomLeft,
child: Container(
padding:const EdgeInsets.only(left: 10, bottom: 10, top: 10),
height: 60,
width: double.infinity,
color: MyTheme.white,
child: Row(
children: <Widget>[
Expanded(
child: Container(
padding:const EdgeInsets.only(left: 10, right: 10),
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(20),
color: MyTheme.app_accent_color_extra_light,
),
child: TextField(
onChanged: (text){
if(text.trim().isEmpty){
messageTextController.text="";
}
_messege = text.trim().toString();
setState(() {
});
},
controller: messageTextController,
decoration:const InputDecoration(
hintText: "Write message...",
hintStyle: TextStyle(color: Colors.black54),
border: InputBorder.none),
),
),
),
const SizedBox(
width: 15,
),
FloatingActionButton(
onPressed: messageTextController.text.trim().isNotEmpty?() {
print(_messege);
sendMessage();
}:null,
child:const Icon(
Icons.send,
color: Colors.white,
size: 18,
),
backgroundColor: MyTheme.app_accent_color,
elevation: 0,
),
],
),
),
);
}
chatShimmer(){
return SingleChildScrollView(
reverse: true,
child: Container(
margin:const EdgeInsets.only(bottom: 60),
child: ListView.builder(
reverse: true,
itemCount: 10,
shrinkWrap: true,
padding: const EdgeInsets.only(top: 10, bottom: 10),
physics: const NeverScrollableScrollPhysics(),
itemBuilder: (context, index) {
//print(_messages[index+1].year.toString());
return Container(
padding:
const EdgeInsets.only(left: 14, right: 14, top: 10, bottom: 10),
//margin: EdgeInsets.only(right: messages[index].messageType == "receiver"?0:50,left:messages[index].messageType == "receiver"? 50:0),
child: Align(
alignment: (index.isOdd
? Alignment.topRight
: Alignment.topLeft),
child: smsShimmer(index),
),
);
},
),
),
);
}
Widget smsShimmer(int index) {
return Shimmer.fromColors(
baseColor: MyTheme.shimmer_base,
highlightColor: MyTheme.shimmer_highlighted,
child: Container(
constraints: BoxConstraints(
minWidth: 150,
maxWidth: DeviceInfo(context).getWidth()/1.6,
),
padding: const EdgeInsets.only(top: 8, bottom: 3, right: 10, left: 10),
decoration: BoxDecoration(
border: Border.all(width: 1,color:index.isOdd? MyTheme.app_accent_color: MyTheme.grey_153),
borderRadius: BorderRadius.only(
topLeft: Radius.circular(16),
topRight: Radius.circular(16),
bottomLeft:
index.isOdd? Radius.circular(16) : Radius.circular(0),
bottomRight:
index.isOdd? Radius.circular(0) : Radius.circular(16),
),
color: (index.isOdd
? MyTheme.app_accent_color
: MyTheme.app_accent_color_extra_light),
),
child: Stack(
children: [
Positioned(
bottom: 2,
right: index.isOdd ? 2 : null,
left: index.isOdd ? null : 2,
child: Text(
" ",
style: TextStyle(fontSize: 8, color: (index.isOdd
? MyTheme.light_grey
: MyTheme.grey_153),
),
)),
Padding(
padding: const EdgeInsets.only(bottom: 15.0),
child: Text(" ",
style: TextStyle(fontSize: 12, color: (index.isOdd
? MyTheme.white
: Colors.black),
),
),)
],
),
),
);
}
}

View File

@@ -0,0 +1,287 @@
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/loading.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/route_transaction.dart';
import 'package:active_ecommerce_seller_app/custom/toast_component.dart';
import 'package:active_ecommerce_seller_app/data_model/coupon_list_response.dart';
import 'package:active_ecommerce_seller_app/dummy_data/coupons.dart';
import 'package:active_ecommerce_seller_app/helpers/shimmer_helper.dart';
import 'package:active_ecommerce_seller_app/my_theme.dart';
import 'package:active_ecommerce_seller_app/repositories/coupon_repository.dart';
import 'package:active_ecommerce_seller_app/screens/coupon/edit_coupon.dart';
import 'package:active_ecommerce_seller_app/screens/coupon/new_coupon.dart';
import 'package:flutter/material.dart';
import 'package:toast/toast.dart';
class Coupons extends StatefulWidget {
const Coupons({Key? key}) : super(key: key);
@override
State<Coupons> createState() => _CouponsState();
}
class _CouponsState extends State<Coupons> {
List<Coupon> _coupons = [];
Loading _loading = Loading();
bool _faceData=false;
getCouponList() async {
var response = await CouponRepository().getCoupons();
_coupons.addAll(response.data!);
print(_coupons.isEmpty);
_faceData=true;
setState(() {});
}
deleteCoupon(String id)async{
_loading.show();
var response =await CouponRepository().deleteCoupon(id);
_loading.hide();
if (response.result!){
ToastComponent.showDialog(response.message,bgColor: MyTheme.white,textStyle:TextStyle(color:MyTheme.black) ,gravity: Toast.center,duration: Toast.lengthLong);
refresh();
}
}
fetchData() {
getCouponList();
}
clearData() {
_coupons = [];
_faceData=false;
}
Future<bool> resetData() async{
clearData();
fetchData();
setState(() {});
return true;
}
Future<void> refresh()async {
await resetData();
return Future.delayed(Duration(seconds: 1));
}
@override
void initState() {
// TODO: implement initState
fetchData();
super.initState();
}
@override
Widget build(BuildContext context) {
Loading.setInstance(context);
return Scaffold(
appBar: MyAppBar(
context: context,
title: LangText(context: context).getLocal()!.coupons_ucf)
.show(),
body: RefreshIndicator(
onRefresh: refresh,
child: SingleChildScrollView(
physics: AlwaysScrollableScrollPhysics(),
child: Container(
padding: EdgeInsets.symmetric(horizontal: 15),
child: Column(
children: [
SizedBox(
height:20,
),
buildAddCouponContainer(context),
SizedBox(
height: 20,
),
_faceData?_coupons.isEmpty?Center(child: Text(LangText(context: context).getLocal()!.no_data_is_available),):
buildCouponsListView():buildShimmerList(context),
],
)),
),
),
);
}
Widget buildShimmerList(BuildContext context) {
return Column(
children: List.generate(
8,
(index) => Container(
margin: EdgeInsets.only(bottom: 20),
child:ShimmerHelper().buildBasicShimmer(
height: 96, width: DeviceInfo(context).getWidth()))),
);
}
ListView buildCouponsListView() {
return ListView.builder(
physics: NeverScrollableScrollPhysics(),
shrinkWrap: true,
itemCount: _coupons.length,
itemBuilder: (context, index) {
return buildCouponItem(index);
});
}
Widget buildCouponItem(int index) {
return MyWidget.customCardView(
backgroundColor: MyTheme.white,
elevation: 5,
margin: EdgeInsets.only(bottom: 20),
padding: EdgeInsets.symmetric(horizontal: 10, vertical: 10),
height: 96,
width: DeviceInfo(context).getWidth(),
borderColor: MyTheme.light_grey,
borderRadius: 10,
child: Row(
children: [
Container(
width: DeviceInfo(context).getWidth() - 85,
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: [
Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
_coupons[index].code!,
style: TextStyle(
fontSize: 20,
fontWeight: FontWeight.w500,
color: MyTheme.app_accent_color),
),
Text(
_coupons[index].type!,
style: TextStyle(
fontSize: 12,
fontWeight: FontWeight.normal,
color: MyTheme.app_accent_color),
),
],
),
Text(
_coupons[index].startDate!+"-"+_coupons[index].startDate!,
style: TextStyle(
fontSize: 11,
fontWeight: FontWeight.normal,
color: MyTheme.grey_153),
),
],
),
),
Column(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: [
InkWell(
onTap: () {
MyTransaction(context: context).push(EditCoupon(id:_coupons[index].id.toString())).then((value) => refresh());
},
child: MyWidget.customCardView(
padding: EdgeInsets.symmetric(horizontal: 8,vertical: 8),
borderRadius: 15,
height:30,
width: 30,
backgroundColor: MyTheme.app_accent_color,
child: Image.asset(
'assets/icon/edit.png',
width: 10,
height: 10,
fit: BoxFit.fill,
),
),
),
InkWell(
onTap: () {
showDeleteWarningDialog(_coupons[index].id.toString());
},
child: MyWidget.customCardView(
padding: EdgeInsets.symmetric(horizontal: 8,vertical: 8),
borderRadius: 15,
height:30,
width: 30,
backgroundColor: MyTheme.app_accent_color,
child: Image.asset(
'assets/icon/delete.png',
width: 10,
height: 10,
fit: BoxFit.fill,
),
),
),
],
)
],
),
);
}
Widget buildAddCouponContainer(BuildContext context) {
return InkWell(
onTap: () {
MyTransaction(context: context).push(NewCoupon()).then((value) {
refresh();
});
},
child: MyWidget().myContainer(
height: 75,
width: DeviceInfo(context).getWidth(),
borderRadius: 10,
bgColor: MyTheme.app_accent_color_extra_light,
borderColor: MyTheme.app_accent_color,
child: Column(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: [
Text(
LangText(context: context)
.getLocal()!
.add_new_coupon_ucf,
style: TextStyle(
fontWeight: FontWeight.bold,
fontSize: 12,
color: MyTheme.app_accent_color),
),
Image.asset(
'assets/icon/add.png',
width: 18,
height: 18,
color: MyTheme.app_accent_color,
)
],
)),
);
}
showDeleteWarningDialog(id){
showDialog(context: context, builder: (context)=>Container(
width: DeviceInfo(context).getWidth()*1.5,
child: AlertDialog(
title: Text(LangText(context: context).getLocal()!.warning_ucf,style: TextStyle(fontWeight: FontWeight.bold,fontSize: 15,color: MyTheme.red),),
content: Text(LangText(context: context).getLocal()!.do_you_want_to_delete_it,style:const TextStyle(fontWeight: FontWeight.w400,fontSize: 14),),
actions: [
Buttons(
color: MyTheme.app_accent_color,
onPressed: (){
Navigator.pop(context);
}, child: Text(LangText(context: context).getLocal()!.no_ucf,style: TextStyle(color: MyTheme.white,fontSize: 12),)),
Buttons(
color: MyTheme.app_accent_color,
onPressed: (){
Navigator.pop(context);
deleteCoupon(id);
}, child: Text(LangText(context: context).getLocal()!.yes_ucf,style: TextStyle(color: MyTheme.white,fontSize: 12))),
],
),
));
}
}

View File

@@ -0,0 +1,963 @@
import 'dart:convert';
import 'dart:ui';
import 'package:active_ecommerce_seller_app/const/app_style.dart';
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/loading.dart';
import 'package:active_ecommerce_seller_app/custom/localization.dart';
import 'package:active_ecommerce_seller_app/custom/multi_select.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/products_response.dart';
import 'package:active_ecommerce_seller_app/const/newCouponOptions.dart';
import 'package:active_ecommerce_seller_app/my_theme.dart';
import 'package:active_ecommerce_seller_app/repositories/coupon_repository.dart';
import 'package:active_ecommerce_seller_app/repositories/product_repository.dart';
import 'package:flutter/material.dart';
import 'package:intl/intl.dart';
import 'package:toast/toast.dart';
import 'package:validators/validators.dart';
class EditCoupon extends StatefulWidget {
final String? id;
EditCoupon({Key? key, this.id}) : super(key: key);
@override
State<EditCoupon> createState() => _EditCouponState();
}
class _EditCouponState extends State<EditCoupon> {
String? _couponInformation;
String? _couponInformation_key;
List<dynamic> _errors = [];
bool fetchData = false;
late BuildContext loadingContext;
List<CouponDiscountOptions> _couponDiscountTypeList =
CouponDiscountOptions().getList();
List<SelectProduct> _searchProductList = [];
List<SelectProduct> _selectedProducts = [];
TextEditingController _couponCodeEditController = TextEditingController();
TextEditingController _discountAmountEditController = TextEditingController();
TextEditingController _minimumShoppingEditController =
TextEditingController();
TextEditingController _maximumDiscountAmountEditController =
TextEditingController();
String? _couponProductText;
String _seachName = "t";
String _errorMessage = "";
String? _couponCode = "";
String _discountAmount = "";
String? _minimumShoppingAmount = "";
String? _maximumDiscountAmount = "";
String _couponId = "";
bool hasError = true;
CouponDiscountOptions? _couponDiscountTypeText;
String _statAndEndTime =
DateFormat('MM/d/y').format(DateTime.now()).toString() +
" - " +
DateFormat('MM/d/y').format(DateTime.now()).toString();
_sendEditCouponReq() async {
var res = await CouponRepository().editCoupon(widget.id);
if (res.data != null) {
fetchData = true;
var decode = jsonDecode(res.data!.details!);
print(decode);
var data = decode['data'];
_couponInformation_key =res.data!.type;
if (res.data!.type == "product_base") {
_couponInformation = "For Product";
for (var product in data) {
_searchProductList.add(SelectProduct(
id: product["id"],
name: product["name"].toString(),
isSelect: true));
_selectedProducts.add(SelectProduct(
id: product["id"],
name: product["name"].toString(),
isSelect: true));
}
} else {
_couponInformation = "For Total Orders";
_minimumShoppingAmount = decode["min_buy"];
_maximumDiscountAmount = decode["max_discount"];
_minimumShoppingEditController.text = _minimumShoppingAmount!;
_maximumDiscountAmountEditController.text = _maximumDiscountAmount!;
}
_couponId = res.data!.id.toString();
_discountAmount = res.data!.discount.toString();
_discountAmountEditController.text = _discountAmount;
_couponCode = res.data!.code;
_couponCodeEditController.text = _couponCode!;
_couponDiscountTypeText = res.data!.discountType == "amount"
? _couponDiscountTypeList.first
: _couponDiscountTypeList.last;
_statAndEndTime = res.data!.startDate! + " - " + res.data!.endDate!;
setState(() {});
}
}
_sendUpdateCouponReq() async {
_errors=[];
var posBody;
if (_couponInformation == "For Product") {
List productIds = [];
_selectedProducts.forEach((element) {
productIds.add(element.id);
});
posBody = jsonEncode({
"type": "product_base",
"code": _couponCode,
"discount": int.parse(_discountAmount),
"discount_type": _couponDiscountTypeText!.key,
"product_ids": productIds,
"date_range": _statAndEndTime
});
} else {
posBody = jsonEncode({
"type": "cart_base",
"code": _couponCode,
"discount": int.parse(_discountAmount),
"discount_type": _couponDiscountTypeText!.key,
"min_buy": _minimumShoppingAmount,
"max_discount": _maximumDiscountAmount,
"date_range": _statAndEndTime
});
}
show();
var res = await CouponRepository().updateCoupon(posBody,_couponId);
Navigator.pop(loadingContext);
if (res.result!) {
ToastComponent.showDialog(res.message ,gravity: Toast.center,duration: 3);
}else{
_errors.addAll(res.message);
}
}
/*
bool hasErrors() {
bool hasError = true;
if (_couponCode.isEmpty) {
_errorMessage =
LangText(context: context).getLocal().common_error_coupon_code;
hasError = true;
} else if (_discountAmount.isEmpty || !isNumeric(_discountAmount)) {
_errorMessage =
LangText(context: context).getLocal().common_error_discount_amount;
hasError = true;
} else if (_couponInformation == "product_base") {
if (_selectedProducts.isEmpty) {
_errorMessage =
LangText(context: context).getLocal().common_error_products;
hasError = true;
} else {
_errorMessage = "";
hasError = false;
}
} else if (_couponInformation == "cart_base") {
if (!isNumeric(_minimumShoppingAmount)) {
_errorMessage =
LangText(context: context).getLocal().common_error_minimum_shopping;
hasError = true;
} else if (!isNumeric(_maximumDiscountAmount)) {
_errorMessage =
LangText(context: context).getLocal().common_error_maximum_discount;
hasError = true;
} else {
_errorMessage = "";
hasError = false;
}
} else {
_errorMessage = "";
hasError = false;
}
return hasError;
}*/
formValidation() {
_errors = [];
_couponCode = _couponCodeEditController.text;
_discountAmount = _discountAmountEditController.text;
_minimumShoppingAmount = _minimumShoppingEditController.text;
_maximumDiscountAmount = _maximumDiscountAmountEditController.text;
if (_couponCode!.isEmpty) {
_errors.add(LangText(context: context).getLocal()!.coupon_code_is_empty_ucf);
} if (_discountAmount.isEmpty || !isNumeric(_discountAmount)) {
_errors.add(LangText(context: context).getLocal()!.discount_amount_is_invalid_ucf);
}
if (_couponInformation == "product_base") {
if (_selectedProducts.isEmpty) {
_errors.add(LangText(context: context).getLocal()!.please_select_minimum_1_product_ucf);
}
} else if (_couponInformation == "cart_base") {
if (!isNumeric(_minimumShoppingAmount!)) {
_errors.add(LangText(context: context).getLocal()!.invalid_minimum_shopping_ucf);
} else if (!isNumeric(_maximumDiscountAmount!)) {
_errors.add(
LangText(context: context).getLocal()!.invalid_maximum_discount_ucf);
}
}
setState(() {
});
}
@override
void initState() {
_sendEditCouponReq();
//getSearchedProductList();
//_couponInformationList.addAll(CouponInformationOptions().getList());
// TODO: implement initState
//_couponInformation = "select";
super.initState();
}
@override
Widget build(BuildContext context) {
//loading = Loading(context);
return Scaffold(
appBar: MyAppBar(
context: context,
title:
LangText(context: context).getLocal()!.edit_coupon_ucf,
).show(),
body: SingleChildScrollView(
child: Container(
padding: const EdgeInsets.symmetric(horizontal: 15),
child: buildBody(context),
),
),
);
}
Widget buildBody(BuildContext context) {
return fetchData
? Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
SizedBox(
height: 14,
),
buildCouponInformationContainer(context),
SizedBox(
height: 14,
),
buildShowBox(context)
],
)
: buildLoadingContainer();
}
Widget buildLoadingContainer() {
return Container(
height: DeviceInfo(context).getHeight(),
child: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
SizedBox(
height: 10,
width: 2,
),
CircularProgressIndicator(),
SizedBox(
height: 10,
width: 2,
),
],
),
),
);
}
Column buildShowBox(BuildContext context) {
return Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
buildCouponCodeContainer(context),
SizedBox(
height: 14,
),
_couponInformation == "For Product"
? buildCouponProductContainer()
: buildForOrderContainer(context),
SizedBox(
height: 14,
),
buildCouponDateContainer(),
SizedBox(
height: 14,
),
buildCouponDiscountContainer(),
SizedBox(
height: 14,
),
buildCouponDiscountTextField(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: 30,
),
SubmitBtn.show(
radius: 6.0,
alignment: Alignment.center,
elevation: 5,
width: DeviceInfo(context).getWidth(),
backgroundColor: MyTheme.app_accent_color,
height: 48,
padding: EdgeInsets.zero,
onTap: () {
formValidation();
if (_errors.isEmpty) {
_sendUpdateCouponReq();
}
},
child: Text(
LangText(context: context).getLocal()!.save_ucf,
style: TextStyle(fontSize: 17, color: MyTheme.white),
)),
],
);
}
Column buildCouponDiscountContainer() {
return Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
LangText(context: context).getLocal()!.discount_ucf,
style: TextStyle(
fontSize: 12,
color: MyTheme.font_grey,
fontWeight: FontWeight.bold),
),
SizedBox(
height: 10,
),
Container(height: 50, child: _buildCouponDiscountList()),
],
);
}
Column buildCouponCodeContainer(BuildContext context) {
return Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
LangText(context: context)
.getLocal()!
.add_your_coupon_code_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: _couponCodeEditController,
decoration: InputDecorations.buildInputDecoration_1(
hint_text: "Coupon Code",
borderColor: MyTheme.noColor,
hintTextColor: MyTheme.light_grey),
),
),
],
);
}
Column buildCouponDiscountTextField(BuildContext context) {
return Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
LangText(context: context).getLocal()!.amount_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: _discountAmountEditController,
keyboardType: TextInputType.numberWithOptions(decimal: true),
decoration: InputDecorations.buildInputDecoration_1(
hint_text: "Amount",
borderColor: MyTheme.noColor,
hintTextColor: MyTheme.light_grey),
),
),
],
);
}
Column buildForOrderContainer(BuildContext context) {
return Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
LangText(context: context).getLocal()!.minimum_shopping_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(
keyboardType: TextInputType.number,
controller: _minimumShoppingEditController,
decoration: InputDecorations.buildInputDecoration_1(
hint_text: LangText(context: context)
.getLocal()!
.minimum_shopping_ucf,
borderColor: MyTheme.noColor,
hintTextColor: MyTheme.light_grey),
),
),
SizedBox(
height: 10,
),
Text(
LangText(context: context)
.getLocal()!
.maximum_discount_amount_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(
keyboardType: TextInputType.number,
controller: _maximumDiscountAmountEditController,
decoration: InputDecorations.buildInputDecoration_1(
hint_text: LangText(context: context)
.getLocal()!
.maximum_discount_amount_ucf,
borderColor: MyTheme.light_grey,
hintTextColor: MyTheme.light_grey),
),
),
SizedBox(
height: 10,
),
],
);
}
Column buildCouponInformationContainer(BuildContext context) {
return Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
LangText(context: context)
.getLocal()!
.coupon_information_adding,
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,
padding: EdgeInsets.symmetric(horizontal: 16),
child: Container(
alignment: Alignment.centerLeft,
height: 50, child: Text(_couponInformation!))),
],
);
}
Column buildCouponProductContainer() {
return Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
LangText(context: context).getLocal()!.product_ucf,
style: TextStyle(
fontSize: 12,
color: MyTheme.font_grey,
fontWeight: FontWeight.bold),
),
SizedBox(
height: 10,
),
Container(
height: 50,
child: Buttons(
padding: EdgeInsets.zero,
onPressed: () {
showDialog(
barrierDismissible: false,
context: context,
builder: (context) {
return StatefulBuilder(builder: (context, setSate) {
return Container(
height: 200,
child: AlertDialog(
content: dialogBox(context, setSate),
actions: [
Buttons(
onPressed: () {
_selectedProducts = [];
if (_searchProductList.isNotEmpty) {
_searchProductList.forEach((element) {
if (element.isSelect!) {
_selectedProducts.add(element);
print(element.id);
}
});
setState(() {});
}
Navigator.pop(context, _selectedProducts);
},
child: Text("Ok"))
],
),
);
});
});
},
child: MyWidget.customCardView(
alignment: Alignment.centerLeft,
padding: EdgeInsets.only(left: 16,top: 16),
backgroundColor: MyTheme.white,
width: DeviceInfo(context).getWidth(),
height: 45,
borderRadius: 10,
elevation: 5,
child: Text(
LangText(context: context)
.getLocal()!
.select_products_ucf,
style: TextStyle(color: MyTheme.light_grey),
))),
//_buildCouponProductList()
),
SizedBox(
height: 5,
),
build_selectedProductsroductList()
],
);
}
Container build_selectedProductsroductList() {
return Container(
width: DeviceInfo(context).getWidth()-34,
child: Wrap(
children: List.generate(
_selectedProducts.length,
(index) => Container(
constraints: BoxConstraints(maxWidth: (DeviceInfo(context).getWidth()-50)/3),
margin: EdgeInsets.only(right: 5,bottom: 5),
child: MyWidget.customCardView(
backgroundColor: MyTheme.white,
width: DeviceInfo(context).getWidth(),
height: 20,
alignment: Alignment.centerLeft,
borderRadius: 10,
elevation: 5,
child: Stack(
children: [
Container(
padding: EdgeInsets.symmetric(horizontal: 5,vertical: 3),
constraints: BoxConstraints(maxWidth: 90),
child: Text(
_selectedProducts[index].name.toString(),
maxLines: 1,
overflow: TextOverflow.ellipsis,
style: TextStyle(fontSize: 12),
)),
Positioned(
top: 2,
right: 2,
child: Container(
// decoration: BoxDecoration(borderRadius: BorderRadius.circular(20),
// color: MyTheme.grey_153
// ),
child: InkWell(
child:
Icon(Icons.highlight_remove, size: 15, color: MyTheme.red),
onTap: () {
_searchProductList.removeWhere((element) {
if (element.id == _selectedProducts[index].id) {
return true;
}
return false;
});
_selectedProducts.removeAt(index);
setState(() {});
},
),
),
)
],
),
))),
),
);
}
Column buildCouponDateContainer() {
return Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
LangText(context: context).getLocal()!.date_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,
padding: EdgeInsets.symmetric(horizontal: AppStyles.layoutMargin),
child: InkWell(
onTap: () async {
// showDateDialog();
DateTimeRange? time;
time = await _buildCouponDate();
setState(() {
_statAndEndTime = DateFormat('MM/d/y').format(time!.start) +
" - " +
DateFormat('MM/d/y').format(time.end);
});
},
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: [
Text(_statAndEndTime),
Spacer(),
Padding(
padding: const EdgeInsets.only(right: 8.0),
child: Icon(
Icons.calendar_today,
size: 12,
),
),
],
),
)),
],
);
}
// Widget showDateDialog(){
//
// showDialog(context: context, builder: (context){
// return AlertDialog(
// content: DateRangePickerDialog(
//
// initialDateRange:DateTimeRange(start:DateTime.now(),end: DateTime.now() ) ,
// saveText: "Select",
// initialEntryMode: DatePickerEntryMode.calendarOnly,
// firstDate:_start,lastDate: DateTime.utc(2050),)
// );
// });
// }
Future<DateTimeRange?> _buildCouponDate() async {
DateTimeRange? p;
p = await showDateRangePicker(
context: context,
firstDate: DateTime.now(),
lastDate: DateTime.utc(2050),
builder: (context, child) {
return Container(
color: MyTheme.red,
width: 500,
height: 500,
child: DateRangePickerDialog(
initialDateRange:
DateTimeRange(start: DateTime.now(), end: DateTime.now()),
saveText: "Select",
initialEntryMode: DatePickerEntryMode.calendarOnly,
firstDate: DateTime.now(),
lastDate: DateTime.utc(2050),
),
);
});
return p;
}
/*
Widget _buildCouponInformationList() {
return MyWidget().myContainer(
borderRadius: 6.0,
borderColor: MyTheme.light_grey,
paddingY: 14.0,
width: DeviceInfo(context).getWidth(),
child: DropdownButton<CouponInformationOptions>(
isDense: true,
underline: Container(),
isExpanded: true,
onChanged: (value) {
setState(() {
_couponInformation = value;
});
},
icon: Icon(Icons.arrow_drop_down),
value: _couponInformation,
items: _couponInformationList
.map((value) => DropdownMenuItem<CouponInformationOptions>(
enabled: !widget.isEdit,
child: Text(
value.value,
),
value: value,
))
.toList(),
),
);
}*/
/*
Widget _buildCouponProductList() {
return MyWidget().myContainer(
borderRadius: 6.0,
borderColor: MyTheme.light_grey,
paddingY: 14.0,
width: DeviceInfo(context).getWidth(),
child: SmartSelect<CouponProduct>.multiple(
modalType: S2ModalType.bottomSheet,
modalFilter:true ,
title: "Choose Product",
modalConfig:S2ModalConfig(title: "Search Product") ,
choiceItems: List<S2Choice<CouponProduct>>.generate(_productList.length, (index) =>
S2Choice<CouponProduct>(value: _productList[index], title:_productList[index].name),
),
value: _chosenProduct,
onChange: (onChange){
setState(() {
_chosenProduct = onChange.value;
});
},)
);
}*/
Widget _buildCouponDiscountList() {
return MyWidget.customCardView(
backgroundColor: MyTheme.white,
width: DeviceInfo(context).getWidth(),
height: 45,
borderRadius: 10,
elevation: 5,
alignment: Alignment.centerLeft,
padding: EdgeInsets.symmetric(vertical: 16,horizontal: 16),
child: DropdownButton<CouponDiscountOptions>(
isDense: true,
underline: Container(),
isExpanded: true,
onChanged: (value) {
setState(() {
_couponDiscountTypeText = value;
});
},
icon: Icon(Icons.arrow_drop_down),
value: _couponDiscountTypeText,
items: _couponDiscountTypeList
.map((value) => DropdownMenuItem(
child: Text(
value.value!,
),
value: value,
))
.toList(),
),
);
}
Widget dialogBox(BuildContext context, setState) {
return ConstrainedBox(
constraints: BoxConstraints(
maxHeight: 300,
),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Container(
width: DeviceInfo(context).getWidth(),
height: 60,
child: TextField(
decoration: InputDecoration(
contentPadding: EdgeInsets.symmetric(horizontal: 10),
hintText: "Product Name",
border: OutlineInputBorder(
gapPadding: 40.0, borderRadius: BorderRadius.circular(20)),
),
onChanged: (string) {
searchProduct(string, setState);
},
),
),
Container(
height: 240,
child: SingleChildScrollView(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: _searchProductList.isNotEmpty
? List.generate(
_searchProductList.length,
(index) => Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Container(
width: DeviceInfo(context).getWidth() / 2,
child: Text(
_searchProductList[index].name!,
maxLines: 1,
),
),
Checkbox(
value: _searchProductList[index].isSelect,
onChanged: (value) {
setState(() {
_searchProductList[index].isSelect =
value;
_selectedProducts = [];
_searchProductList.forEach((element) {
if (element.isSelect!) {
_selectedProducts.add(element);
print(element.id);
}
});
});
})
],
))
: List.generate(1, (index) => Text("No Product")),
),
),
),
],
),
);
}
searchProduct(String value, setState) async {
_searchProductList.removeWhere((element) {
if (element.isSelect!) {
return false;
}
return true;
});
var response = await CouponRepository().searchProducts(value);
response.data!.forEach((element) {
bool idHas = false;
_searchProductList.forEach((element2) {
if (element.id == element2.id) {
idHas = true;
}
});
if (!idHas) {
_searchProductList.add(
SelectProduct(id: element.id, name: element.name, isSelect: false));
}
});
setState(() {});
}
show(){
return showDialog(
context: context,
builder: (BuildContext context) {
//setDialogContext.add(context);
loadingContext = context;
return AlertDialog(
content: Row(
children: [
CircularProgressIndicator(),
SizedBox(
width: 10,
),
Text("${LangText(context: context).getLocal()!.please_wait_ucf}"),
],
));
});
}
}

View File

@@ -0,0 +1,863 @@
import 'dart:convert';
import 'dart:ui';
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/loading.dart';
import 'package:active_ecommerce_seller_app/custom/localization.dart';
import 'package:active_ecommerce_seller_app/custom/multi_select.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/const/newCouponOptions.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/repositories/coupon_repository.dart';
import 'package:active_ecommerce_seller_app/repositories/product_repository.dart';
import 'package:flutter/material.dart';
import 'package:intl/intl.dart';
import 'package:toast/toast.dart';
import 'package:validators/validators.dart';
class NewCoupon extends StatefulWidget {
NewCoupon({Key? key}) : super(key: key);
@override
State<NewCoupon> createState() => _NewCouponState();
}
class _NewCouponState extends State<NewCoupon> {
late BuildContext loadingContext;
List<CouponInformationOptions> _couponInformationList =
CouponInformationOptions().getList();
List<CouponDiscountOptions> _couponDiscountTypeList =
CouponDiscountOptions().getList();
GlobalKey key = GlobalKey();
List<SelectProduct> _searchProductList = [];
List<SelectProduct> _selectedProducts = [];
List<dynamic> _errors = [];
CouponInformationOptions? _couponInformation;
TextEditingController _couponCodeEditController = TextEditingController();
TextEditingController _discountAmountEditController = TextEditingController();
TextEditingController _minimumShoppingEditController =
TextEditingController();
TextEditingController _maximumDiscountAmountEditController =
TextEditingController();
String? _couponProductText;
String _seachName = "t";
String _errorMessage = "";
String _couponCode = "";
String _discountAmount = "";
String _minimumShoppingAmount = "";
String _maximumDiscountAmount = "";
int count = 0;
bool hasError = true;
CouponDiscountOptions? _couponDiscountTypeText;
String _statAndEndTime =
DateFormat('MM/d/y').format(DateTime.now()).toString() +
" - " +
DateFormat('MM/d/y').format(DateTime.now()).toString();
_sendCreateCouponReq() async {
_errors = [];
var posBody;
if (_couponInformation!.key == "product_base") {
List productIds = [];
_selectedProducts.forEach((element) {
productIds.add(element.id);
});
posBody = jsonEncode({
"type": "product_base",
"code": _couponCode,
"discount": int.parse(_discountAmount),
"discount_type": _couponDiscountTypeText!.key,
"product_ids": productIds,
"date_range": _statAndEndTime
});
} else {
posBody = jsonEncode({
"type": "cart_base",
"code": _couponCode,
"discount": int.parse(_discountAmount),
"discount_type": _couponDiscountTypeText!.key,
"min_buy": _minimumShoppingAmount,
"max_discount": _maximumDiscountAmount,
"date_range": _statAndEndTime
});
}
dialogShow();
var res = await CouponRepository().createCoupon(posBody);
Navigator.pop(loadingContext);
if (res.result!) {
ToastComponent.showDialog(res.message,bgColor: MyTheme.white,textStyle:TextStyle(color:MyTheme.black) ,gravity: Toast.center,duration: Toast.lengthLong);
Navigator.pop(context);
} else {
_errors.addAll(res.message);
}
}
resetData(){
}
formValidation() {
_errors = [];
_couponCode = _couponCodeEditController.text;
_discountAmount = _discountAmountEditController.text;
_minimumShoppingAmount = _minimumShoppingEditController.text;
_maximumDiscountAmount = _maximumDiscountAmountEditController.text;
if (_couponCode.isEmpty) {
_errors
.add(LangText(context: context).getLocal()!.coupon_code_is_empty_ucf);
}
if (_discountAmount.isEmpty || !isNumeric(_discountAmount)) {
_errors.add(
LangText(context: context).getLocal()!.discount_amount_is_invalid_ucf);
}
if (_couponInformation!.key == "product_base") {
if (_selectedProducts.isEmpty) {
_errors
.add(LangText(context: context).getLocal()!.please_select_minimum_1_product_ucf);
}
} else if (_couponInformation!.key == "cart_base") {
if (!isNumeric(_minimumShoppingAmount)) {
_errors.add(LangText(context: context)
.getLocal()!
.invalid_minimum_shopping_ucf);
} else if (!isNumeric(_maximumDiscountAmount)) {
_errors.add(LangText(context: context)
.getLocal()!
.invalid_maximum_discount_ucf);
}
}
setState(() {});
}
@override
void initState() {
//getSearchedProductList();
_couponInformation = _couponInformationList.first;
_couponDiscountTypeText = _couponDiscountTypeList.first;
//_couponInformationList.addAll(CouponInformationOptions().getList());
// TODO: implement initState
//_couponInformation = "select";
super.initState();
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: MyAppBar(
context: context,
title:
LangText(context: context).getLocal()!.add_new_coupon_ucf,
).show(),
body: SingleChildScrollView(
child: Container(
padding: const EdgeInsets.symmetric(horizontal: 15),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
SizedBox(
height: 20,
),
buildCouponInformationContainer(context),
SizedBox(
height: 14,
),
_couponInformation!.value != "Select"
? buildShowBox(context)
: Container(),
],
),
),
),
);
}
Column buildShowBox(BuildContext context) {
return Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
buildCouponCodeContainer(context),
SizedBox(
height: 14,
),
_couponInformation!.value == "For Product"
? buildCouponProductContainer()
: buildForOrderContainer(context),
SizedBox(
height: 14,
),
buildCouponDateContainer(),
SizedBox(
height: 14,
),
buildCouponDiscountContainer(),
SizedBox(
height: 14,
),
buildCouponDiscountTextField(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: 30,
),
SubmitBtn.show(
elevation:5,
radius:6,
//: DeviceInfo(context).getWidth(),
backgroundColor: MyTheme.app_accent_color,
//height: 48,
padding: EdgeInsets.zero,
onTap: () {
formValidation();
print(_errors.isEmpty);
if (_errors.isEmpty) {
_sendCreateCouponReq();
}
},
child: Container(
width: DeviceInfo(context).getWidth(),
alignment: Alignment.center,
height: 48,
child: Text(
LangText(context: context).getLocal()!.save_ucf,
style: TextStyle(fontSize: 17, color: MyTheme.white),
),
)),
SizedBox(
height: 30,
),
],
);
}
Column buildCouponDiscountContainer() {
return Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
LangText(context: context).getLocal()!.discount_ucf,
style: TextStyle(
fontSize: 12,
color: MyTheme.font_grey,
fontWeight: FontWeight.bold),
),
SizedBox(
height: 10,
),
Container(height: 50, child: _buildCouponDiscountList()),
],
);
}
Widget buildCouponCodeContainer(BuildContext context) {
return Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
LangText(context: context)
.getLocal()!
.add_your_coupon_code_ucf,
style: TextStyle(
fontSize: 12,
color: MyTheme.font_grey,
fontWeight: FontWeight.bold),
),
SizedBox(
height: 10,
),
MyWidget.customCardView(
backgroundColor: MyTheme.white,
elevation: 5,
width: DeviceInfo(context).getWidth(),
height: 45,
borderRadius: 10,
child: TextField(
controller: _couponCodeEditController,
decoration: InputDecorations.buildInputDecoration_1(
hint_text: "Coupon Code",
borderColor: MyTheme.noColor,
hintTextColor: MyTheme.grey_153),
),
),
],
);
}
Column buildCouponDiscountTextField(BuildContext context) {
return Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
LangText(context: context).getLocal()!.amount_ucf,
style: TextStyle(
fontSize: 12,
color: MyTheme.font_grey,
fontWeight: FontWeight.bold),
),
SizedBox(
height: 10,
),
MyWidget.customCardView(
backgroundColor: MyTheme.white,
elevation: 5,
width: DeviceInfo(context).getWidth(),
height: 45,
borderRadius: 10,
child: TextField(
controller: _discountAmountEditController,
keyboardType: TextInputType.numberWithOptions(decimal: true),
decoration: InputDecorations.buildInputDecoration_1(
hint_text: "Amount",
borderColor: MyTheme.noColor,
hintTextColor: MyTheme.grey_153),
),
),
],
);
}
Column buildForOrderContainer(BuildContext context) {
return Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
LangText(context: context).getLocal()!.minimum_shopping_ucf,
style: TextStyle(
fontSize: 12,
color: MyTheme.font_grey,
fontWeight: FontWeight.bold),
),
SizedBox(
height: 10,
),
MyWidget.customCardView(
backgroundColor: MyTheme.white,
elevation: 5,
width: DeviceInfo(context).getWidth(),
height: 45,
borderRadius: 10,
child: TextField(
keyboardType: TextInputType.number,
controller: _minimumShoppingEditController,
decoration: InputDecorations.buildInputDecoration_1(
hint_text: LangText(context: context)
.getLocal()!
.minimum_shopping_ucf,
borderColor: MyTheme.noColor,
hintTextColor: MyTheme.light_grey),
),
),
SizedBox(
height: 10,
),
Text(
LangText(context: context)
.getLocal()!
.maximum_discount_amount_ucf,
style: TextStyle(
fontSize: 12,
color: MyTheme.font_grey,
fontWeight: FontWeight.bold),
),
SizedBox(
height: 10,
),
MyWidget.customCardView(
backgroundColor: MyTheme.white,
elevation: 5,
width: DeviceInfo(context).getWidth(),
height: 45,
borderRadius: 10,
child: TextField(
keyboardType: TextInputType.number,
controller: _maximumDiscountAmountEditController,
decoration: InputDecorations.buildInputDecoration_1(
hint_text: LangText(context: context)
.getLocal()!
.maximum_discount_amount_ucf,
borderColor: MyTheme.noColor,
hintTextColor: MyTheme.light_grey),
),
),
SizedBox(
height: 10,
),
],
);
}
Column buildCouponInformationContainer(BuildContext context) {
return Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
LangText(context: context)
.getLocal()!
.coupon_information_adding,
style: TextStyle(
fontSize: 12,
color: MyTheme.font_grey,
fontWeight: FontWeight.bold),
),
SizedBox(
height: 10,
),
Container(height: 50, child: _buildCouponInformationList()),
],
);
}
Column buildCouponProductContainer() {
return Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
LangText(context: context).getLocal()!.product_ucf,
style: TextStyle(
fontSize: 12,
color: MyTheme.font_grey,
fontWeight: FontWeight.bold),
),
SizedBox(
height: 10,
),
Container(
height: 50,
child: Buttons(
padding: EdgeInsets.zero,
onPressed: () {
showDialog(
barrierDismissible: false,
context: context,
builder: (context) {
return StatefulBuilder(builder: (context, setSate) {
return Container(
height: 150,
width: 150,
child: AlertDialog(
//contentPadding: EdgeInsets.zero,
actionsPadding: EdgeInsets.zero,
contentPadding: EdgeInsets.only(top: 24,right: 24,left: 24),
content: productsDialogBox(context, setSate),
actions: [
Buttons(
onPressed: () {
_selectedProducts = [];
if (_searchProductList.isNotEmpty) {
_searchProductList.forEach((element) {
if (element.isSelect!) {
_selectedProducts.add(element);
print(element.id);
}
});
setState(() {});
}
Navigator.pop(context, _selectedProducts);
},
child: Text("Ok")),
],
),
);
});
});
},
child: MyWidget.customCardView(
backgroundColor: MyTheme.white,
elevation: 5,
alignment: Alignment.centerLeft,
padding: EdgeInsets.symmetric(vertical: 14, horizontal: 14),
width: DeviceInfo(context).getWidth(),
borderRadius: 10.0,
borderColor: MyTheme.light_grey,
height: 45,
child: Text(
LangText(context: context)
.getLocal()!
.select_products_ucf,
style: TextStyle(color: MyTheme.grey_153),
))),
//_buildCouponProductList()
),
SizedBox(
height: 5,
),
build_selectedProductstList()
],
);
}
Container build_selectedProductstList() {
return Container(
child: Wrap(
children: List.generate(
_selectedProducts.length,
(index) => Container(
constraints: BoxConstraints(maxWidth: (DeviceInfo(context).getWidth()-50)/3),
margin: EdgeInsets.only(right: 5,bottom: 5),
child: MyWidget.customCardView(
backgroundColor: MyTheme.white,
width: DeviceInfo(context).getWidth(),
height: 20,
alignment: Alignment.centerLeft,
borderRadius: 10,
elevation: 5,
child: Stack(
children: [
Container(
padding: EdgeInsets.symmetric(horizontal: 5,vertical: 3),
constraints: BoxConstraints(maxWidth: 90),
child: Text(
_selectedProducts[index].name.toString(),
maxLines: 1,
overflow: TextOverflow.ellipsis,
style: TextStyle(fontSize: 12),
)),
Positioned(
top: 2,
right: 2,
child: Container(
// decoration: BoxDecoration(borderRadius: BorderRadius.circular(20),
// color: MyTheme.grey_153
// ),
child: InkWell(
child:
Icon(Icons.highlight_remove, size: 15, color: MyTheme.red),
onTap: () {
_searchProductList.removeWhere((element) {
if (element.id == _selectedProducts[index].id) {
return true;
}
return false;
});
_selectedProducts.removeAt(index);
setState(() {});
},
),
),
)
],
),
))),
),
);
}
Column buildCouponDateContainer() {
return Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
LangText(context: context).getLocal()!.date_ucf,
style: TextStyle(
fontSize: 12,
color: MyTheme.font_grey,
fontWeight: FontWeight.bold),
),
SizedBox(
height: 10,
),
MyWidget.customCardView(
backgroundColor: MyTheme.white,
elevation: 5,
borderRadius: 6.0,
borderColor: MyTheme.light_grey,
padding: EdgeInsets.symmetric(vertical: 14, horizontal: 14),
width: DeviceInfo(context).getWidth(),
height: 50,
child: InkWell(
onTap: () async {
// showDateDialog();
DateTimeRange? time;
time = await _buildCouponDate();
setState(() {
_statAndEndTime = DateFormat('MM/d/y').format(time!.start) +
" - " +
DateFormat('MM/d/y').format(time.end);
});
},
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: [
Text(_statAndEndTime),
Spacer(),
Padding(
padding: const EdgeInsets.only(right: 8.0),
child: Icon(
Icons.calendar_today,
size: 12,
),
),
],
),
)),
],
);
}
// Widget showDateDialog(){
//
// showDialog(context: context, builder: (context){
// return AlertDialog(
// content: DateRangePickerDialog(
//
// initialDateRange:DateTimeRange(start:DateTime.now(),end: DateTime.now() ) ,
// saveText: "Select",
// initialEntryMode: DatePickerEntryMode.calendarOnly,
// firstDate:_start,lastDate: DateTime.utc(2050),)
// );
// });
// }
Future<DateTimeRange?> _buildCouponDate() async {
DateTimeRange? p;
p = await showDateRangePicker(
context: context,
firstDate: DateTime.now(),
lastDate: DateTime.utc(2050),
builder: (context, child) {
return Container(
color: MyTheme.red,
width: 500,
height: 500,
child: DateRangePickerDialog(
initialDateRange:
DateTimeRange(start: DateTime.now(), end: DateTime.now()),
saveText: "Select",
initialEntryMode: DatePickerEntryMode.calendarOnly,
firstDate: DateTime.now(),
lastDate: DateTime.utc(2050),
),
);
});
return p;
}
Widget _buildCouponInformationList() {
return MyWidget.customCardView(
backgroundColor: MyTheme.white,
elevation: 5,
borderRadius: 6.0,
borderColor: MyTheme.light_grey,
padding: EdgeInsets.symmetric(vertical: 14, horizontal: 14),
width: DeviceInfo(context).getWidth(),
child: DropdownButton<CouponInformationOptions>(
isDense: true,
underline: Container(),
isExpanded: true,
onChanged: (value) {
setState(() {
_couponInformation = value;
});
},
icon: Icon(Icons.arrow_drop_down),
value: _couponInformation,
items: _couponInformationList
.map((value) => DropdownMenuItem<CouponInformationOptions>(
child: Text(
value.value!,
),
value: value,
))
.toList(),
),
);
}
/*
Widget _buildCouponProductList() {
return MyWidget.customCardView(
elevation: 5,
borderRadius: 6.0,
borderColor: MyTheme.light_grey,
padding: EdgeInsets.symmetric(vertical: 14,horizontal: 14),
width: DeviceInfo(context).getWidth(),
child: SmartSelect<CouponProduct>.multiple(
modalType: S2ModalType.bottomSheet,
modalFilter:true ,
title: "Choose Product",
modalConfig:S2ModalConfig(title: "Search Product") ,
choiceItems: List<S2Choice<CouponProduct>>.generate(_productList.length, (index) =>
S2Choice<CouponProduct>(value: _productList[index], title:_productList[index].name),
),
value: _chosenProduct,
onChange: (onChange){
setState(() {
_chosenProduct = onChange.value;
});
},)
);
}*/
Widget _buildCouponDiscountList() {
return MyWidget.customCardView(
backgroundColor: MyTheme.white,
elevation: 5,
borderRadius: 6.0,
borderColor: MyTheme.light_grey,
padding: EdgeInsets.symmetric(vertical: 14, horizontal: 14),
width: DeviceInfo(context).getWidth(),
child: DropdownButton<CouponDiscountOptions>(
isDense: true,
underline: Container(),
isExpanded: true,
onChanged: (value) {
setState(() {
_couponDiscountTypeText = value;
});
},
icon: Icon(Icons.arrow_drop_down),
value: _couponDiscountTypeText,
items: _couponDiscountTypeList
.map((value) => DropdownMenuItem(
child: Text(
value.value!,
),
value: value,
))
.toList(),
),
);
}
Widget productsDialogBox(BuildContext context, setState) {
return ConstrainedBox(
constraints: BoxConstraints(
minWidth: 290,
maxHeight: 290,
),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Container(
width: DeviceInfo(context).getWidth(),
height: 40,
child: TextField(
decoration: InputDecoration(
contentPadding: EdgeInsets.symmetric(horizontal: 10),
hintText: "Product Name",
border: OutlineInputBorder(
gapPadding: 40.0, borderRadius: BorderRadius.circular(20)),
),
onChanged: (string) {
searchProduct(string, setState);
},
),
),
Container(
height: 240,
child: SingleChildScrollView(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: _searchProductList.isNotEmpty
? List.generate(
_searchProductList.length,
(index) => Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Container(
width: DeviceInfo(context).getWidth() / 2,
child: Text(
_searchProductList[index].name!,
style: TextStyle(fontSize: 12),
maxLines: 1,
),
),
Checkbox(
value: _searchProductList[index].isSelect,
onChanged: (value) {
setState(() {
_searchProductList[index].isSelect =
value;
_selectedProducts = [];
_searchProductList.forEach((element) {
if (element.isSelect!) {
_selectedProducts.add(element);
print(element.id);
}
});
});
})
],
))
: List.generate(1, (index) => Text("No Product")),
),
),
),
],
),
);
}
searchProduct(String value, setState) async {
_searchProductList.removeWhere((element) {
if (element.isSelect!) {
return false;
}
return true;
});
var resPonse = await CouponRepository().searchProducts(value);
resPonse.data!.forEach((element) {
bool idHas = false;
_searchProductList.forEach((element2) {
if (element.id == element2.id) {
idHas = true;
}
});
if (!idHas) {
_searchProductList.add(
SelectProduct(id: element.id, name: element.name, isSelect: false));
}
});
setState(() {});
}
dialogShow() {
return showDialog(
context: context,
builder: (BuildContext context) {
loadingContext = context;
return AlertDialog(
content: Row(
children: [
CircularProgressIndicator(),
SizedBox(
width: 10,
),
Text("${LangText(context: context).getLocal()!.please_wait_ucf}"),
],
));
});
}
}

View File

@@ -0,0 +1,153 @@
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/my_theme.dart';
import 'package:flutter/material.dart';
class CreateTicket extends StatefulWidget {
const CreateTicket({Key? key}) : super(key: key);
@override
State<CreateTicket> createState() => _CreateTicketState();
}
class _CreateTicketState extends State<CreateTicket> {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: MyAppBar(context: context,title: LangText(context: context).getLocal()!.create_a_ticket).show(),
body: SingleChildScrollView(
child: Container(
padding: EdgeInsets.symmetric(horizontal: 15),
child: Column(
children: [
Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
LangText(context: context)
.getLocal()!
.subject_ucf,
style: TextStyle(
fontSize: 12,
color: MyTheme.font_grey,
fontWeight: FontWeight.bold),
),
SizedBox(
height: 10,
),
TextField(
decoration: InputDecorations.buildInputDecoration_1(
hint_text: LangText(context: context)
.getLocal()!
.subject_ucf,
borderColor: MyTheme.light_grey,
hintTextColor: MyTheme.grey_153),
),
],
),
SizedBox(height: 14,),
Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
LangText(context: context)
.getLocal()!
.provide_a_detailed_description,
style: TextStyle(
fontSize: 12,
color: MyTheme.font_grey,
fontWeight: FontWeight.bold),
),
SizedBox(
height: 10,
),
MyWidget().myContainer(
paddingY: 8.0,
height: 80,
width: DeviceInfo(context).getWidth(),
borderColor: MyTheme.light_grey,
borderRadius: 6,
child: TextField(
decoration: InputDecoration.collapsed(hintText: "Type your reply",hintStyle: TextStyle(color: MyTheme.grey_153,fontSize: 12)),
maxLines: 6,
),
),
],
),
SizedBox(height: 14,),
Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
LangText(context: context)
.getLocal()!
.photo_ucf,
style: TextStyle(
fontSize: 12,
color: MyTheme.font_grey,
fontWeight: FontWeight.bold),
),
SizedBox(
height: 10,
),
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: 18,),
Container(
width: DeviceInfo(context).getWidth(),
child:Row(
mainAxisAlignment: MainAxisAlignment.end,
children: [
SubmitBtn.show(height: 30.0,width: 120.0,child: Text(LangText(context: context)
.getLocal()!
.cancel_ucf,style: TextStyle(color: MyTheme.white,fontSize: 13),),backgroundColor: MyTheme.grey_153,onTap: (){
Navigator.pop(context);
},
radius: 2.0
),
SizedBox(width: 14,),
SubmitBtn.show(height: 30.0,width: 120.0,child: Text(LangText(context: context)
.getLocal()!
.send_ticket,style: TextStyle(color: MyTheme.white,fontSize: 13),),backgroundColor: MyTheme.app_accent_color,onTap: (){},
radius: 2.0
),
],
),
)
],),
),
),
);
}
}

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,467 @@
import 'package:active_ecommerce_seller_app/app_config.dart';
import 'package:active_ecommerce_seller_app/custom/buttons.dart';
import 'package:active_ecommerce_seller_app/custom/input_decorations.dart';
import 'package:active_ecommerce_seller_app/custom/intl_phone_input.dart';
import 'package:active_ecommerce_seller_app/custom/localization.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/helpers/auth_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/address_repository.dart';
import 'package:active_ecommerce_seller_app/repositories/auth_repository.dart';
import 'package:active_ecommerce_seller_app/screens/home.dart';
import 'package:active_ecommerce_seller_app/screens/main.dart';
import 'package:active_ecommerce_seller_app/screens/password_forget.dart';
import 'package:active_ecommerce_seller_app/screens/registration.dart';
import 'package:flutter/material.dart';
import 'package:intl_phone_number_input/intl_phone_number_input.dart';
import 'package:toast/toast.dart';
import 'package:flutter/services.dart';
import 'package:flutter_gen/gen_l10n/app_localizations.dart';
class Login extends StatefulWidget {
@override
_LoginState createState() => _LoginState();
}
class _LoginState extends State<Login> {
String _login_by = "email"; //phone or email
String initialCountry = 'US';
PhoneNumber phoneCode = PhoneNumber(isoCode: 'US', dialCode: "+1");
String? _phone = "";
late BuildContext loadingContext;
var countries_code = <String?>[];
//controllers
TextEditingController _phoneNumberController = TextEditingController();
TextEditingController _emailController = TextEditingController();
TextEditingController _passwordController = TextEditingController();
MyWidget? myWidget;
fetch_country() async {
var data = await AddressRepository().getCountryList();
data.countries!.forEach((c) => countries_code.add(c.code));
phoneCode = PhoneNumber(isoCode: data.countries!.first.code);
setState((){});
}
@override
void initState() {
//on Splash Screen hide statusbar
SystemChrome.setEnabledSystemUIMode(SystemUiMode.manual, overlays: [SystemUiOverlay.bottom]);
super.initState();
if(otp_addon_installed.$) {
fetch_country();
}
/*if (is_logged_in.value == true) {
Navigator.push(context, MaterialPageRoute(builder: (context) {
return Main();
}));
}*/
}
@override
void dispose() {
//before going to other screen show statusbar
SystemChrome.setEnabledSystemUIMode(
SystemUiMode.manual, overlays: [SystemUiOverlay.top, SystemUiOverlay.bottom]);
super.dispose();
}
onPressedLogin() async {
var email = _emailController.text.toString();
var password = _passwordController.text.toString();
if (_login_by == 'email' && email == "") {
ToastComponent.showDialog("Enter email",
gravity: Toast.center, duration: Toast.lengthLong);
return;
} else if (_login_by == 'phone' && _phone == "") {
ToastComponent.showDialog("Enter phone number",
gravity: Toast.center, duration: Toast.lengthLong);
return;
} else if (password == "") {
ToastComponent.showDialog("Enter password",
gravity: Toast.center, duration: Toast.lengthLong);
return;
}
loading();
var loginResponse = await AuthRepository()
.getLoginResponse(_login_by == 'email' ? email : _phone, password);
Navigator.pop(loadingContext);
if (loginResponse.result == true) {
ToastComponent.showDialog(loginResponse.message!,
gravity: Toast.center, duration: Toast.lengthLong);
AuthHelper().setUserData(loginResponse);
access_token.load().whenComplete(() {
if (access_token.$!.isNotEmpty) {
print(access_token.$);
Navigator.pushAndRemoveUntil(
context,
MaterialPageRoute(builder: (context) {
return Main();
},),(route)=>false);
}
});
} else {
ToastComponent.showDialog(loginResponse.message!,
gravity: Toast.center, duration: Toast.lengthLong);
}
}
@override
Widget build(BuildContext context) {
myWidget = MyWidget(myContext: context);
return WillPopScope(
onWillPop: () async => false,
child: Scaffold(
backgroundColor: MyTheme.login_reg_screen_color,
body: buildBody(context),
),
);
}
buildBody(context) {
final _screen_width = MediaQuery.of(context).size.width;
return Container(
padding: const EdgeInsets.symmetric(horizontal: 36),
width: double.infinity,
child: SingleChildScrollView(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
SizedBox(
height: 100,
),
Text(
LangText(context: context).getLocal()!.hi_welcome_to_all_lower,
style:
TextStyle(color: MyTheme.app_accent_border, fontSize: 20,fontWeight: FontWeight.w300),
),
SizedBox(
height: 20,
),
Row(
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Container(
padding: EdgeInsets.all(8),
decoration: BoxDecoration(
border:
Border.all(color: MyTheme.app_accent_border),
borderRadius: BorderRadius.circular(10)),
width: 72,
height: 72,
child: Image.asset(
"assets/logo/white_logo.png",
height: 48,
width: 36,
)),
SizedBox(
width: 10,
),
Container(
width: _screen_width / 2,
child: Text(
AppConfig.app_name,
style: TextStyle(
color: Colors.white,
fontSize: 22,
fontWeight: FontWeight.w500),
),
),
],
),
Padding(
padding: const EdgeInsets.only(
top: 40,
bottom: 30.0,
),
child: Text(
LangText(context: context).getLocal()!.login_to_your_account_all_lower,
style: TextStyle(
color: MyTheme.app_accent_border,
fontSize: 20,
fontWeight: FontWeight.w300),
),
),
// login form container
Container(
width: _screen_width,
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Padding(
padding: const EdgeInsets.only(bottom: 4.0),
child: Text(
_login_by == "email" ? "Email" : "Phone",
style:const TextStyle(
color: MyTheme.app_accent_border,
fontWeight: FontWeight.w400,
fontSize: 12),
),
),
if (_login_by == "email")
Padding(
padding: const EdgeInsets.only(bottom: 8.0),
child: Column(
crossAxisAlignment: CrossAxisAlignment.end,
children: [
Container(
height: 36,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(10),
color: Color.fromRGBO(255, 255, 255, 0.5)),
child: TextField(
style: TextStyle(color: MyTheme.white),
controller: _emailController,
autofocus: false,
decoration:
InputDecorations.buildInputDecoration_1(
borderColor: MyTheme.noColor,
hint_text: "seller@example.com",
hintTextColor: MyTheme.dark_grey
),
),
),
],
),
)
else
Padding(
padding: const EdgeInsets.only(bottom: 8.0),
child: Column(
crossAxisAlignment: CrossAxisAlignment.end,
children: [
Container(
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(10),
color: Color.fromRGBO(255, 255, 255, 0.5)),
height: 36,
child: CustomInternationalPhoneNumberInput(
countries:countries_code,
onInputChanged: (PhoneNumber number) {
print(number.phoneNumber);
setState(() {
_phone = number.phoneNumber;
});
},
onInputValidated: (bool value) {
print('on input validation ${value}');
},
selectorConfig: SelectorConfig(
selectorType: PhoneInputSelectorType.DIALOG,
),
ignoreBlank: false,
autoValidateMode: AutovalidateMode.disabled,
selectorTextStyle:
TextStyle(color: MyTheme.font_grey),
textStyle: TextStyle(color: Colors.white54),
initialValue: phoneCode,
textFieldController: _phoneNumberController,
formatInput: true,
keyboardType: TextInputType.numberWithOptions(
signed: true, decimal: true),
inputDecoration:
InputDecorations.buildInputDecoration_phone(
hint_text: "01XXX XXX XXX"),
onSaved: (PhoneNumber number) {
print('On Saved: $number');
},
),
),
],
),
),
if(otp_addon_installed.$)
Row(
children: [
Spacer(),
GestureDetector(
onTap: () {
setState(() {
_login_by = _login_by == "email" ?"phone":"email";
});
},
child: Text(
"or, Login with ${_login_by == "email" ?'a phone':'an email'}",
style: TextStyle(
color: MyTheme.white,
fontStyle: FontStyle.italic,
decoration: TextDecoration.underline),
),
),
],
),
Padding(
padding: const EdgeInsets.only(bottom: 4.0),
child: Text(
"Password",
style: TextStyle(
color: MyTheme.app_accent_border,
fontWeight: FontWeight.w400,
fontSize: 12),
),
),
Padding(
padding: const EdgeInsets.only(bottom: 8.0),
child: Column(
crossAxisAlignment: CrossAxisAlignment.end,
children: [
Container(
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(10),
color: Color.fromRGBO(255, 255, 255, 0.5)),
height: 36,
child: TextField(
controller: _passwordController,
autofocus: false,
obscureText: true,
enableSuggestions: false,
autocorrect: false,
style: TextStyle(color: MyTheme.white),
decoration: InputDecorations.buildInputDecoration_1(
borderColor: MyTheme.noColor,
hint_text: "• • • • • • • •",hintTextColor: MyTheme.dark_grey),
),
),
Padding(
padding: const EdgeInsets.only(top: 8.0),
child: GestureDetector(
onTap: () {
Navigator.push(context,
MaterialPageRoute(builder: (context) {
return PasswordForget();
}));
},
child: Text(
"Forgot Password?",
style: TextStyle(
color: MyTheme.white,
fontStyle: FontStyle.italic,
decoration: TextDecoration.underline),
),
),
)
],
),
),
Padding(
padding: const EdgeInsets.only(top: 30.0),
child: Container(
height: 45,
decoration: BoxDecoration(
border: Border.all(
color: MyTheme.app_accent_border, width: 1),
borderRadius:
const BorderRadius.all(Radius.circular(12.0))),
child: Buttons(
width: MediaQuery.of(context).size.width,
height: 50,
color: Colors.white.withOpacity(0.8),
shape: RoundedRectangleBorder(
borderRadius: const BorderRadius.all(
Radius.circular(11.0),
),
),
child: Text(
"login",
style: TextStyle(
color: MyTheme.app_accent_color,
fontSize: 17,
fontWeight: FontWeight.w500),
),
onPressed: () {
onPressedLogin();
},
),
),
),
],
),
),
Padding(
padding: const EdgeInsets.only(
top: 20,
),
child: Container(
alignment: Alignment.center,
child: Text(
LangText(context: context).getLocal()!.in_case_of_any_difficulties_contact_with_admin,
style: TextStyle(fontSize: 12, color: MyTheme.app_accent_border),
),
),
),
Padding(
padding: const EdgeInsets.only(
top: 20,
),
child: Container(
alignment: Alignment.center,
child: Text(
LangText(context: context).getLocal()!.or,
style: TextStyle(fontSize: 12, color: MyTheme.app_accent_border),
),
),
),
Padding(
padding: const EdgeInsets.only(top: 10.0),
child: Container(
alignment: Alignment.center,
height: 45,
child: Buttons(
alignment: Alignment.center,
//width: MediaQuery.of(context).size.width,
height: 50,
//color: Colors.white.withOpacity(0.8),
child: Text(
LangText(context: context).getLocal()!.registration,
style: TextStyle(
color: MyTheme.white,
fontSize: 17,
fontWeight: FontWeight.w500,
decoration: TextDecoration.underline
),
),
onPressed: () {
Navigator.push(context, MaterialPageRoute(builder: (context)=>Registration()));
},
),
),
),
],
),
),
);
}
loading() {
showDialog(
context: context,
builder: (context) {
loadingContext = context;
return AlertDialog(
content: Row(
children: [
const CircularProgressIndicator(),
const SizedBox(
width: 10,
),
Text(AppLocalizations.of(context)!.please_wait_ucf),
],
));
});
}
}

View File

@@ -0,0 +1,296 @@
import 'package:active_ecommerce_seller_app/custom/CommonFunctoins.dart';
import 'package:active_ecommerce_seller_app/custom/common_style.dart';
import 'package:active_ecommerce_seller_app/custom/customDateTimes.dart';
import 'package:active_ecommerce_seller_app/custom/localization.dart';
import 'package:active_ecommerce_seller_app/custom/route_transaction.dart';
import 'package:active_ecommerce_seller_app/helpers/shop_info_helper.dart';
import 'package:active_ecommerce_seller_app/my_theme.dart';
import 'package:active_ecommerce_seller_app/screens/account.dart';
import 'package:active_ecommerce_seller_app/screens/conversation.dart';
import 'package:active_ecommerce_seller_app/screens/home.dart';
import 'package:active_ecommerce_seller_app/screens/orders.dart';
import 'package:active_ecommerce_seller_app/screens/product/products.dart';
import 'package:active_ecommerce_seller_app/screens/profile.dart';
import 'dart:async';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'dart:ui';
import 'package:flutter/services.dart';
import 'package:flutter_gen/gen_l10n/app_localizations.dart';
import 'package:route_transitions/route_transitions.dart';
class Main extends StatefulWidget {
@override
_MainState createState() => _MainState();
}
class _MainState extends State<Main> {
int _currentIndex = 0;
String title = "";
var _children = [
Home(
fromBottombar: true,
),
Products(
fromBottomBar: true,
),
Orders(fromBottomBar: true),
];
final GlobalKey<ScaffoldState> _scaffoldKey = new GlobalKey<ScaffoldState>();
void onTapped(int i) {
if (i == 3) {
// setState(() {
// _scaffoldKey.currentState.openEndDrawer();
// });
//
slideRightWidget(newPage: Account(), context: context, opaque: false);
} else {
setState(() {
_currentIndex = i;
});
}
}
void initState() {
// TODO: implement initState
ShopInfoHelper().setShopInfo();
//re appear statusbar in case it was not there in the previous page
SystemChrome.setEnabledSystemUIMode(
SystemUiMode.manual, overlays: [SystemUiOverlay.top, SystemUiOverlay.bottom]);
super.initState();
}
onPop(value) {}
_onBackPressed(){
if (_currentIndex != 0) {
setState(() {
_currentIndex = 0;
});
} else {
CommonFunctions(context).appExitDialog();
}
}
@override
Widget build(BuildContext context) {
return WillPopScope(
onWillPop: () =>_onBackPressed(),
child: Scaffold(
key: _scaffoldKey,
appBar: buildAppBar(),
// drawer: MainDrawer(index: _currentIndex,),
extendBody: true,
body: _children[_currentIndex],
//specify the location of the FAB
bottomNavigationBar: Container(
height: 90,
// padding: const EdgeInsets.symmetric(vertical: 8.0),
child: BottomAppBar(
color: Colors.transparent,
clipBehavior: Clip.antiAlias,
child: BackdropFilter(
filter: ImageFilter.blur(sigmaX: 1.0, sigmaY: 1.0),
child: BottomNavigationBar(
type: BottomNavigationBarType.fixed,
onTap: onTapped,
currentIndex: _currentIndex,
backgroundColor: Colors.white.withOpacity(0.8),
fixedColor: MyTheme.app_accent_color,
unselectedItemColor: Color.fromRGBO(153, 153, 153, 1),
items: [
BottomNavigationBarItem(
icon: Padding(
padding: const EdgeInsets.symmetric(vertical: 8.0),
child: Image.asset(
"assets/icon/dashboard.png",
color: _currentIndex == 0
? MyTheme.app_accent_color
: Color.fromRGBO(153, 153, 153, 1),
height: 20,
),
),
label: LangText(context: context).getLocal()!.dashboard_ucf,
),
BottomNavigationBarItem(
icon: Padding(
padding: const EdgeInsets.symmetric(vertical: 8.0),
child: Image.asset(
"assets/icon/products.png",
color: _currentIndex == 1
? MyTheme.app_accent_color
: Color.fromRGBO(153, 153, 153, 1),
height: 20,
),
),
label: LangText(context: context).getLocal()!.products_ucf,
),
BottomNavigationBarItem(
icon: Padding(
padding: const EdgeInsets.symmetric(vertical: 8.0),
child: Image.asset(
"assets/icon/orders.png",
color: _currentIndex == 2
? MyTheme.app_accent_color
: Color.fromRGBO(153, 153, 153, 1),
height: 20,
),
),
label: LangText(context: context).getLocal()!.orders_ucf,
),
BottomNavigationBarItem(
icon: Padding(
padding: const EdgeInsets.symmetric(vertical: 8.0),
child: Image.asset(
"assets/icon/account.png",
color: _currentIndex == 3
? MyTheme.app_accent_color
: Color.fromRGBO(153, 153, 153, 1),
height: 20,
),
),
label: LangText(context: context).getLocal()!.account_ucf,
),
],
),
),
),
),
/*floatingActionButton: FloatingActionButton(
//backgroundColor: MyTheme.app_accent_color,
onPressed: () {
MyTransaction(context: context).push(Conversation());
},
child: Container(
margin: EdgeInsets.all(0.0),
child: IconButton(
icon: new Image.asset(
'assets/icon/chat.png',
height: 16,
width: 16,
),
tooltip: 'Action',
onPressed: () {
MyTransaction(context: context).push(Conversation());
})),
elevation: 0.0,
),*/
),
);
}
AppBar buildAppBar() {
return AppBar(
leadingWidth: 0.0,
backgroundColor: Colors.white,
elevation: 5,
centerTitle: false,
title: Row(
crossAxisAlignment: CrossAxisAlignment.center,
children: [
/*InkWell(child: Padding(
padding: const EdgeInsets.all(10.0),
child: Image.asset(
'assets/icon/back_arrow.png',
height: 14,
width: 14,
//color: MyTheme.dark_grey,
),
),
onTap: (){
setState(() {
_currentIndex = 0;
});
},),*/
_currentIndex == 0
? Image.asset(
'assets/logo/app_logo_small.png',
height: 34,
width: 26,
//color: MyTheme.dark_grey,
)
: Container(
width: 24,
height: 24,
child: IconButton(
splashRadius: 15,
padding: EdgeInsets.all(0.0),
onPressed: () {
setState(() {
_currentIndex = 0;
});
},
icon: Image.asset(
'assets/icon/back_arrow.png',
height: 20,
width: 20,
color: MyTheme.app_accent_color,
),
),
),
SizedBox(
width: 10,
),
Text(
getTitle(),
style: MyTextStyle()
.appbarText()
.copyWith(fontSize: 17, fontWeight: FontWeight.bold),
),
],
),
actions: [
Visibility(
visible: _currentIndex == 0,
child: Container(
alignment: Alignment.center,
child: Column(
crossAxisAlignment: CrossAxisAlignment.end,
mainAxisAlignment: MainAxisAlignment.center,
children: [
Text(
'${CustomDateTime.getDate}',
style: TextStyle(
color: MyTheme.app_accent_color,
fontSize: 10,
fontWeight: FontWeight.w400),
),
Text(
'${CustomDateTime.getDayName}',
style: TextStyle(
color: MyTheme.app_accent_color,
fontSize: 10,
fontWeight: FontWeight.w400),
),
],
)),
),
SizedBox(
width: 20,
),
],
);
}
String getTitle() {
switch (_currentIndex) {
case 0:
title = AppLocalizations.of(context)!.dashboard_ucf;
break;
case 1:
title = AppLocalizations.of(context)!.products_ucf;
break;
case 2:
title = AppLocalizations.of(context)!.orders_ucf;
break;
case 3:
title = AppLocalizations.of(context)!.profile_ucf;
break;
}
return title;
}
}

View File

@@ -0,0 +1,239 @@
///
/// AVANCED EXAMPLE:
/// Screen with map and search box on top. When the user selects a place through autocompletion,
/// the screen is moved to the selected location, a path that demonstrates the route is created, and a "start route"
/// box slides in to the screen.
///
import 'dart:async';
import 'dart:convert';
import 'package:active_ecommerce_seller_app/custom/buttons.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/shop_repository.dart';
import 'package:flutter/material.dart';
import 'package:google_maps_flutter/google_maps_flutter.dart';
import 'package:google_maps_place_picker_mb/google_maps_place_picker.dart';
import 'package:toast/toast.dart';
import 'package:flutter_gen/gen_l10n/app_localizations.dart';
class MapLocation extends StatefulWidget {
MapLocation({Key? key, this.lng,this.lat}) : super(key: key);
var lat ,lng;
@override
State<MapLocation> createState() => MapLocationState();
}
class MapLocationState extends State<MapLocation>
with SingleTickerProviderStateMixin {
PickResult? selectedPlace;
static LatLng kInitialPosition = LatLng(
51.52034098371205, -0.12637399200000668); // London , arbitary value
late GoogleMapController _controller;
Future<void> _onMapCreated(GoogleMapController controller) async {
_controller = controller;
String value = await DefaultAssetBundle.of(context)
.loadString('assets/map_style.json');
_controller.setMapStyle(value);
//setState(() {});
}
@override
void initState() {
// TODO: implement initState
super.initState();
if ((widget.lat =="" && widget.lng=="") || (widget.lat== null && widget.lng== null)) {
print("no lat");
setDummyInitialLocation();
}else{
print("widget.lat ${widget.lat}");
setInitialLocation();
}
}
setInitialLocation() {
kInitialPosition = LatLng(double.parse(widget.lat) ,double.parse(widget.lng) );
setState(() {});
}
setDummyInitialLocation() {
kInitialPosition = LatLng(
51.52034098371205, -0.12637399200000668); // London , arbitary value
setState(() {});
}
/*
updateInfo()async{
loadingShow(context);
Navigator.pop(loadingContext);
if (response.result) {
ToastComponent.showDialog(response.message, context,
backgroundColor: MyTheme.green, duration: 2, gravity: Toast.center);
}else{
ToastComponent.showDialog(response.message, context,
backgroundColor: MyTheme.red, duration: 2, gravity: Toast.center);
}
}*/
onTapPickHere(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);
}
@override
Widget build(BuildContext context) {
return PlacePicker(
hintText: AppLocalizations.of(context)!.your_delivery_location,
apiKey: OtherConfig.GOOGLE_MAP_API_KEY,
initialPosition: kInitialPosition,
useCurrentLocation: false,
selectInitialPosition: true,
//onMapCreated: _onMapCreated,
//initialMapType: MapType.terrain,
//usePlaceDetailSearch: true,
onPlacePicked: (result) {
print("kkkkkkkkkkk");
ToastComponent.showDialog(result.geometry!.location.lat.toString(),);
print("kkkkkkkkkkk");
print(result.geometry!.location.lat);
print(result.geometry!.location.lng);
selectedPlace = result;
// Navigator.of(context).pop();
// setState(() {});
},
//forceSearchOnZoomChanged: true,
//automaticallyImplyAppBarLeading: false,
//autocompleteLanguage: "ko",
//region: 'au',
//selectInitialPosition: true,
selectedPlaceWidgetBuilder:
(BuildContext context, selectedPlace, state, isSearchBarFocused) {
print("state: $state, isSearchBarFocused: $isSearchBarFocused");
print(selectedPlace.toString());
if(state==SearchingState.Searching){
print("------Searching-------");
}else{
print("-------$selectedPlace------");
}
print("-------$selectedPlace------");
/*
if(!isSearchBarFocused && state != SearchingState.Searching){
ToastComponent.showDialog("Hello", context,
gravity: Toast.center, duration: Toast.lengthLong);
}*/
return isSearchBarFocused
? Container()
: FloatingCard(
height: 50,
bottomPosition: 120.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(
AppLocalizations.of(context)!.calculating,
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(
AppLocalizations.of(context)!.update_location,
style: TextStyle(color: Colors.white,fontSize: 10),
),
onPressed: () {
// IMPORTANT: You MUST manage selectedPlace data yourself as using this build will not invoke onPlacePicker as
// this will override default 'Select here' Button.
/*print("do something with [selectedPlace] data");
print(selectedPlace.formattedAddress);
print(selectedPlace.geometry.location.lat);
print(selectedPlace.geometry.location.lng);*/
onTapPickHere(selectedPlace);
},
),
),
],
),
),
);
},
pinBuilder: (context, state) {
print("poin stat ${state.name}");
if (state == PinState.Idle) {
return Image.asset(
'assets/icon/delivery_map_icon.png',
height: 60,
);
} else {
return Image.asset(
'assets/icon/delivery_map_icon.png',
height: 80,
);
}
},
);
}
}

View File

@@ -0,0 +1,319 @@
import 'package:active_ecommerce_seller_app/const/app_style.dart';
import 'package:active_ecommerce_seller_app/custom/common_style.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/route_transaction.dart';
import 'package:active_ecommerce_seller_app/custom/submitButton.dart';
import 'package:active_ecommerce_seller_app/data_model/shop_info_response.dart';
import 'package:active_ecommerce_seller_app/data_model/shop_response.dart';
import 'package:active_ecommerce_seller_app/data_model/withdraw_list_response.dart';
import 'package:active_ecommerce_seller_app/dummy_data/withdrawList.dart';
import 'package:active_ecommerce_seller_app/helpers/shared_value_helper.dart';
import 'package:active_ecommerce_seller_app/helpers/shimmer_helper.dart';
import 'package:active_ecommerce_seller_app/my_theme.dart';
import 'package:active_ecommerce_seller_app/repositories/shop_repository.dart';
import 'package:active_ecommerce_seller_app/repositories/withdraw_repository.dart';
import 'package:active_ecommerce_seller_app/screens/withdraw_req.dart';
import 'package:flutter/material.dart';
class MoneyWithdraw extends StatefulWidget {
const MoneyWithdraw({Key? key}) : super(key: key);
@override
State<MoneyWithdraw> createState() => _MoneyWithdrawState();
}
class _MoneyWithdrawState extends State<MoneyWithdraw> {
List<Withdraw> _withdraws = [];
ShopInfo? _shop;
bool _isLoadData = false;
bool _isLoadShop = false;
int _page = 1;
Future<bool> getReviews() async {
var response = await WithdrawRepository().getList(_page);
_withdraws.addAll(response.data!);
_isLoadData = true;
setState(() {});
return true;
}
Future<bool> getShop() async {
var response = await ShopRepository().getShopInfo();
_shop = response.shopInfo;
_isLoadShop = true;
setState(() {});
return true;
}
fetchData() async {
await getReviews();
await getShop();
}
clearData() async {
_withdraws = [];
_isLoadData = false;
_shop = null;
_isLoadShop = false;
setState(() {});
}
Future<void> reFresh() async {
clearData();
await fetchData();
return Future.delayed(const Duration(microseconds: 100));
}
@override
void initState() {
fetchData();
super.initState();
}
@override
Widget build(BuildContext context) {
return Directionality(
textDirection: app_language_rtl.$! ? TextDirection.rtl : TextDirection.ltr,
child: Scaffold(
appBar: MyAppBar(
context: context,
title: LangText(context: context)
.getLocal()!
.money_withdraw_ucf)
.show(),
body: LayoutBuilder(builder: (context, constraints) {
return RefreshIndicator(
onRefresh: reFresh,
child: CustomScrollView(
physics: AlwaysScrollableScrollPhysics(),
slivers: [
SliverToBoxAdapter(
child: Container(
child: Column(
children: [
SizedBox(
height: 20,
),
buildTop2BoxContainer(context),
SizedBox(
height: 20,
),
Container(
child: _isLoadData
? withdrawListContainer()
: ShimmerHelper().buildListShimmer(
item_count: 15, item_height: 80.0),
),
],
),
),
)
],
),
);
}),
),
);
}/*
SingleChildScrollView buildSingleChildScrollView(BuildContext context) {
return SingleChildScrollView(
physics: BouncingScrollPhysics(),
child: Container(
child: Column(
children: [
buildTop2BoxContainer(context),
SizedBox(
height: 20,
),
Container(
child: _isLoadData
? productsContainer()
: ShimmerHelper()
.buildListShimmer(item_count: 20, item_height: 80.0),
),
],
),
),
);
}*/
Container buildTop2BoxContainer(BuildContext context) {
return Container(
margin: EdgeInsets.symmetric(horizontal: 15),
child: Row(
children: [
MyWidget.customCardView(
padding: EdgeInsets.all(10),
//decoration: BoxDecoration(
// borderRadius: BorderRadius.circular(10),
// //border: Border.all(color: MyTheme.app_accent_border),
// color: MyTheme.app_accent_color,
// ),
borderRadius: 10,
backgroundColor: MyTheme.app_accent_color,
elevation: 5,
height: 75,
width: DeviceInfo(context).getWidth() / 2 - 22,
child: Column(
crossAxisAlignment: CrossAxisAlignment.center,
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: [
Text(
LangText(context: context)
.getLocal()!
.pending_balance_ucf,
style: MyTextStyle().dashboardBoxText(context),
),
Text(
_isLoadShop ? _shop!.adminToPay.toString() : "...",
style: MyTextStyle().dashboardBoxNumber(context),
),
],
)),
SizedBox(width: AppStyles.itemMargin,),
SubmitBtn.show(
elevation: 5,
alignment: Alignment.center,
radius: 10,
borderColor: MyTheme.app_accent_color,
onTap: () {
MyTransaction(context: context)
.push(SendAWithdrwRequest())
.then((value) {
reFresh();
});
},
backgroundColor: MyTheme.app_accent_color_extra_light,
// decoration: BoxDecoration(
// borderRadius: BorderRadius.circular(10),
// border: Border.all(color: MyTheme.app_accent_color),
// color: MyTheme.app_accent_color_extra_light,
// ),
height: 75,
width: DeviceInfo(context).getWidth() / 2 - 25,
child: Container(
height: 75,
child: Column(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: [
Text(
LangText(context: context)
.getLocal()!
.send_withdraw_request_ucf,
style: MyTextStyle()
.dashboardBoxText(context)
.copyWith(color: MyTheme.app_accent_color),
),
Image.asset(
'assets/icon/add.png',
color: MyTheme.app_accent_color,
height: 18,
width: 18,
)
],
),
)),
],
),
);
}
Widget withdrawListContainer() {
return Container(
padding: EdgeInsets.symmetric(horizontal: 15),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
ListView.builder(
physics: NeverScrollableScrollPhysics(),
itemCount: _withdraws.length + 1,
shrinkWrap: true,
itemBuilder: (context, index) {
// print(index);
if (index == _withdraws.length) {
return SizedBox(
height: 80,
);
}
return withdrawItem(index, _withdraws[index].status!,
_withdraws[index].createdAt, _withdraws[index].amount!);
}),
],
),
);
}
Container withdrawItem(
int id, String withdrawStatus, withdrawCreatedAt, String withdrawPrice) {
return MyWidget.customCardView(
backgroundColor: MyTheme.white,
alignment: Alignment.center,
elevation: 5,
height: 90,
padding: EdgeInsets.symmetric(horizontal: 15, vertical: 20),
width: DeviceInfo(context).getWidth(),
margin: EdgeInsets.only(bottom: 20),
borderColor: MyTheme.light_grey,
borderRadius: 6,
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Container(
width: DeviceInfo(context).getWidth() - 160,
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisAlignment: MainAxisAlignment.center,
children: [
Text(
withdrawStatus,
style: TextStyle(
fontSize: 13,
fontWeight: FontWeight.bold,
color:withdrawStatus=="Pending"?MyTheme.grey_153: MyTheme.app_accent_color),
maxLines: 1,
overflow: TextOverflow.ellipsis,
),
SizedBox(
height: 5,
),
Row(
children: [
Image.asset(
"assets/icon/calender.png",
width: 12,
height: 12,
),
SizedBox(
width: 8,
),
Text(
withdrawCreatedAt,
style: TextStyle(
fontSize: 12,
color: MyTheme.grey_153,
),
maxLines: 1,
overflow: TextOverflow.ellipsis,
),
],
),
],
),
),
Text(withdrawPrice,
style: TextStyle(fontSize: 16,fontWeight: AppStyles.bold, color: MyTheme.app_accent_color),
),
],
)) as Container;
}
}

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,587 @@
import 'package:active_ecommerce_seller_app/const/DeliveryStatus.dart';
import 'package:active_ecommerce_seller_app/const/PaymentStatus.dart';
import 'package:active_ecommerce_seller_app/const/app_style.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/helpers/shared_value_helper.dart';
import 'package:active_ecommerce_seller_app/my_theme.dart';
import 'package:active_ecommerce_seller_app/repositories/order_repository.dart';
import 'package:active_ecommerce_seller_app/screens/order_details.dart';
import 'package:flutter/material.dart';
import 'package:shimmer/shimmer.dart';
class Orders extends StatefulWidget {
final bool fromBottomBar;
const Orders({Key? key, this.fromBottomBar = false}) : super(key: key);
@override
_OrdersState createState() => _OrdersState();
}
class _OrdersState extends State<Orders> {
ScrollController _scrollController = ScrollController();
ScrollController _xcrollController = ScrollController();
List<PaymentStatus> _paymentStatusList = PaymentStatus.getPaymentStatusList();
List<DeliveryStatus> _deliveryStatusList =
DeliveryStatus.getDeliveryStatusList();
PaymentStatus? _selectedPaymentStatus;
DeliveryStatus? _selectedDeliveryStatus;
List<DropdownMenuItem<PaymentStatus>>? _dropdownPaymentStatusItems;
List<DropdownMenuItem<DeliveryStatus>>? _dropdownDeliveryStatusItems;
//------------------------------------
List<dynamic> _orderList = [];
bool _isInitial = true;
int _page = 1;
int? _totalData = 0;
bool _showLoadingContainer = false;
String _defaultPaymentStatusKey = '';
String _defaultDeliveryStatusKey = '';
@override
void initState() {
init();
super.initState();
fetchData();
_xcrollController.addListener(() {
//print("position: " + _xcrollController.position.pixels.toString());
print("max: " + _xcrollController.position.maxScrollExtent.toString());
if (_xcrollController.position.pixels ==
_xcrollController.position.maxScrollExtent) {
setState(() {
_page++;
});
_showLoadingContainer = true;
fetchData();
}
});
}
@override
void dispose() {
// TODO: implement dispose
//_scrollController.dispose();
_xcrollController.dispose();
super.dispose();
}
init() {
_dropdownPaymentStatusItems =
buildDropdownPaymentStatusItems(_paymentStatusList);
_dropdownDeliveryStatusItems =
buildDropdownDeliveryStatusItems(_deliveryStatusList);
for (int x = 0; x < _dropdownPaymentStatusItems!.length; x++) {
if (_dropdownPaymentStatusItems![x].value!.option_key ==
_defaultPaymentStatusKey) {
_selectedPaymentStatus = _dropdownPaymentStatusItems![x].value;
}
}
for (int x = 0; x < _dropdownDeliveryStatusItems!.length; x++) {
if (_dropdownDeliveryStatusItems![x].value!.option_key ==
_defaultDeliveryStatusKey) {
_selectedDeliveryStatus = _dropdownDeliveryStatusItems![x].value;
}
}
}
reset() {
_orderList.clear();
_isInitial = true;
_page = 1;
_totalData = 0;
_showLoadingContainer = false;
}
resetFilterKeys() {
_defaultPaymentStatusKey = '';
_defaultDeliveryStatusKey = '';
setState(() {});
}
Future<void> _onRefresh() async {
reset();
resetFilterKeys();
for (int x = 0; x < _dropdownPaymentStatusItems!.length; x++) {
if (_dropdownPaymentStatusItems![x].value!.option_key ==
_defaultPaymentStatusKey) {
_selectedPaymentStatus = _dropdownPaymentStatusItems![x].value;
}
}
for (int x = 0; x < _dropdownDeliveryStatusItems!.length; x++) {
if (_dropdownDeliveryStatusItems![x].value!.option_key ==
_defaultDeliveryStatusKey) {
_selectedDeliveryStatus = _dropdownDeliveryStatusItems![x].value;
}
}
setState(() {});
fetchData();
}
fetchData() async {
var orderResponse = await OrderRepository().getOrderList(
page: _page,
payment_status: _selectedPaymentStatus!.option_key,
delivery_status: _selectedDeliveryStatus!.option_key);
//print("or:"+orderResponse.toJson().toString());
_orderList.addAll(orderResponse.data!);
_isInitial = false;
_totalData = orderResponse.meta!.total;
_showLoadingContainer = false;
setState(() {});
}
List<DropdownMenuItem<PaymentStatus>> buildDropdownPaymentStatusItems(
List _paymentStatusList) {
List<DropdownMenuItem<PaymentStatus>> items = [];
for (PaymentStatus item in _paymentStatusList as Iterable<PaymentStatus>) {
items.add(
DropdownMenuItem(
value: item,
child: Text(item.name),
),
);
}
return items;
}
List<DropdownMenuItem<DeliveryStatus>> buildDropdownDeliveryStatusItems(
List _deliveryStatusList) {
List<DropdownMenuItem<DeliveryStatus>> items = [];
for (DeliveryStatus item in _deliveryStatusList as Iterable<DeliveryStatus>) {
items.add(
DropdownMenuItem(
value: item,
child: Text(item.name),
),
);
}
return items;
}
@override
Widget build(BuildContext context) {
return Container(
child: Column(
mainAxisAlignment: MainAxisAlignment.end,
children: [
buildTopSection(context),
buildOrderListList(),
],
));
}
Column buildTopSection(BuildContext context) {
return Column(
children: [
buildAppBar(context),
buildFilterSection(context),
],
);
}
Visibility buildAppBar(BuildContext context) {
return Visibility(
visible: !widget.fromBottomBar,
child: SizedBox(
height: AppBar().preferredSize.height + 20,
child: MyAppBar(
context: context,
title:
LangText(context: context)
.getLocal()!
.orders_ucf)
.show(),
));
}
buildOrderListList() {
// if ( _isInitial && _orderList.length == 0) {
// return buildOrderShimmer();
// }
return RefreshIndicator(
color: MyTheme.app_accent_color,
backgroundColor: Colors.white,
displacement:0,
onRefresh: _onRefresh,
child:
_isInitial && _orderList.length == 0?buildOrderShimmer():
Container(
height: DeviceInfo(context).getHeight()-((widget.fromBottomBar?100:78)+AppBar().preferredSize.height),
child: CustomScrollView(
controller: _xcrollController,
slivers: [
SliverToBoxAdapter(
child: _orderList.length > 0
? ListView.separated(
separatorBuilder:(context,index) {
return SizedBox(height: 20,);
},
padding: EdgeInsets.only(
top: 20,
left: AppStyles.layoutMargin,
right: AppStyles.layoutMargin,
bottom: widget.fromBottomBar?95:15,
),
// physics: const BouncingScrollPhysics(
// parent: AlwaysScrollableScrollPhysics()),
itemCount: _orderList.length,
scrollDirection: Axis.vertical,
physics: BouncingScrollPhysics(
parent: NeverScrollableScrollPhysics()),
shrinkWrap: true,
itemBuilder: (context, index) {
return GestureDetector(
onTap: () {
Navigator.push(context,
MaterialPageRoute(builder: (context) {
return OrderDetails(
id: _orderList[index].id,
);
}));
},
child: buildOrderListItemCard(index),
);
},
)
: SizedBox(
height: DeviceInfo(context).getHeight() -
(AppBar().preferredSize.height + 75),
child: Center(
child: Text(LangText(context: context)
.getLocal()!
.
no_data_is_available)),
),
),
],
),
),
);
}
Container buildOrderShimmer() {
return Container(
height: DeviceInfo(context).getHeight() -
(AppBar().preferredSize.height + 90),
child: SingleChildScrollView(
child: ListView.builder(
controller: _scrollController,
itemCount: 10,
scrollDirection: Axis.vertical,
physics: NeverScrollableScrollPhysics(),
shrinkWrap: true,
itemBuilder: (context, index) {
return Padding(
padding:
const EdgeInsets.symmetric(horizontal: 16.0, vertical: 8.0),
child: Shimmer.fromColors(
baseColor: MyTheme.shimmer_base,
highlightColor: MyTheme.shimmer_highlighted,
child: Container(
height: 75,
width: double.infinity,
color: Colors.white,
),
),
);
},
)),
);
}
Widget buildOrderListItemCard(int index) {
return MyWidget.customCardView(
alignment: Alignment.center,
backgroundColor: MyTheme.app_accent_color_extra_light,
width: DeviceInfo(context).getWidth(),
elevation: 5.0,
borderRadius: 10,
height: 120,
borderColor: MyTheme.app_accent_border,
borderWidth: 1,
child: Padding(
padding: const EdgeInsets.all(16.0),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Column(
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisAlignment: MainAxisAlignment.center,
children: [
Padding(
padding: const EdgeInsets.only(bottom: 8.0),
child: Text(
_orderList[index].orderCode,
style: TextStyle(
color: MyTheme.app_accent_color,
fontSize: 13,
fontWeight: FontWeight.bold),
),
),
Padding(
padding: const EdgeInsets.only(bottom: 4.0),
child: Row(
children: [
Padding(
padding: app_language_rtl.$!
? const EdgeInsets.only(left: 8.0)
: const EdgeInsets.only(right: 8.0),
child: Icon(
Icons.calendar_today_outlined,
size: 16,
color: MyTheme.font_grey,
),
),
Text(_orderList[index].orderDate,
style: TextStyle(
color: MyTheme.font_grey,
fontSize: 12,
fontWeight: FontWeight.w400)),
],
),
),
Padding(
padding: const EdgeInsets.only(bottom: 4.0),
child: Row(
children: [
Padding(
padding: app_language_rtl.$!
? const EdgeInsets.only(left: 8.0)
: const EdgeInsets.only(right: 8.0),
child: Icon(
Icons.credit_card,
size: 16,
color: MyTheme.font_grey,
),
),
Text(
"${LangText(context: context)
.getLocal()!
.payment_status_ucf} - ",
style: TextStyle(
color: MyTheme.font_grey,
fontSize: 12,
fontWeight: FontWeight.w400)),
Text(
_orderList[index]
.paymentStatus
.toString()
.replaceRange(
0,
1,
_orderList[index]
.paymentStatus
.toString()
.characters
.first
.toString()
.toUpperCase()),
style: TextStyle(
color: _orderList[index].paymentStatus == "paid"
? Colors.green
: Colors.red,
fontSize: 12,
fontWeight: FontWeight.w600)),
/*Padding(
padding: app_language_rtl.$
? const EdgeInsets.only(right: 8.0)
: const EdgeInsets.only(left: 8.0),
child: buildPaymentStatusCheckContainer(
_orderList[index].paymentStatus),
),*/
],
),
),
Row(
children: [
Padding(
padding: app_language_rtl.$!
? const EdgeInsets.only(left: 8.0)
: const EdgeInsets.only(right: 8.0),
child: Icon(
Icons.local_shipping_outlined,
size: 16,
color: MyTheme.font_grey,
),
),
Text(
"${LangText(context: context)
.getLocal()!
.delivery_status_ucf} -",
style: TextStyle(
color: MyTheme.font_grey,
fontSize: 12,
fontWeight: FontWeight.w400)),
Text(_orderList[index].deliveryStatus,
style: TextStyle(
color: MyTheme.font_grey,
fontSize: 12,
fontWeight: FontWeight.w400)),
],
),
],
),
Text(
_orderList[index].total,
style: TextStyle(
color: MyTheme.app_accent_color,
fontSize: 16,
fontWeight: FontWeight.w500),
)
],
),
),
);
}
/*
Container buildPaymentStatusCheckContainer(String payment_status) {
return Container(
height: 16,
width: 16,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(16.0),
color: payment_status == "paid" ? Colors.green : Colors.red),
child: Padding(
padding: const EdgeInsets.all(3),
child: Icon(
payment_status == "paid" ? FontAwesome.check : FontAwesome.times,
color: Colors.white,
size: 10),
),
);
}
*/
buildFilterSection(BuildContext context) {
return Container(
margin: EdgeInsets.only(top: 10),
height: 40,
child: Padding(
padding: EdgeInsets.symmetric(horizontal: AppStyles.layoutMargin),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
MyWidget.customCardView(
borderRadius: 6,
elevation: 5,
borderColor: MyTheme.light_grey,
backgroundColor: Colors.white,
// decoration: BoxDecoration(
// color: Colors.white,
// borderRadius: BorderRadius.circular(6.0),
// border: Border.all(color: MyTheme.light_grey)
// /* border: Border.symmetric(
// vertical:
// BorderSide(color: MyTheme.light_grey, width: .5),
// horizontal:
// BorderSide(color: MyTheme.light_grey, width: 1))*/
// ),
padding: EdgeInsets.symmetric(horizontal: 10, vertical: 5),
height: 36,
width: MediaQuery
.of(context)
.size
.width * .42,
child: new DropdownButton<PaymentStatus>(
isExpanded: true,
icon: Padding(
padding: const EdgeInsets.symmetric(horizontal: 8.0),
child: Icon(Icons.expand_more, color: Colors.black54),
),
hint: Text(
LangText(context: context)
.getLocal()!
.all_ucf,
style: TextStyle(
color: Colors.black,
fontSize: 13,
),
),
iconSize: 14,
underline: SizedBox(),
value: _selectedPaymentStatus,
items: _dropdownPaymentStatusItems,
onChanged: (PaymentStatus? selectedFilter) {
setState(() {
_selectedPaymentStatus = selectedFilter;
});
reset();
fetchData();
},
),
),
MyWidget.customCardView(
borderRadius: 6,
elevation: 5,
borderColor: MyTheme.light_grey,
backgroundColor: MyTheme.white,
padding: EdgeInsets.symmetric(horizontal: 10, vertical: 5),
height: 36,
width: MediaQuery
.of(context)
.size
.width * .42,
child: new DropdownButton<DeliveryStatus>(
isExpanded: true,
icon: Padding(
padding: const EdgeInsets.symmetric(horizontal: 5.0),
child: Icon(Icons.expand_more, color: Colors.black54),
),
hint: Text(
LangText(context: context)
.getLocal()!
.all_ucf,
style: TextStyle(
color: Colors.black,
fontSize: 13,
),
),
iconSize: 14,
underline: SizedBox(),
value: _selectedDeliveryStatus,
items: _dropdownDeliveryStatusItems,
onChanged: (DeliveryStatus? selectedFilter) {
setState(() {
_selectedDeliveryStatus = selectedFilter;
});
reset();
fetchData();
},
),
),
/*MyWidget().myContainer(
borderRadius: 6.0,
borderColor: MyTheme.light_grey,
height: 36,
width: 36,
child: IconButton(
splashRadius: 20,
onPressed: (){
}, icon: Image.asset('assets/icon/search.png',width:16,height:16)),
)*/
],
),
));
}
}

View File

@@ -0,0 +1,592 @@
import 'package:active_ecommerce_seller_app/const/app_style.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/route_transaction.dart';
import 'package:active_ecommerce_seller_app/custom/select_payment_list.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/payment_type_response.dart';
import 'package:active_ecommerce_seller_app/data_model/seller_package_response.dart';
import 'package:active_ecommerce_seller_app/dummy_data/package_list.dart';
import 'package:active_ecommerce_seller_app/helpers/shared_value_helper.dart';
import 'package:active_ecommerce_seller_app/helpers/shimmer_helper.dart';
import 'package:active_ecommerce_seller_app/my_theme.dart';
import 'package:active_ecommerce_seller_app/repositories/payment_repository.dart';
import 'package:active_ecommerce_seller_app/repositories/payment_type_repository.dart';
import 'package:active_ecommerce_seller_app/repositories/shop_repository.dart';
import 'package:active_ecommerce_seller_app/screens/payments/bkash_screen.dart';
import 'package:active_ecommerce_seller_app/screens/payments/flutterwave_screen.dart';
import 'package:active_ecommerce_seller_app/screens/payments/iyzico_screen.dart';
import 'package:active_ecommerce_seller_app/screens/payments/nagad_screen.dart';
import 'package:active_ecommerce_seller_app/screens/payments/offline_payment_screen.dart';
import 'package:active_ecommerce_seller_app/screens/payments/paypal_screen.dart';
import 'package:active_ecommerce_seller_app/screens/payments/paystack_screen.dart';
import 'package:active_ecommerce_seller_app/screens/payments/paytm_screen.dart';
import 'package:active_ecommerce_seller_app/screens/payments/razorpay_screen.dart';
import 'package:active_ecommerce_seller_app/screens/payments/sslcommerz_screen.dart';
import 'package:active_ecommerce_seller_app/screens/payments/stripe_screen.dart';
import 'package:flutter/material.dart';
import 'package:toast/toast.dart';
class Packages extends StatefulWidget {
const Packages({Key? key}) : super(key: key);
@override
State<Packages> createState() => _PackagesState();
}
class _PackagesState extends State<Packages> {
List<Package> _packages = [];
bool _isFetchAllData = false;
List<PaymentTypeResponse> _onlinePaymentList = [];
List<PaymentTypeResponse> _offlinePaymentList = [];
final List<PaymentType> _paymentOptions = PaymentOption.getList();
PaymentTypeResponse? _selectedOnlinePaymentTypeValue;
PaymentTypeResponse? _selectedOfflinePaymentTypeValue;
PaymentType? _selectedPaymentOption;
Future<bool> getPackageList() async {
var response = await ShopRepository().getSellerPackageRequest();
_packages.addAll(response.data!);
setState(() {});
return true;
}
Future<bool> getOnlinePaymentList() async {
var response = await PaymentRepository().getPaymentResponseList(list: "online",mode: "seller_package");
_onlinePaymentList.addAll(response);
print(response.length);
if (_onlinePaymentList.isNotEmpty) {
_selectedOnlinePaymentTypeValue = _onlinePaymentList.first;
}
setState(() {});
return true;
}
Future<bool> getOfflinePaymentList() async {
var response = await PaymentRepository().getPaymentResponseList(list: "offline",mode: "seller_package");
_offlinePaymentList.addAll(response);
if (_offlinePaymentList.isNotEmpty) {
_selectedOfflinePaymentTypeValue = _offlinePaymentList.first;
}
setState(() {});
return true;
}
Future<bool> sendFreePackageReq(id) async {
var response = await ShopRepository().purchaseFreePackageRequest(id);
ToastComponent.showDialog(response.message,
gravity: Toast.center, duration: Toast.lengthLong);
setState(() {});
return true;
}
Future<bool> fetchData() async {
getOnlinePaymentList();
if (offline_payment_addon.$) {
getOfflinePaymentList();
}
await getPackageList();
_isFetchAllData = true;
setState(() {});
return true;
}
clearData() {
_onlinePaymentList = [];
_isFetchAllData = false;
_packages = [];
setState(() {});
}
Future<bool> resetData() {
clearData();
return fetchData();
}
Future<void> refresh() async {
await resetData();
return Future.delayed(const Duration(seconds: 0));
}
sendPaymentPage({int? package_id,String? payment_method_key, amount}) {
switch (payment_method_key) {
case "stripe":
MyTransaction(context: context).push(
StripeScreen(
amount: double.parse(amount.toString()),
payment_method_key: payment_method_key,
payment_type: "seller_package_payment",
package_id: package_id.toString(),
));
break;
case "iyzico":
MyTransaction(context: context).push(
IyzicoScreen(
amount: double.parse(amount.toString()),
payment_method_key: payment_method_key,
payment_type: "seller_package_payment",
package_id: package_id.toString(),
));
break;
case "bkash":
MyTransaction(context: context).push(
BkashScreen(
amount: double.parse(amount.toString()),
payment_method_key: payment_method_key,
payment_type: "seller_package_payment",
package_id: package_id.toString(),
));
break;
case "nagad":
MyTransaction(context: context).push(
NagadScreen(
amount: double.parse(amount.toString()),
payment_method_key: payment_method_key,
payment_type: "seller_package_payment",
package_id: package_id.toString(),
));
break;
case "paytm":
MyTransaction(context: context).push(
PaytmScreen(
amount: double.parse(amount.toString()),
payment_method_key: payment_method_key,
payment_type: "seller_package_payment",
package_id: package_id.toString(),
));
break;
case "paypal":
MyTransaction(context: context).push(PaypalScreen(
amount: double.parse(amount.toString()),
payment_method_key: payment_method_key,
payment_type: "seller_package_payment",
package_id: package_id.toString(),
));
break;
case "sslcommerz":
MyTransaction(context: context).push(SslCommerzScreen(
amount: double.parse(amount.toString()),
payment_method_key: payment_method_key,
payment_type: "seller_package_payment",
package_id: package_id.toString(),
));
break;
case "flutterwave":
MyTransaction(context: context).push(FlutterwaveScreen(
amount: double.parse(amount.toString()),
payment_method_key: payment_method_key,
payment_type: "seller_package_payment",
package_id: package_id.toString(),
));
break;
case "paystack":
MyTransaction(context: context).push(PaystackScreen(
amount: double.parse(amount.toString()),
payment_method_key: payment_method_key,
payment_type: "seller_package_payment",
package_id: package_id.toString(),
));
break;
case "razorpay":
MyTransaction(context: context).push(RazorpayScreen(
amount: double.parse(amount.toString()),
payment_method_key: payment_method_key,
payment_type: "seller_package_payment",
package_id: package_id.toString(),
));
break;
default:
print("Die ");
print("$payment_method_key ");
break;
}
}
@override
void initState() {
_selectedPaymentOption = _paymentOptions.first;
fetchData();
// TODO: implement initState
super.initState();
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: MyAppBar(
context: context,
title: LangText(context: context)
.getLocal()!
.premium_package_for_seller_ucf)
.show(),
body: RefreshIndicator(
onRefresh: refresh,
child: SingleChildScrollView(
physics: AlwaysScrollableScrollPhysics(),
child: Container(
padding: EdgeInsets.symmetric(horizontal: AppStyles.layoutMargin),
child: buildList(),
),
),
),
);
}
ListView buildList() {
return _isFetchAllData
? ListView.builder(
itemCount: _packages.length,
physics: NeverScrollableScrollPhysics(),
shrinkWrap: true,
itemBuilder: (context, index) {
return packageItem(
index,
context,
_packages[index].logo,
_packages[index].name!,
_packages[index].amount!,
_packages[index].duration.toString(),
_packages[index].productUploadLimit.toString(),
_packages[index].price,
_packages[index].id,
);
})
: loadingShimmer() as ListView;
}
Widget loadingShimmer() {
return ShimmerHelper().buildListShimmer(item_count: 10, item_height: 170.0);
}
Widget packageItem(int index,BuildContext context, String? url, String packageName,
String packagePrice, String packageDate, String packageProduct, price,package_id) {
print(url);
return MyWidget.customCardView(
elevation: 5,
margin: EdgeInsets.only(bottom: 20,top: index==0?20:0),
padding: EdgeInsets.symmetric(vertical: 15),
borderWidth: 1,
height: 170.0,
borderRadius: 6,
width: DeviceInfo(context).getWidth(),
borderColor: MyTheme.app_accent_border,
backgroundColor: MyTheme.app_accent_color_extra_light,
child: Column(
crossAxisAlignment: CrossAxisAlignment.center,
mainAxisAlignment: MainAxisAlignment.center,
children: [
// FadeInImage.assetNetwork(
// placeholder: "assets/logo/placeholder.png",
// image: url,
// height: 30,
// imageErrorBuilder: (context, object, stackTrace) {
// return Container(
// height: 30,
// width: 30,
// decoration: BoxDecoration(
// borderRadius: BorderRadius.circular(10),
// image:const DecorationImage(
// image: AssetImage("assets/logo/placeholder.png"),
// fit: BoxFit.cover
// )
// ),
// );
// },
// width: 30,
// fit: BoxFit.cover,
// ),
MyWidget.imageWithPlaceholder(width: 30.0, height: 30.0, url: url,backgroundColor: MyTheme.noColor),
Text(
packageName,
style: TextStyle(fontSize: 17, fontWeight: FontWeight.normal),
),
Container(
width: DeviceInfo(context).getWidth() / 2,
child: SubmitBtn.show(
height: 30,
width: DeviceInfo(context).getWidth() / 3,
onTap: () {
if(double.parse(price.toString())<=0){
sendFreePackageReq(package_id);
return;
}
if (offline_payment_addon.$) {
selectPaymentOption(price,package_id);
} else {
selectOnlinePaymentType(price,package_id);
}
},
backgroundColor: MyTheme.app_accent_color,
radius: 3.0,
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.end,
children: [
Text(
packagePrice,
style: TextStyle(
fontSize: 12,
fontWeight: FontWeight.bold,
color: MyTheme.white),
textAlign: TextAlign.end,
),
Text(
"/",
style: TextStyle(
fontSize: 12,
fontWeight: FontWeight.bold,
color: MyTheme.white),
),
Text(
packageDate +
'' +
LangText(context: context)
.getLocal()!
.days_ucf,
style: TextStyle(
fontSize: 10, color: MyTheme.light_grey),
textAlign: TextAlign.end,
),
],
)),
),
Container(
width: DeviceInfo(context).getWidth() / 2,
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Icon(
Icons.check_circle,
color: MyTheme.app_accent_color,
size: 11,
),
Text(
packageProduct +
" " +
LangText(context: context)
.getLocal()!
.product_upload_limit_ucf,
style:
TextStyle(fontSize: 12, fontWeight: FontWeight.normal),
),
],
),
),
],
));
}
selectOnlinePaymentType(amount,package_id) {
return showDialog(
context: context,
builder: (context) {
return StatefulBuilder(builder: (context, setState) {
return Container(
child: AlertDialog(
title: Text(LangText(context: context)
.getLocal()!
.select_payment_type_ucf),
content: DropdownButton<PaymentTypeResponse>(
underline: Container(),
elevation: 2,
isExpanded: true,
items: _onlinePaymentList
.map<DropdownMenuItem<PaymentTypeResponse>>(
(paymentType) => DropdownMenuItem(
child: Text(paymentType.name!),
value: paymentType,
))
.toList(),
value: _selectedOnlinePaymentTypeValue,
onChanged: (newValue) {
setState(() {
_selectedOnlinePaymentTypeValue = newValue;
});
},
),
actions: [
SubmitBtn.show(
radius: 5,
backgroundColor: MyTheme.red,
width: 40,
height: 30,
onTap: () {
Navigator.pop(context);
},
child: Text(
LangText(context: context).getLocal()!.cancel_ucf,
style: TextStyle(color: MyTheme.white, fontSize: 12),
),
padding: EdgeInsets.symmetric(horizontal: 5)),
SubmitBtn.show(
radius: 5,
backgroundColor: MyTheme.green,
width: 40,
height: 30,
onTap: () {
Navigator.pop(context);
sendPaymentPage(
payment_method_key: _selectedOnlinePaymentTypeValue!.payment_type_key,
amount: amount,
package_id: package_id
);
},
child: Text(
LangText(context: context).getLocal()!.continue_ucf,
style: TextStyle(color: MyTheme.white, fontSize: 12)),
padding: EdgeInsets.symmetric(horizontal: 5))
],
),
);
});
});
}
selectOfflinePaymentType(amount,package_id) {
return showDialog(
context: context,
builder: (context) {
return StatefulBuilder(builder: (context, setState) {
return Container(
child: AlertDialog(
title: Text(LangText(context: context)
.getLocal()!
.select_payment_type_ucf),
content: DropdownButton<PaymentTypeResponse>(
underline: Container(),
elevation: 2,
isExpanded: true,
items: _offlinePaymentList
.map<DropdownMenuItem<PaymentTypeResponse>>(
(paymentType) => DropdownMenuItem(
child: Text(paymentType.name!),
value: paymentType,
))
.toList(),
value: _selectedOfflinePaymentTypeValue,
onChanged: (newValue) {
setState(() {
_selectedOfflinePaymentTypeValue = newValue;
});
},
),
actions: [
SubmitBtn.show(
radius: 5,
backgroundColor: MyTheme.red,
width: 40,
height: 30,
onTap: () {
Navigator.pop(context);
},
child: Text(
LangText(context: context).getLocal()!.cancel_ucf,
style: TextStyle(color: MyTheme.white, fontSize: 12),
),
padding: EdgeInsets.symmetric(horizontal: 5)),
SubmitBtn.show(
radius: 5,
backgroundColor: MyTheme.green,
width: 40,
height: 30,
onTap: () {
Navigator.pop(context);
MyTransaction(context: context).push(
OfflineScreen(details:_selectedOfflinePaymentTypeValue!.details, offline_payment_id:_selectedOfflinePaymentTypeValue!.offline_payment_id,rechargeAmount:double.parse(amount.toString()),
package_id: package_id,
));
// sendPaymentPage(
// payment_method_key: _selectedOnlinePaymentTypeValue.key,
// amount: amount,
// );
},
child: Text(
LangText(context: context).getLocal()!.continue_ucf,
style: TextStyle(color: MyTheme.white, fontSize: 12)),
padding: EdgeInsets.symmetric(horizontal: 5))
],
),
);
});
});
}
selectPaymentOption(amount,package_id) {
return showDialog(
context: context,
builder: (context) {
return StatefulBuilder(builder: (context, setState) {
return Container(
child: AlertDialog(
title: Text(LangText(context: context)
.getLocal()!.select_payment_option_ucf),
content: DropdownButton<PaymentType>(
underline: Container(),
elevation: 2,
isExpanded: true,
items: _paymentOptions
.map<DropdownMenuItem<PaymentType>>(
(paymentType) => DropdownMenuItem(
child: Text(paymentType.value),
value: paymentType,
))
.toList(),
value: _selectedPaymentOption,
onChanged: (newValue) {
setState(() {
_selectedPaymentOption = newValue;
});
Navigator.pop(context);
if (_selectedPaymentOption!.key == "online") {
selectOnlinePaymentType(amount,package_id);
}
if (_selectedPaymentOption!.key == "offline") {
selectOfflinePaymentType(amount,package_id);
// MyTransaction(context: context).push(OfflineScreen());
}
},
),
actions: [
SubmitBtn.show(
radius: 5,
backgroundColor: MyTheme.red,
width: 40,
height: 30,
onTap: () {
Navigator.pop(context);
},
child: Text(
LangText(context: context).getLocal()!.cancel_ucf,
style: TextStyle(color: MyTheme.white, fontSize: 12),
),
padding: EdgeInsets.symmetric(horizontal: 5)),
],
),
);
});
});
}
}

View File

@@ -0,0 +1,291 @@
import 'package:active_ecommerce_seller_app/custom/buttons.dart';
import 'package:active_ecommerce_seller_app/custom/input_decorations.dart';
import 'package:active_ecommerce_seller_app/custom/intl_phone_input.dart';
import 'package:active_ecommerce_seller_app/custom/loading.dart';
import 'package:active_ecommerce_seller_app/custom/localization.dart';
import 'package:active_ecommerce_seller_app/custom/toast_component.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/address_repository.dart';
import 'package:active_ecommerce_seller_app/repositories/auth_repository.dart';
import 'package:active_ecommerce_seller_app/screens/password_otp.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:intl_phone_number_input/intl_phone_number_input.dart';
import 'package:toast/toast.dart';
import 'package:flutter_gen/gen_l10n/app_localizations.dart';
class PasswordForget extends StatefulWidget {
@override
_PasswordForgetState createState() => _PasswordForgetState();
}
class _PasswordForgetState extends State<PasswordForget> {
String _send_code_by = "email"; //phone or email
String initialCountry = 'US';
PhoneNumber phoneCode = PhoneNumber(isoCode: 'US');
var countries_code = <String?>[];
String? _phone = "";
//controllers
TextEditingController _emailController = TextEditingController();
TextEditingController _phoneNumberController = TextEditingController();
fetch_country() async {
var data = await AddressRepository().getCountryList();
data.countries!.forEach((c) => countries_code.add(c.code));
phoneCode = PhoneNumber(isoCode: data.countries!.first.code);
setState((){});
}
@override
void initState() {
//on Splash Screen hide statusbar
SystemChrome.setEnabledSystemUIMode(SystemUiMode.manual, overlays: [SystemUiOverlay.bottom]);
fetch_country();
super.initState();
}
@override
void dispose() {
//before going to other screen show statusbar
SystemChrome.setEnabledSystemUIMode(
SystemUiMode.manual, overlays: [SystemUiOverlay.top, SystemUiOverlay.bottom]);
super.dispose();
}
onPressSendCode() async {
var email = _emailController.text.toString();
var regEx = RegExp(r'^[A-Za-z0-9+_.-]+@(.+)+.(.+)$');
print(regEx.hasMatch(email));
if (_send_code_by == 'email' && (email == "" || !regEx.hasMatch(email) )) {
ToastComponent.showDialog(AppLocalizations.of(context)!.enter_email, gravity: Toast.center, duration: Toast.lengthLong);
return;
}else if (_send_code_by == 'phone' && _phone == "") {
ToastComponent.showDialog(
AppLocalizations.of(context)!.enter_phone_number_ucf,
gravity: Toast.center,
duration: Toast.lengthLong);
return;
}
Loading.setInstance(context);
Loading().show();
var passwordForgetResponse = await AuthRepository()
.getPasswordForgetResponse(
_send_code_by == 'email' ? email : _phone, _send_code_by);
Loading().hide();
if (passwordForgetResponse.result == false) {
ToastComponent.showDialog(passwordForgetResponse.message!, gravity: Toast.center, duration: Toast.lengthLong);
} else {
ToastComponent.showDialog(passwordForgetResponse.message!, gravity: Toast.center, duration: Toast.lengthLong);
Navigator.push(context, MaterialPageRoute(builder: (context) {
return PasswordOtp(
verify_by: _send_code_by,
email: email,
);
}));
}
}
@override
Widget build(BuildContext context) {
final _screen_height = MediaQuery.of(context).size.height;
final _screen_width = MediaQuery.of(context).size.width;
return Directionality(
textDirection: app_language_rtl.$! ? TextDirection.rtl : TextDirection.ltr,
child: Scaffold(
backgroundColor: MyTheme.app_accent_color,
body: Container(
width: double.infinity,
child: SingleChildScrollView(
child: Column(
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Padding(
padding: const EdgeInsets.only(top: 40.0, bottom: 15),
child: Container(
width: 75,
height: 75,
child:
Image.asset('assets/logo/white_logo.png'),
),
),
Padding(
padding: const EdgeInsets.only(bottom: 20.0),
child: Text(
"Forget Password ?",
style: TextStyle(
color: MyTheme.white,
fontSize: 18,
fontWeight: FontWeight.w600),
),
),
Container(
width: _screen_width * (3 / 4),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Padding(
padding: const EdgeInsets.only(bottom: 4.0),
child: Text(
_send_code_by == "email" ? "Email" : "Phone",
style:const TextStyle(
color: MyTheme.app_accent_border,
fontWeight: FontWeight.w400,
fontSize: 12),
),
),
if (_send_code_by == "email")
Padding(
padding: const EdgeInsets.only(bottom: 8.0),
child: Column(
crossAxisAlignment: CrossAxisAlignment.end,
children: [
Container(
height: 36,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(10),
color: Color.fromRGBO(255, 255, 255, 0.5)),
child: TextField(
style: TextStyle(color: MyTheme.white),
controller: _emailController,
autofocus: false,
decoration:
InputDecorations.buildInputDecoration_1(
borderColor: MyTheme.noColor,
hint_text: "seller@example.com",
hintTextColor: MyTheme.dark_grey
),
),
),
],
),
)
else
Padding(
padding: const EdgeInsets.only(bottom: 8.0),
child: Column(
crossAxisAlignment: CrossAxisAlignment.end,
children: [
Container(
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(10),
color: Color.fromRGBO(255, 255, 255, 0.5)),
height: 36,
child: CustomInternationalPhoneNumberInput(
countries:countries_code,
onInputChanged: (PhoneNumber number) {
print(number.phoneNumber);
setState(() {
_phone = number.phoneNumber;
});
},
onInputValidated: (bool value) {
print('on input validation ${value}');
},
selectorConfig: SelectorConfig(
selectorType: PhoneInputSelectorType.DIALOG,
),
ignoreBlank: false,
autoValidateMode: AutovalidateMode.disabled,
selectorTextStyle:
TextStyle(color: MyTheme.font_grey),
textStyle: TextStyle(color: Colors.white54),
initialValue: phoneCode,
textFieldController: _phoneNumberController,
formatInput: true,
keyboardType: TextInputType.numberWithOptions(
signed: true, decimal: true),
inputDecoration:
InputDecorations.buildInputDecoration_phone(
hint_text: "01XXX XXX XXX"),
onSaved: (PhoneNumber number) {
print('On Saved: $number');
},
),
),
],
),
),
if(otp_addon_installed.$)
Padding(
padding: const EdgeInsets.only(bottom: 8.0),
child: Row(
children: [
Spacer(),
GestureDetector(
onTap: () {
setState(() {
_send_code_by = _send_code_by == "email" ?"phone":"email";
});
},
child: Text(
"or, Login with ${_send_code_by == "email" ?'a phone':'an email'}",
style: TextStyle(
color: MyTheme.white,
fontStyle: FontStyle.italic,
decoration: TextDecoration.underline),
),
),
],
),
),
Text(
_send_code_by =="email"?
LangText(context: context).getLocal()!.we_will_send_you_a_OTP_code_if_the_mail_id_is_correct_ucf:LangText(context: context).getLocal()!.we_will_send_you_a_OTP_code_if_the_phone_no_is_correct_ucf,
style: TextStyle(
fontSize: 12,
color: MyTheme.grey_153,
),
textHeightBehavior: TextHeightBehavior(applyHeightToFirstAscent: false),
softWrap: false,
),
Padding(
padding: const EdgeInsets.only(top: 40.0),
child: Container(
height: 45,
decoration: BoxDecoration(
border: Border.all(
color: MyTheme.textfield_grey, width: 1),
borderRadius: const BorderRadius.all(
Radius.circular(12.0))),
child: Buttons(
width: MediaQuery.of(context).size.width,
//height: 50,
color: MyTheme.white,
shape: RoundedRectangleBorder(
borderRadius: const BorderRadius.all(
Radius.circular(12.0))),
child: Text(
"Send Code",
style: TextStyle(
color: MyTheme.app_accent_color,
fontSize: 14,
fontWeight: FontWeight.w600),
),
onPressed: () {
onPressSendCode();
},
),
),
),
],
),
)
],
)),
),
),
);
}
}

View File

@@ -0,0 +1,331 @@
import 'package:active_ecommerce_seller_app/custom/buttons.dart';
import 'package:active_ecommerce_seller_app/custom/input_decorations.dart';
import 'package:active_ecommerce_seller_app/custom/toast_component.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/auth_repository.dart';
import 'package:active_ecommerce_seller_app/screens/login.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:toast/toast.dart';
import 'package:flutter_gen/gen_l10n/app_localizations.dart';
class PasswordOtp extends StatefulWidget {
PasswordOtp({Key? key, this.verify_by = "email", this.email,})
: super(key: key);
final String verify_by;
final String? email;
@override
_PasswordOtpState createState() => _PasswordOtpState();
}
class _PasswordOtpState extends State<PasswordOtp> {
//controllers
TextEditingController _codeController = TextEditingController();
TextEditingController _passwordController = TextEditingController();
TextEditingController _passwordConfirmController = TextEditingController();
@override
void initState() {
//on Splash Screen hide statusbar
SystemChrome.setEnabledSystemUIMode(SystemUiMode.manual, overlays: [SystemUiOverlay.bottom]);
super.initState();
}
@override
void dispose() {
//before going to other screen show statusbar
SystemChrome.setEnabledSystemUIMode(
SystemUiMode.manual, overlays: [SystemUiOverlay.top, SystemUiOverlay.bottom]);
super.dispose();
}
onPressConfirm() async {
var code = _codeController.text.toString();
var password = _passwordController.text.toString();
var password_confirm = _passwordConfirmController.text.toString();
if (code == "") {
ToastComponent.showDialog(AppLocalizations.of(context)!.enter_the_code, gravity: Toast.center, duration: Toast.lengthLong);
return;
} else if (password == "") {
ToastComponent.showDialog(AppLocalizations.of(context)!.enter_password, gravity: Toast.center, duration: Toast.lengthLong);
return;
} else if (password_confirm == "") {
ToastComponent.showDialog(AppLocalizations.of(context)!.confirm_your_password, gravity: Toast.center, duration: Toast.lengthLong);
return;
} else if (password.length < 6) {
ToastComponent.showDialog(
AppLocalizations.of(context)!.password_must_contain_at_least_6_characters, gravity: Toast.center, duration: Toast.lengthLong);
return;
} else if (password != password_confirm) {
ToastComponent.showDialog(AppLocalizations.of(context)!.passwords_do_not_match, gravity: Toast.center, duration: Toast.lengthLong);
return;
}
var passwordConfirmResponse =
await AuthRepository().getPasswordConfirmResponse(code, password);
if (passwordConfirmResponse.result == false) {
ToastComponent.showDialog(passwordConfirmResponse.message!, gravity: Toast.center, duration: Toast.lengthLong);
} else {
ToastComponent.showDialog(passwordConfirmResponse.message!, gravity: Toast.center, duration: Toast.lengthLong);
Navigator.push(context, MaterialPageRoute(builder: (context) {
return Login();
}));
}
}
onTapResend() async {
var passwordResendCodeResponse = await AuthRepository()
.getPasswordResendCodeResponse(widget.email, widget.verify_by);
if (passwordResendCodeResponse.result == false) {
ToastComponent.showDialog(passwordResendCodeResponse.message!, gravity: Toast.center, duration: Toast.lengthLong);
} else {
ToastComponent.showDialog(passwordResendCodeResponse.message!, gravity: Toast.center, duration: Toast.lengthLong);
}
}
@override
Widget build(BuildContext context) {
String _verify_by = widget.verify_by; //phone or email
final _screen_height = MediaQuery.of(context).size.height;
final _screen_width = MediaQuery.of(context).size.width;
return Directionality(
textDirection: app_language_rtl.$! ? TextDirection.rtl : TextDirection.ltr,
child: Scaffold(
backgroundColor:MyTheme.app_accent_color,
body: Stack(
children: [
Container(
width: double.infinity,
child: SingleChildScrollView(
child: Column(
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Padding(
padding: const EdgeInsets.only(top: 40.0, bottom: 15),
child: Container(
width: 75,
height: 75,
child:
Image.asset('assets/logo/white_logo.png'),
),
),
Padding(
padding: const EdgeInsets.only(bottom: 20.0),
child: Text(
AppLocalizations.of(context)!.reset_password_ucf,
style: TextStyle(
color: MyTheme.white,
fontSize: 18,
fontWeight: FontWeight.w600),
),
),
Padding(
padding: const EdgeInsets.only(bottom: 16.0),
child: Container(
width: _screen_width * (3 / 4),
child: Text(
AppLocalizations.of(context)!.enter_the_verification_code_that_sent_to_your_email_recently,
textAlign: TextAlign.center,
style: TextStyle(
color: MyTheme.dark_grey, fontSize: 14))
),
),
Container(
width: _screen_width * (3 / 4),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Padding(
padding: const EdgeInsets.only(bottom: 8.0),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Padding(
padding: const EdgeInsets.only(bottom: 8.0),
child: Text(
'Verification Code',
style: TextStyle(
fontSize: 12,
color: MyTheme.white,
),
textHeightBehavior: TextHeightBehavior(applyHeightToFirstAscent: false),
softWrap: false,
),
),
Container(
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(10),
color: Color.fromRGBO(255, 255, 255, 0.5)),
height: 36,
child: TextField(
controller: _codeController,
autofocus: false,
decoration:
InputDecorations.buildInputDecoration_1(
borderColor: MyTheme.noColor,
hint_text: "A X B 4 J H"),
),
),
],
),
),
Padding(
padding: const EdgeInsets.only(bottom: 4.0),
child: Text(
AppLocalizations.of(context)!.password_ucf,
style: TextStyle(
color: MyTheme.app_accent_color,
fontWeight: FontWeight.w600),
),
),
Padding(
padding: const EdgeInsets.only(bottom: 8.0),
child: Text(
'New Password',
style: TextStyle(
fontSize: 12,
color: MyTheme.white,
),
textHeightBehavior: TextHeightBehavior(applyHeightToFirstAscent: false),
softWrap: false,
),
),
Padding(
padding: const EdgeInsets.only(bottom: 8.0),
child: Column(
crossAxisAlignment: CrossAxisAlignment.end,
children: [
Container(
height: 36,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(10),
color: Color.fromRGBO(255, 255, 255, 0.5)),
child: TextField(
controller: _passwordController,
autofocus: false,
obscureText: true,
enableSuggestions: false,
autocorrect: false,
decoration:
InputDecorations.buildInputDecoration_1(
borderColor: MyTheme.noColor,
hint_text: "• • • • • • • •"),
),
),
Padding(
padding: const EdgeInsets.only(top: 8.0),
child: Text(
AppLocalizations.of(context)!.password_must_contain_at_least_6_characters,
style: TextStyle(
color: MyTheme.textfield_grey,
fontStyle: FontStyle.italic),
),
)
],
),
),
Padding(
padding: const EdgeInsets.only(bottom: 4.0),
child: Text(
AppLocalizations.of(context)!.retype_password_ucf,
style: TextStyle(
color: MyTheme.app_accent_color,
fontWeight: FontWeight.w600),
),
),
Padding(
padding: const EdgeInsets.only(bottom: 8.0),
child: Text(
'Confirm Password',
style: TextStyle(
fontSize: 12,
color: MyTheme.white,
),
textHeightBehavior: TextHeightBehavior(applyHeightToFirstAscent: false),
softWrap: false,
),
),
Padding(
padding: const EdgeInsets.only(bottom: 8.0),
child: Container(
height: 36,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(10),
color: Color.fromRGBO(255, 255, 255, 0.5)),
child: TextField(
controller: _passwordConfirmController,
autofocus: false,
obscureText: true,
enableSuggestions: false,
autocorrect: false,
decoration: InputDecorations.buildInputDecoration_1(
borderColor: MyTheme.noColor,
hint_text: "• • • • • • • •"),
),
),
),
Padding(
padding: const EdgeInsets.only(top: 40.0),
child: Container(
height: 45,
decoration: BoxDecoration(
border: Border.all(
color: MyTheme.textfield_grey, width: 1),
borderRadius: const BorderRadius.all(
Radius.circular(12.0))),
child: Buttons(
width: MediaQuery.of(context).size.width,
//height: 50,
color: MyTheme.white,
shape: RoundedRectangleBorder(
borderRadius: const BorderRadius.all(
Radius.circular(12.0))),
child: Text(
AppLocalizations.of(context)!.confirm_ucf,
style: TextStyle(
color: MyTheme.app_accent_color,
fontSize: 14,
fontWeight: FontWeight.w600),
),
onPressed: () {
onPressConfirm();
},
),
),
),
],
),
),
Padding(
padding: const EdgeInsets.only(top: 100),
child: InkWell(
onTap: () {
onTapResend();
},
child: Text(AppLocalizations.of(context)!.resend_code_ucf,
textAlign: TextAlign.center,
style: TextStyle(
color: MyTheme.app_accent_color,
decoration: TextDecoration.underline,
fontSize: 13)),
),
),
],
)),
)
],
),
),
);
}
}

View File

@@ -0,0 +1,205 @@
import 'package:active_ecommerce_seller_app/custom/device_info.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/data_model/payment_history_response.dart';
import 'package:active_ecommerce_seller_app/dummy_data/payment_history_list.dart';
import 'package:active_ecommerce_seller_app/helpers/shimmer_helper.dart';
import 'package:active_ecommerce_seller_app/my_theme.dart';
import 'package:active_ecommerce_seller_app/repositories/payment_history_repository.dart';
import 'package:flutter/material.dart';
import 'package:flutter_gen/gen_l10n/app_localizations.dart';
class PaymentHistory extends StatefulWidget {
const PaymentHistory({Key? key}) : super(key: key);
@override
_PaymentHistoryState createState() => _PaymentHistoryState();
}
class _PaymentHistoryState extends State<PaymentHistory> {
ScrollController _scrollController = new ScrollController(initialScrollOffset: 0);
int _page=1;
bool _isFetchAllData= false,_showMoreProductLoadingContainer = false;
List<Payment> _payments = [];
Future<bool> getPaymentHistory()async{
var response = await PaymentHistoryRepository().getList(page: _page);
_payments.addAll(response.data!);
setState(() {});
return true;
}
fetchData()async{
await getPaymentHistory();
_isFetchAllData= true;
setState(() {
});
}
clearAllData(){
_scrollController = new ScrollController(initialScrollOffset: 0);
_page=1;
_isFetchAllData= false;
_payments = [];
setState(() {
});
}
resetData(){
clearAllData();
fetchData();
}
Future<void> refresh(){
resetData();
return Future.delayed(const Duration(seconds: 1));
}
scrollControllerPosition(){
_scrollController.addListener(() {
print("po");
//print("position: " + _xcrollController.position.pixels.toString());
//print("max: " + _xcrollController.position.maxScrollExtent.toString());
if (_scrollController.position.pixels ==
_scrollController.position.maxScrollExtent) {
_showMoreProductLoadingContainer = true;
setState(() {
_page++;
});
getPaymentHistory();
}
});
}
@override
void initState() {
// TODO: implement initState
scrollControllerPosition();
fetchData();
super.initState();
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: MyAppBar(
title: AppLocalizations.of(context)!.payment_history_ucf,
context: context)
.show(),
body: RefreshIndicator(
onRefresh: refresh,
child: CustomScrollView(
slivers: [
SliverToBoxAdapter(
child: Container(
child: Column(
children: [
Container(
child:_isFetchAllData? paymentHistoryContainer():ShimmerHelper().buildListShimmer(item_count: 20,item_height: 80.0),
),
],
),
),
),
],
),
),
);
}
Widget paymentHistoryContainer() {
return Container(
padding: EdgeInsets.symmetric(horizontal: 15),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
ListView.builder(
physics: NeverScrollableScrollPhysics(),
itemCount: _payments.length+1,
shrinkWrap: true,
itemBuilder: (context,index){
// print(index);
if(index==_payments.length){
return moreProductLoading();
}
return
productItem(index,_payments[index].paymentMethod!,_payments[index].paymentDate,_payments[index].amount.toString());
}),
],
),
);
}
Container productItem(int index,String paymentMethod,paymentDate,String amount){
return MyWidget.customCardView(
backgroundColor: MyTheme.white,
elevation: 5,
height: 80,
padding: EdgeInsets.symmetric(horizontal: 10,vertical: 15),
width: DeviceInfo(context).getWidth(),
margin: EdgeInsets.only(bottom: 20,top: index==0?20:0),
borderColor: MyTheme.light_grey,
alignment: Alignment.center,
borderRadius: 6,
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Column(
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisAlignment: MainAxisAlignment.center,
children: [
Text(paymentMethod,style: TextStyle(fontSize: 13,fontWeight: FontWeight.bold,color: MyTheme.app_accent_color),maxLines: 1,overflow: TextOverflow.ellipsis,),
SizedBox(height: 5,),
Container(
width: DeviceInfo(context).getWidth()/3,
child: Row(
children: [
Image.asset("assets/icon/calender.png",width: 12,height: 12,),
SizedBox(width: 8,),
Text(paymentDate,style: TextStyle(fontSize: 12,color: MyTheme.grey_153,),maxLines:1,overflow: TextOverflow.ellipsis,),
],
),
),
],
),
Text(amount,style: TextStyle(fontSize: 16,color: MyTheme.app_accent_color,fontWeight: FontWeight.w500)),
],
)
) as Container;
}
Widget moreProductLoading() {
return _showMoreProductLoadingContainer? Container(
alignment: Alignment.center,
child: SizedBox(height: 40,width: 40,child: Row(
children: [
SizedBox(width: 2,height: 2,),
CircularProgressIndicator(),
SizedBox(width: 2,height: 2,),
],
),),
):SizedBox(height: 5,width: 5,);
}
}

View File

@@ -0,0 +1,412 @@
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/my_theme.dart';
import 'package:active_ecommerce_seller_app/repositories/shop_repository.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:toast/toast.dart';
import 'package:validators/validators.dart';
class PaymentSetting extends StatefulWidget {
const PaymentSetting({Key? key}) : super(key: key);
@override
State<PaymentSetting> createState() => _PaymentSettingState();
}
class _PaymentSettingState extends State<PaymentSetting> {
TextEditingController bankNameEditingController = TextEditingController(text: "");
TextEditingController accountNameEditingController = TextEditingController(text: "");
TextEditingController accountNumberEditingController = TextEditingController(text: "");
TextEditingController bankRoutingNumberEditingController = TextEditingController(text: "");
late BuildContext loadingContext;
String? bankName,accountName,accountNumber,bankRoutingNumber,bankPayment,cashPayment;
setDataInEditController(){
bankNameEditingController.text=bankName!;
accountNameEditingController.text = accountName!;
accountNumberEditingController.text = accountNumber!;
bankRoutingNumberEditingController.text = bankRoutingNumber!;
}
bool _faceData=false;
String error= "Provide Number";
setDataInVariable(){
bankName=bankNameEditingController.text;
accountName=accountNameEditingController.text ;
accountNumber=accountNumberEditingController.text ;
bankRoutingNumber = bankRoutingNumberEditingController.text ;
}
Future<bool> _getAccountInfo() async {
var response = await ShopRepository().getShopInfo();
Navigator.pop(loadingContext);
bankName=response.shopInfo!.bankName;
accountName=response.shopInfo!.bankAccName;
accountNumber=response.shopInfo!.bankAccNo;
bankRoutingNumber=response.shopInfo!.bankRoutingNo.toString();
bankPayment=response.shopInfo!.bank_payment_status.toString();
cashPayment=response.shopInfo!.cashOnDeliveryStatus.toString();
print(bankPayment);
setDataInEditController();
_faceData=true;
setState(() {});
return true;
}
faceData(){
WidgetsBinding.instance
.addPostFrameCallback((_) => loadingShow(context));
_getAccountInfo();
}
updateInfo()async{
setDataInVariable();
var postBody = jsonEncode({
"cash_on_delivery_status": cashPayment,
"bank_payment_status": bankPayment,
"bank_name":bankName,
"bank_acc_name": accountName,
"bank_acc_no": accountNumber,
"bank_routing_no": bankRoutingNumber,
});
loadingShow(context);
var response = await ShopRepository().updateShopSetting(postBody);
Navigator.pop(loadingContext);
if (response.result!) {
ToastComponent.showDialog(response.message,
gravity: Toast.center,
duration: 3,
textStyle: TextStyle(color: MyTheme.black),
);
}else{
ToastComponent.showDialog(response.message,
gravity: Toast.center,
duration: 3,
textStyle: TextStyle(color: MyTheme.black),
);
}
}
@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()!
.payment_settings_ucf)
.show(),
body: SingleChildScrollView(
child: Container(
padding: EdgeInsets.symmetric(horizontal: 15),
child: Column(
children: [
Container(
width: DeviceInfo(context).getWidth(),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Text(
LangText(context: context)
.getLocal()!
.bank_payment,
style: TextStyle(
fontSize: 12,
color: MyTheme.font_grey,
fontWeight: FontWeight.bold),
),
Switch(
activeColor: MyTheme.green,
inactiveThumbColor: Colors.grey,
value: bankPayment=="1",
onChanged: (value) {
if(value){
bankPayment="1";
}else{
bankPayment="0";
}
setState(() {
});
},
),
],
),
),
SizedBox(
height: 14,
),
Container(
width: DeviceInfo(context).getWidth(),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Text(
LangText(context: context)
.getLocal()!
.cash_payment,
style: TextStyle(
fontSize: 12,
color: MyTheme.font_grey,
fontWeight: FontWeight.bold),
),
Switch(
activeColor: MyTheme.green,
inactiveThumbColor: Colors.grey,
value: cashPayment=="1",
onChanged: (value) {
if(value){
cashPayment="1";
}else{
cashPayment="0";
}
setState(() {
});
},
),
],
),
),
SizedBox(
height: 14,
),
buildBankName(context),
SizedBox(
height: 14,
),
buildBankAccountName(context),
SizedBox(
height: 14,
),
buildBankAccountNumber(context),
SizedBox(
height: 14,
),
buildBankRoutingNumber(context),
SizedBox(
height: 30,
),
SubmitBtn.show(
elevation: 5,
onTap: () {
updateInfo();
},
alignment: Alignment.center,
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),
)),
],
),
),
),
);
}
Column buildBankRoutingNumber(BuildContext context) {
return Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
LangText(context: context)
.getLocal()!
.bank_routing_number_ucf,
style: TextStyle(
fontSize: 12,
color: MyTheme.font_grey,
fontWeight: FontWeight.bold),
),
SizedBox(
height: 10,
),
MyWidget.customCardView(
width: DeviceInfo(context).getWidth(),
height: 45,
borderRadius: 10,
elevation: 5,
backgroundColor: MyTheme.white,
child: TextField(
onChanged: (data){
if(!isNumeric(data)){
bankRoutingNumberEditingController.text="";
}
print(data);
},
keyboardType:TextInputType.number ,
controller: bankRoutingNumberEditingController,
decoration: InputDecorations.buildInputDecoration_1(
hint_text: "91400554",
borderColor: MyTheme.noColor,
hintTextColor: MyTheme.grey_153),
),
),
],
);
}
Column buildBankAccountNumber(BuildContext context) {
return Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
LangText(context: context)
.getLocal()!
.bank_account_number,
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: accountNumberEditingController,
decoration: InputDecorations.buildInputDecoration_1(
hint_text: "7131259163",
borderColor: MyTheme.noColor,
hintTextColor: MyTheme.grey_153),
),
),
],
);
}
Column buildBankAccountName(BuildContext context) {
return Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
LangText(context: context)
.getLocal()!
.bank_account_name,
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: accountNameEditingController,
decoration: InputDecorations.buildInputDecoration_1(
hint_text: "Elmira Wisozk",
borderColor: MyTheme.noColor,
hintTextColor: MyTheme.grey_153),
),
),
],
);
}
Column buildBankName(BuildContext context) {
return Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
LangText(context: context)
.getLocal()!
.bank_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: bankNameEditingController,
decoration: InputDecorations.buildInputDecoration_1(
hint_text: "Plains Commerce Bank",
borderColor: MyTheme.noColor,
hintTextColor: 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}"),
],
));
});
}
}

View File

@@ -0,0 +1,195 @@
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/payment_repository.dart';
import 'package:flutter/material.dart';
import 'package:toast/toast.dart';
import 'dart:convert';
import 'package:webview_flutter/webview_flutter.dart';
import 'package:flutter_gen/gen_l10n/app_localizations.dart';
class BkashScreen extends StatefulWidget {
double amount;
String payment_type;
String? payment_method_key;
String? package_id;
BkashScreen({Key? key,
this.amount = 0.00,
this.payment_type = "",
this.payment_method_key = "", this.package_id})
: super(key: key);
@override
_BkashScreenState createState() => _BkashScreenState();
}
class _BkashScreenState extends State<BkashScreen> {
int _combined_order_id = 0;
bool _order_init = false;
String? _initial_url = "";
bool _initial_url_fetched = false;
WebViewController _webViewController = WebViewController()
..setJavaScriptMode(JavaScriptMode.unrestricted);
String? _token = "";
bool showLoading = false;
@override
void initState() {
// TODO: implement initState
super.initState();
_webViewController.setNavigationDelegate(
NavigationDelegate(
onProgress: (int progress) {
// Update loading bar.
},
onPageStarted: (String url) {},
onPageFinished: (String page) {
if (page.contains("/bkash/api/success")) {
getData();
} else if (page.contains("/bkash/api/fail")) {
ToastComponent.showDialog("Payment cancelled",
gravity: Toast.center, duration: Toast.lengthLong);
Navigator.of(context).pop();
return;
}
},
onWebResourceError: (WebResourceError error) {},
),
);
// on cart payment need proper order id
getSetInitialUrl();
}
getSetInitialUrl() async {
var bkashUrlResponse = await PaymentRepository().getBkashBeginResponse(
widget.payment_type, _combined_order_id, widget.package_id,
widget.amount);
if (bkashUrlResponse.result == false) {
ToastComponent.showDialog(bkashUrlResponse.message!, gravity: Toast.center,
duration: Toast.lengthLong);
Navigator.of(context).pop();
return;
}
_token = bkashUrlResponse.token;
_initial_url = bkashUrlResponse.url;
_initial_url_fetched = true;
_webViewController.loadRequest(Uri.parse(_initial_url!));
setState(() {});
// print(_initial_url);
// print(_initial_url_fetched);
}
@override
Widget build(BuildContext context) {
return Scaffold(
backgroundColor: Colors.white,
appBar: buildAppBar(context),
body: buildBody(),
);
}
buildBody() {
if (_initial_url_fetched == false) {
return Container(
child: Center(
child: Text(AppLocalizations
.of(context)!
.fetching_bkash_url),
),
);
} else {
return SingleChildScrollView(
child: Container(
width: MediaQuery
.of(context)
.size
.width,
height: MediaQuery
.of(context)
.size
.height,
child: showLoading ? Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
SizedBox(width: 1, height: 1,),
CircularProgressIndicator(strokeWidth: 3,)
],
) : WebViewWidget(
controller: _webViewController,
),
),
);
}
}
onPaymentSuccess(payment_details) async {
showLoading = true;
setState(() {});
var bkashPaymentProcessResponse = await PaymentRepository()
.getBkashPaymentProcessResponse(
amount: widget.amount,
token: _token,
payment_type: widget.payment_type,
combined_order_id: _combined_order_id,
package_id: widget.package_id,
payment_id: payment_details['paymentID'],
);
ToastComponent.showDialog(bkashPaymentProcessResponse.message!,
duration: Toast.lengthLong, gravity: Toast.center);
Navigator.pop(context);
}
void getData() {
String? payment_details = '';
_webViewController
.runJavaScriptReturningResult("document.body.innerText")
.then((data) {
var responseJSON = jsonDecode(data as String);
if (responseJSON.runtimeType == String) {
responseJSON = jsonDecode(responseJSON);
}
print(data);
if (responseJSON["result"] == false) {
Toast.show(responseJSON["message"],
duration: Toast.lengthLong, gravity: Toast.center);
Navigator.pop(context);
} else if (responseJSON["result"] == true) {
payment_details = responseJSON['payment_details'];
onPaymentSuccess(responseJSON);
}
});
}
AppBar buildAppBar(BuildContext context) {
return AppBar(
backgroundColor: Colors.white,
centerTitle: true,
leading: Builder(
builder: (context) =>
IconButton(
icon: Icon(Icons.arrow_back, color: MyTheme.dark_grey),
onPressed: () => Navigator.of(context).pop(),
),
),
title: Text(
AppLocalizations
.of(context)!
.pay_with_bkash,
style: TextStyle(fontSize: 16, color: MyTheme.app_accent_color),
),
elevation: 0.0,
titleSpacing: 0,
);
}
}

View File

@@ -0,0 +1,172 @@
import 'package:active_ecommerce_seller_app/custom/toast_component.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/payment_repository.dart';
import 'package:flutter/material.dart';
import 'package:toast/toast.dart';
import 'dart:convert';
import 'package:webview_flutter/webview_flutter.dart';
class FlutterwaveScreen extends StatefulWidget {
double amount;
String payment_type;
String? payment_method_key;
String? package_id;
FlutterwaveScreen(
{Key? key,
this.amount = 0.00,
this.payment_type = "",
this.payment_method_key = "",this.package_id})
: super(key: key);
@override
_FlutterwaveScreenState createState() => _FlutterwaveScreenState();
}
class _FlutterwaveScreenState extends State<FlutterwaveScreen> {
int _combined_order_id = 0;
bool _order_init = false;
String? _initial_url = "";
bool _initial_url_fetched = false;
late WebViewController _webViewController;
@override
void initState() {
// TODO: implement initState
super.initState();
_webViewController = WebViewController()
..setJavaScriptMode(JavaScriptMode.unrestricted)
..setNavigationDelegate(
NavigationDelegate(
onProgress: (int progress) {
// Update loading bar.
},
onPageStarted: (String url) {},
onPageFinished: (page) {
//print(page.toString());
if (page.contains("/flutterwave/payment/callback")) {
getData();
}
},
onWebResourceError: (WebResourceError error) {},
),
);
getSetInitialUrl();
}
getSetInitialUrl() async {
var flutterwaveUrlResponse = await PaymentRepository().getFlutterwaveUrlResponse(
widget.payment_type, _combined_order_id,widget.package_id ,widget.amount);
if (flutterwaveUrlResponse.result == false) {
ToastComponent.showDialog(flutterwaveUrlResponse.message!,
gravity: Toast.center, duration: Toast.lengthLong);
Navigator.of(context).pop();
return;
}
_initial_url = flutterwaveUrlResponse.url;
_initial_url_fetched = true;
_webViewController.loadRequest(Uri.parse(_initial_url!));
setState(() {});
//print(_initial_url);
//print(_initial_url_fetched);
}
@override
Widget build(BuildContext context) {
return Directionality(
textDirection: app_language_rtl.$! ? TextDirection.rtl : TextDirection.ltr,
child: Scaffold(
backgroundColor: Colors.white,
appBar: buildAppBar(context),
body: buildBody(),
),
);
}
void getData() {
_webViewController
.runJavaScriptReturningResult("document.body.innerText")
.then((data) {
var responseJSON = jsonDecode(data as String);
if(responseJSON.runtimeType ==String ){
responseJSON = jsonDecode(responseJSON);
}
//print(data.toString());
if (responseJSON["result"] == false) {
ToastComponent.showDialog(responseJSON["message"],
duration: Toast.lengthLong, gravity: Toast.center);
Navigator.pop(context);
} else if (responseJSON["result"] == true) {
ToastComponent.showDialog(responseJSON["message"],
duration: Toast.lengthLong, gravity: Toast.center);
Navigator.pop(context);
}
});
}
buildBody() {
if (_order_init == false &&
_combined_order_id == 0 &&
widget.payment_type == "cart_payment") {
return Container(
child: Center(
child: Text("Creating order ..."),
),
);
} else if (_initial_url_fetched == false) {
return Container(
child: Center(
child: Text("Fetching Flutterwave url ..."),
),
);
} else {
return SingleChildScrollView(
child: Container(
width: MediaQuery.of(context).size.width,
height: MediaQuery.of(context).size.height,
child: WebViewWidget(
controller: _webViewController,
),
),
);
}
}
AppBar buildAppBar(BuildContext context) {
return AppBar(
backgroundColor: Colors.white,
centerTitle: true,
leading: Builder(
builder: (context) => IconButton(
icon: Icon(Icons.arrow_back, color: MyTheme.dark_grey),
onPressed: () => Navigator.of(context).pop(),
),
),
title: Text(
"Pay with Flutterwave",
style: TextStyle(fontSize: 16, color: MyTheme.app_accent_color),
),
elevation: 0.0,
titleSpacing: 0,
);
}
}

View File

@@ -0,0 +1,172 @@
import 'package:active_ecommerce_seller_app/app_config.dart';
import 'package:active_ecommerce_seller_app/custom/toast_component.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/payment_repository.dart';
import 'package:flutter/material.dart';
import 'package:toast/toast.dart';
import 'dart:io';
import 'dart:convert';
import 'package:webview_flutter/webview_flutter.dart';
import 'package:flutter_gen/gen_l10n/app_localizations.dart';
class IyzicoScreen extends StatefulWidget {
double amount;
String payment_type;
String? payment_method_key;
String? package_id;
IyzicoScreen(
{Key? key,
this.amount = 0.00,
this.payment_type = "",
this.payment_method_key = "",this.package_id})
: super(key: key);
@override
_IyzicoScreenState createState() => _IyzicoScreenState();
}
class _IyzicoScreenState extends State<IyzicoScreen> {
int _combined_order_id = 0;
bool _order_init = false;
String initial_url="";
late WebViewController _webViewController;
@override
void initState() {
// TODO: implement initState
super.initState();
initial_url =
"${AppConfig.BASE_URL}/iyzico/init?payment_type=${widget.payment_type}&combined_order_id=${_combined_order_id}&amount=${widget.amount}&user_id=${seller_id.$}&package_id=${widget.package_id}";
_webViewController = WebViewController()
..setJavaScriptMode(JavaScriptMode.unrestricted)
..setNavigationDelegate(
NavigationDelegate(
onPageFinished: (page) {
print(page.toString());
getData();
},
),
)
..loadRequest(Uri.parse(initial_url));
}
@override
Widget build(BuildContext context) {
return Directionality(
textDirection: app_language_rtl.$! ? TextDirection.rtl : TextDirection.ltr,
child: Scaffold(
backgroundColor: Colors.white,
appBar: buildAppBar(context),
body: buildBody(),
),
);
}
void getData() {
print('called.........');
String? payment_details = '';
_webViewController
.runJavaScriptReturningResult("document.body.innerText")
.then((data) {
var responseJSON = jsonDecode(data as String);
if(responseJSON.runtimeType ==String ){
responseJSON = jsonDecode(responseJSON);
}
try {
if (responseJSON["result"] == false) {
ToastComponent.showDialog(responseJSON["message"],
duration: Toast.lengthLong, gravity: Toast.center);
Navigator.pop(context);
} else if (responseJSON["result"] == true) {
print("a");
payment_details = responseJSON['payment_details'];
onPaymentSuccess(payment_details);
}
} on Exception catch (e) {
print("error");
// TODO
}
});
}
onPaymentSuccess(payment_details) async{
print("b");
var iyzicoPaymentSuccessResponse = await PaymentRepository().getIyzicoPaymentSuccessResponse(widget.payment_type, widget.amount,_combined_order_id, payment_details);
if(iyzicoPaymentSuccessResponse.result == false ){
print("c");
ToastComponent.showDialog(iyzicoPaymentSuccessResponse.message!,
duration: Toast.lengthLong, gravity: Toast.center);
Navigator.pop(context);
return;
}
print("Success package Payment");
ToastComponent.showDialog(iyzicoPaymentSuccessResponse.message!,
duration: Toast.lengthLong, gravity: Toast.center);
if (widget.payment_type == "cart_payment") {
Navigator.push(context, MaterialPageRoute(builder: (context) {
//return OrderList(from_checkout: true);
} as Widget Function(BuildContext)));
} else if (widget.payment_type == "wallet_payment") {
print("d");
Navigator.push(context, MaterialPageRoute(builder: (context) {
//return Wallet(from_recharge: true);
} as Widget Function(BuildContext)));
}
}
buildBody() {
//print("init url");
//print(initial_url);
if (_order_init == false &&
_combined_order_id == 0 &&
widget.payment_type == "cart_payment") {
return Container(
child: Center(
child: Text(AppLocalizations.of(context)!.no_ucf),
),
);
} else {
return SizedBox.expand(
child: Container(
child: WebViewWidget(
controller: _webViewController,
),
),
);
}
}
AppBar buildAppBar(BuildContext context) {
return AppBar(
backgroundColor: Colors.white,
centerTitle: true,
leading: Builder(
builder: (context) => IconButton(
icon: Icon(Icons.arrow_back, color: MyTheme.dark_grey),
onPressed: () => Navigator.of(context).pop(),
),
),
title: Text(
AppLocalizations.of(context)!.pay_with_iyzico,
style: TextStyle(fontSize: 16, color: MyTheme.app_accent_color),
),
elevation: 0.0,
titleSpacing: 0,
);
}
}

View File

@@ -0,0 +1,175 @@
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/payment_repository.dart';
import 'package:flutter/material.dart';
import 'package:toast/toast.dart';
import 'dart:convert';
import 'package:webview_flutter/webview_flutter.dart';
import 'package:flutter_gen/gen_l10n/app_localizations.dart';
class NagadScreen extends StatefulWidget {
double amount;
String payment_type;
String? payment_method_key;
String? package_id;
NagadScreen(
{Key? key,
this.amount = 0.00,
this.payment_type = "",
this.payment_method_key = "",this.package_id})
: super(key: key);
@override
_NagadScreenState createState() => _NagadScreenState();
}
class _NagadScreenState extends State<NagadScreen> {
int _combined_order_id = 0;
bool _order_init = false;
String? _initial_url = "";
bool _initial_url_fetched = false;
late WebViewController _webViewController;
@override
void initState() {
// TODO: implement initState
super.initState();
_webViewController = WebViewController()
..setJavaScriptMode(JavaScriptMode.unrestricted)
..setNavigationDelegate(
NavigationDelegate(
onPageFinished: (page) {
//print(page.toString());
if (page.contains("/nagad/verify/") ||
page.contains('/check-out/confirm-payment/')) {
getData();
} else {
if (page.contains('confirm-payment')) {
print('yessssssss');
} else {
print('nooooooooo');
}
}
}
),
)
;
getSetInitialUrl();
}
getSetInitialUrl() async {
var nagadUrlResponse = await PaymentRepository().getNagadBeginResponse(
widget.payment_type, _combined_order_id, widget.package_id,widget.amount);
if (nagadUrlResponse.result == false) {
ToastComponent.showDialog(nagadUrlResponse.message!,
gravity: Toast.center, duration: Toast.lengthLong);
Navigator.of(context).pop();
return;
}
_initial_url = nagadUrlResponse.url;
_initial_url_fetched = true;
_webViewController.loadRequest(Uri.parse(_initial_url!));
setState(() {});
//print(_initial_url);
//print(_initial_url_fetched);
}
@override
Widget build(BuildContext context) {
return Scaffold(
backgroundColor: Colors.white,
appBar: buildAppBar(context),
body: buildBody(),
);
}
void getData() {
String? payment_details = '';
_webViewController
.runJavaScriptReturningResult("document.body.innerText")
.then((data) {
var responseJSON = jsonDecode(data as String);
if(responseJSON.runtimeType ==String ){
responseJSON = jsonDecode(responseJSON);
}
if (responseJSON["result"] == false) {
ToastComponent.showDialog(responseJSON["message"],
duration: Toast.lengthLong, gravity: Toast.center);
Navigator.pop(context);
} else if (responseJSON["result"] == true) {
payment_details = responseJSON['payment_details'];
onPaymentSuccess(payment_details);
}
});
}
onPaymentSuccess(payment_details) async{
var nagadPaymentProcessResponse = await PaymentRepository().getNagadPaymentProcessResponse(widget.payment_type, widget.amount,_combined_order_id, payment_details);
if(nagadPaymentProcessResponse.result == false ){
ToastComponent.showDialog(nagadPaymentProcessResponse.message!,
duration: Toast.lengthLong, gravity: Toast.center);
Navigator.pop(context);
return;
}
ToastComponent.showDialog(nagadPaymentProcessResponse.message!,
duration: Toast.lengthLong, gravity: Toast.center);
Navigator.pop(context);
}
buildBody() {
if (_initial_url_fetched == false) {
return Container(
child: Center(
child: Text(AppLocalizations.of(context)!.fetching_nagad_url),
),
);
} else {
return SingleChildScrollView(
child: Container(
width: MediaQuery.of(context).size.width,
height: MediaQuery.of(context).size.height,
child: WebViewWidget(
controller: _webViewController,
),
),
);
}
}
AppBar buildAppBar(BuildContext context) {
return AppBar(
backgroundColor: Colors.white,
centerTitle: true,
leading: Builder(
builder: (context) => IconButton(
icon: Icon(Icons.arrow_back, color: MyTheme.dark_grey),
onPressed: () => Navigator.of(context).pop(),
),
),
title: Text(
AppLocalizations.of(context)!.pay_with_nagad,
style: TextStyle(fontSize: 16, color: MyTheme.app_accent_color),
),
elevation: 0.0,
titleSpacing: 0,
);
}
}

View File

@@ -0,0 +1,405 @@
import 'package:active_ecommerce_seller_app/custom/buttons.dart';
import 'package:active_ecommerce_seller_app/custom/input_decorations.dart';
import 'package:active_ecommerce_seller_app/custom/my_app_bar.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_repository.dart';
import 'package:active_ecommerce_seller_app/repositories/payment_repository.dart';
import 'package:flutter/material.dart';
import 'package:toast/toast.dart';
import 'package:image_picker/image_picker.dart';
import 'package:permission_handler/permission_handler.dart';
import 'package:flutter_gen/gen_l10n/app_localizations.dart';
import 'package:flutter_html/flutter_html.dart';
class OfflineScreen extends StatefulWidget {
String? details;
int? offline_payment_id;
final int? package_id;
final double? rechargeAmount;
OfflineScreen(
{Key? key,
this.details,
this.offline_payment_id,
this.rechargeAmount, this.package_id})
: super(key: key);
@override
_OfflineState createState() => _OfflineState();
}
class _OfflineState extends State<OfflineScreen> {
ScrollController _mainScrollController = ScrollController();
TextEditingController _amountController = TextEditingController();
TextEditingController _nameController = TextEditingController();
TextEditingController _trxIdController = TextEditingController();
final ImagePicker _picker = ImagePicker();
XFile? _photo_file;
String? _photo_path = "";
int? _photo_upload_id = 0;
late BuildContext loadingcontext;
Future<void> _onPageRefresh() async {
reset();
}
reset() {
_amountController.clear();
_nameController.clear();
_trxIdController.clear();
_photo_path = "";
_photo_upload_id = 0;
setState(() {});
}
onPressSubmit() async {
var amount = _amountController.text.toString();
var name = _nameController.text.toString();
var trx_id = _trxIdController.text.toString();
if (amount == "" || name == "" || trx_id == "") {
ToastComponent.showDialog(
AppLocalizations.of(context)!.amount_name_and_transaction_id_are_necessary,
gravity: Toast.center,
duration: Toast.lengthLong);
return;
}
if (_photo_path == "" || _photo_upload_id == 0) {
ToastComponent.showDialog(
AppLocalizations.of(context)!.photo_proof_is_necessary,
gravity: Toast.center, duration: Toast.lengthLong);
return;
}
loading();
var submitResponse = await PaymentRepository()
.getOfflinePaymentResponse(
amount: amount,
name: name,
trx_id: trx_id,
photo: _photo_upload_id,
package_id: widget.package_id);
Navigator.pop(loadingcontext);
if (submitResponse.result == false) {
ToastComponent.showDialog(submitResponse.message!,
gravity: Toast.center, duration: Toast.lengthLong);
} else {
ToastComponent.showDialog(submitResponse.message!,
gravity: Toast.center, duration: Toast.lengthLong);
Navigator.pop(context);
}
}
onPickPhoto(context) async {
//file = await ImagePicker.pickImage(source: ImageSource.camera);
_photo_file = await _picker.pickImage(source: ImageSource.gallery);
if (_photo_file == null) {
ToastComponent.showDialog(
AppLocalizations.of(context)!.no_file_is_chosen,
gravity: Toast.center, duration: Toast.lengthLong);
return;
}
//return;
String base64Image = FileHelper.getBase64FormateFile(_photo_file!.path);
String fileName = _photo_file!.path.split("/").last;
var imageUpdateResponse =
await FileRepository().getSimpleImageUploadResponse(
base64Image,
fileName,
);
if (imageUpdateResponse.result == false) {
print(imageUpdateResponse.message);
ToastComponent.showDialog(imageUpdateResponse.message!,
gravity: Toast.center, duration: Toast.lengthLong);
return;
} else {
ToastComponent.showDialog(imageUpdateResponse.message!,
gravity: Toast.center, duration: Toast.lengthLong);
_photo_path = imageUpdateResponse.path;
_photo_upload_id = imageUpdateResponse.upload_id;
setState(() {});
}
}
@override
void initState() {
_amountController.text = widget.rechargeAmount.toString();
// TODO: implement initState
super.initState();
}
@override
Widget build(BuildContext context) {
return Directionality(
textDirection: app_language_rtl.$! ? TextDirection.rtl : TextDirection.ltr,
child: Scaffold(
backgroundColor: Colors.white,
appBar: MyAppBar(context: context,title: AppLocalizations.of(context)!.offline_payment_ucf,).show(),
body: buildBody(context),
),
);
}
AppBar buildAppBar(BuildContext context) {
return AppBar(
backgroundColor: Colors.white,
centerTitle: true,
leading: Builder(
builder: (context) => IconButton(
icon: Icon(Icons.arrow_back, color: MyTheme.dark_grey),
onPressed: () => Navigator.of(context).pop(),
),
),
title: Text(
AppLocalizations.of(context)!.offline_payment_ucf,
style: TextStyle(fontSize: 16, color: MyTheme.app_accent_color),
),
elevation: 0.0,
titleSpacing: 0,
);
}
buildBody(context) {
return RefreshIndicator(
color: MyTheme.app_accent_color,
backgroundColor: Colors.white,
onRefresh: _onPageRefresh,
displacement: 10,
child: CustomScrollView(
controller: _mainScrollController,
physics: const BouncingScrollPhysics(
parent: AlwaysScrollableScrollPhysics()),
slivers: [
SliverList(
delegate: SliverChildListDelegate([
Padding(
padding: const EdgeInsets.all(16.0),
child: Html(data: widget.details),
),
Padding(
padding: const EdgeInsets.symmetric(horizontal: 16.0),
child: Divider(
height: 24,
),
),
buildProfileForm(context)
]),
)
],
),
);
}
buildProfileForm(context) {
return Padding(
padding:
const EdgeInsets.only(top: 8.0, bottom: 8.0, left: 16.0, right: 16.0),
child: Container(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Padding(
padding: const EdgeInsets.only(bottom: 8.0),
child: Text(
AppLocalizations.of(context)!.all_marked_fields_are_mandatory,
style: TextStyle(
color: MyTheme.grey_153,
fontWeight: FontWeight.w600,
fontSize: 14.0),
),
),
Padding(
padding: const EdgeInsets.only(bottom: 8.0),
child: Text(
AppLocalizations.of(context)!
.correctly_fill_up_the_necessary_information,
style: TextStyle(color: MyTheme.grey_153, fontSize: 14.0),
),
),
Padding(
padding: const EdgeInsets.only(bottom: 4.0),
child: Text(
"${AppLocalizations.of(context)!.amount_ucf}*",
style: TextStyle(
color: MyTheme.app_accent_color, fontWeight: FontWeight.w600),
),
),
Padding(
padding: const EdgeInsets.only(bottom: 8.0),
child: Container(
height: 36,
child: TextField(
controller: _amountController,
autofocus: false,
decoration: InputDecorations.buildInputDecoration_1(
hint_text: "12,000 or Tweleve Thousand Only"),
),
),
),
Padding(
padding: const EdgeInsets.only(bottom: 4.0),
child: Text(
"${AppLocalizations.of(context)!.name_ucf}*",
style: TextStyle(
color: MyTheme.app_accent_color, fontWeight: FontWeight.w600),
),
),
Padding(
padding: const EdgeInsets.only(bottom: 8.0),
child: Container(
height: 36,
child: TextField(
controller: _nameController,
autofocus: false,
decoration: InputDecorations.buildInputDecoration_1(
hint_text: "John Doe"),
),
),
),
Padding(
padding: const EdgeInsets.only(bottom: 4.0),
child: Text(
"${AppLocalizations.of(context)!.transaction_id_ucf}*",
style: TextStyle(
color: MyTheme.app_accent_color, fontWeight: FontWeight.w600),
),
),
Padding(
padding: const EdgeInsets.only(bottom: 8.0),
child: Container(
height: 36,
child: TextField(
controller: _trxIdController,
autofocus: false,
decoration: InputDecorations.buildInputDecoration_1(
hint_text: "BNI-4654321354"),
),
),
),
Padding(
padding: const EdgeInsets.only(bottom: 4.0),
child: Text(
"${AppLocalizations.of(context)!.photo_permission_ucf}* (${AppLocalizations.of(context)!.only_image_file_allowed})",
style: TextStyle(
color: MyTheme.app_accent_color, fontWeight: FontWeight.w600),
),
),
Row(
children: [
Padding(
padding: const EdgeInsets.only(top: 4.0),
child: Container(
width: 180,
height: 36,
decoration: BoxDecoration(
border:
Border.all(color: MyTheme.textfield_grey, width: 1),
borderRadius:
const BorderRadius.all(Radius.circular(8.0))),
child: Buttons(
width: MediaQuery.of(context).size.width,
//height: 50,
color: MyTheme.medium_grey,
shape: RoundedRectangleBorder(
borderRadius:
const BorderRadius.all(Radius.circular(8.0))),
child: Text(
AppLocalizations.of(context)!.photo_proof_ucf,
style: TextStyle(
color: Colors.white,
fontSize: 14,
fontWeight: FontWeight.w600),
),
onPressed: () {
onPickPhoto(context);
},
),
),
),
_photo_path != ""
? Padding(
padding: const EdgeInsets.all(8.0),
child:
Text(AppLocalizations.of(context)!.selected_ucf),
)
: Container()
],
),
Row(
children: [
Spacer(),
Padding(
padding: const EdgeInsets.only(top: 16.0),
child: Container(
width: 120,
height: 36,
decoration: BoxDecoration(
border:
Border.all(color: MyTheme.textfield_grey, width: 1),
borderRadius:
const BorderRadius.all(Radius.circular(8.0))),
child: Buttons(
width: MediaQuery.of(context).size.width,
//height: 50,
color: MyTheme.app_accent_color,
shape: RoundedRectangleBorder(
borderRadius:
const BorderRadius.all(Radius.circular(8.0))),
child: Text(
AppLocalizations.of(context)!.submit_ucf,
style: TextStyle(
color: Colors.white,
fontSize: 14,
fontWeight: FontWeight.w600),
),
onPressed: () {
onPressSubmit();
},
),
),
),
],
),
],
),
),
);
}
loading() {
showDialog(
context: context,
builder: (context) {
loadingcontext = context;
return AlertDialog(
content: Row(
children: [
CircularProgressIndicator(),
SizedBox(
width: 10,
),
Text("${AppLocalizations.of(context)!.please_wait_ucf}"),
],
));
});
}
}

View File

@@ -0,0 +1,152 @@
import 'package:active_ecommerce_seller_app/custom/toast_component.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/payment_repository.dart';
import 'package:flutter/material.dart';
import 'package:toast/toast.dart';
import 'dart:convert';
import 'package:webview_flutter/webview_flutter.dart';
import 'package:flutter_gen/gen_l10n/app_localizations.dart';
class PaypalScreen extends StatefulWidget {
double amount;
String payment_type;
String? payment_method_key;
String? package_id;
PaypalScreen(
{Key? key,
this.amount = 0.00,
this.payment_type = "",
this.payment_method_key = "",this.package_id})
: super(key: key);
@override
_PaypalScreenState createState() => _PaypalScreenState();
}
class _PaypalScreenState extends State<PaypalScreen> {
int _combined_order_id = 0;
bool _order_init = false;
String? _initial_url = "";
bool _initial_url_fetched = false;
late WebViewController _webViewController;
@override
void initState() {
// TODO: implement initState
super.initState();
_webViewController = WebViewController()
..setJavaScriptMode(JavaScriptMode.unrestricted)
..setNavigationDelegate(
NavigationDelegate(
onPageFinished: (page) {
//print(page.toString());
if (page.contains("/paypal/payment/done")) {
getData();
} else if (page.contains("/paypal/payment/cancel")) {
ToastComponent.showDialog("Payment cancelled",
gravity: Toast.center, duration: Toast.lengthLong);
Navigator.of(context).pop();
return;
}
},
),
);
// on cart payment need proper order id
getSetInitialUrl();
}
getSetInitialUrl() async {
var paypalUrlResponse = await PaymentRepository().getPaypalUrlResponse(
widget.payment_type, _combined_order_id,widget.package_id ,widget.amount);
if (paypalUrlResponse.result == false) {
ToastComponent.showDialog(paypalUrlResponse.message!,
gravity: Toast.center, duration: Toast.lengthLong);
Navigator.of(context).pop();
return;
}
_initial_url = paypalUrlResponse.url;
_initial_url_fetched = true;
_webViewController.loadRequest(Uri.parse(_initial_url!));
setState(() {});
}
@override
Widget build(BuildContext context) {
return Directionality(
textDirection: app_language_rtl.$! ? TextDirection.rtl : TextDirection.ltr,
child: Scaffold(
backgroundColor: Colors.white,
appBar: buildAppBar(context),
body: buildBody(),
),
);
}
void getData() {
_webViewController
.runJavaScriptReturningResult("document.body.innerText")
.then((data) {
var responseJSON = jsonDecode(data as String);
if(responseJSON.runtimeType ==String ){
responseJSON = jsonDecode(responseJSON);
}
//print(data.toString());
ToastComponent.showDialog(responseJSON["message"],
duration: Toast.lengthLong, gravity: Toast.center);
Navigator.pop(context);
});
}
buildBody() {
if (_initial_url_fetched == false) {
return Container(
child: Center(
child: Text(AppLocalizations.of(context)!.fetching_paypal_url),
),
);
} else {
return SingleChildScrollView(
child: Container(
width: MediaQuery.of(context).size.width,
height: MediaQuery.of(context).size.height,
child: WebViewWidget(
controller: _webViewController,
),
),
);
}
}
AppBar buildAppBar(BuildContext context) {
return AppBar(
backgroundColor: Colors.white,
centerTitle: true,
leading: Builder(
builder: (context) => IconButton(
icon: Icon(Icons.arrow_back, color: MyTheme.dark_grey),
onPressed: () => Navigator.of(context).pop(),
),
),
title: Text(
AppLocalizations.of(context)!.pay_with_paypal,
style: TextStyle(fontSize: 16, color: MyTheme.app_accent_color),
),
elevation: 0.0,
titleSpacing: 0,
);
}
}

View File

@@ -0,0 +1,137 @@
import 'package:active_ecommerce_seller_app/app_config.dart';
import 'package:active_ecommerce_seller_app/custom/toast_component.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/payment_repository.dart';
import 'package:flutter/material.dart';
import 'package:toast/toast.dart';
import 'dart:convert';
import 'package:webview_flutter/webview_flutter.dart';
import 'package:flutter_gen/gen_l10n/app_localizations.dart';
class PaystackScreen extends StatefulWidget {
double amount;
String payment_type;
String? payment_method_key;
String? package_id;
PaystackScreen(
{Key? key,
this.amount = 0.00,
this.payment_type = "",
this.payment_method_key = "",this.package_id})
: super(key: key);
@override
_PaystackScreenState createState() => _PaystackScreenState();
}
class _PaystackScreenState extends State<PaystackScreen> {
int _combined_order_id = 0;
bool _order_init = false;
String initial_url ="";
late WebViewController _webViewController;
@override
void initState() {
initial_url =
"${AppConfig.BASE_URL}/paystack/init?payment_type=${widget.payment_type}&combined_order_id=${_combined_order_id}&amount=${widget.amount}&user_id=${seller_id.$}&package_id=${widget.package_id}";
_webViewController = WebViewController()
..setJavaScriptMode(JavaScriptMode.unrestricted)
..setNavigationDelegate(
NavigationDelegate(
onPageFinished: (page) {
getData();
},
),
)
..loadRequest(Uri.parse(initial_url));
super.initState();
}
@override
Widget build(BuildContext context) {
return Directionality(
textDirection: app_language_rtl.$! ? TextDirection.rtl : TextDirection.ltr,
child: Scaffold(
backgroundColor: Colors.white,
appBar: buildAppBar(context),
body: buildBody(),
),
);
}
void getData() {
print('called.........');
String? payment_details = '';
_webViewController
.runJavaScriptReturningResult("document.body.innerText")
.then((data) {
var responseJSON = jsonDecode(data as String);
if(responseJSON.runtimeType ==String ){
responseJSON = jsonDecode(responseJSON);
}
//print(responseJSON.toString());
if (responseJSON["result"] == false) {
ToastComponent.showDialog(responseJSON["message"],
duration: Toast.lengthLong, gravity: Toast.center);
Navigator.pop(context);
} else if (responseJSON["result"] == true) {
print("a");
payment_details = responseJSON['payment_details'];
onPaymentSuccess(payment_details);
}
});
}
onPaymentSuccess(payment_details) async{
print("b");
var paystackPaymentSuccessResponse = await PaymentRepository().getPaystackPaymentSuccessResponse(widget.payment_type, widget.amount,_combined_order_id, payment_details);
ToastComponent.showDialog(paystackPaymentSuccessResponse.message!,
duration: Toast.lengthLong, gravity: Toast.center);
Navigator.pop(context);
}
buildBody() {
//print("init url");
//print(initial_url);
return SizedBox.expand(
child: Container(
child: WebViewWidget(
controller: _webViewController,
),
),
);
}
AppBar buildAppBar(BuildContext context) {
return AppBar(
backgroundColor: Colors.white,
centerTitle: true,
leading: Builder(
builder: (context) => IconButton(
icon: Icon(Icons.arrow_back, color: MyTheme.dark_grey),
onPressed: () => Navigator.of(context).pop(),
),
),
title: Text(
AppLocalizations.of(context)!.pay_with_paystack,
style: TextStyle(fontSize: 16, color: MyTheme.app_accent_color),
),
elevation: 0.0,
titleSpacing: 0,
);
}
}

View File

@@ -0,0 +1,135 @@
import 'package:active_ecommerce_seller_app/app_config.dart';
import 'package:active_ecommerce_seller_app/custom/toast_component.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/profile_repository.dart';
import 'package:flutter/material.dart';
import 'package:toast/toast.dart';
import 'dart:convert';
import 'package:webview_flutter/webview_flutter.dart';
import 'package:flutter_gen/gen_l10n/app_localizations.dart';
class PaytmScreen extends StatefulWidget {
double amount;
String payment_type;
String? payment_method_key;
String? package_id;
PaytmScreen(
{Key? key,
this.amount = 0.00,
this.payment_type = "",
this.payment_method_key = "",this.package_id})
: super(key: key);
@override
_PaytmScreenState createState() => _PaytmScreenState();
}
class _PaytmScreenState extends State<PaytmScreen> {
int _combined_order_id = 0;
bool _order_init = false;
String initial_url ="";
late WebViewController _webViewController;
@override
void initState() {
// TODO: implement initState
super.initState();
initial_url =
"${AppConfig.BASE_URL}/paytm/payment/pay?payment_type=${widget.payment_type}&combined_order_id=${_combined_order_id}&amount=${widget.amount}&user_id=${seller_id.$}&package_id=${widget.package_id}";
_webViewController = WebViewController()
..setJavaScriptMode(JavaScriptMode.unrestricted)
..setNavigationDelegate(
NavigationDelegate(
onPageFinished: (page) {
//print(page.toString());
if (page.contains("/paytm/payment/callback")) {
getData();
}
},
),
)
..loadRequest(Uri.parse(initial_url));
checkPhoneAvailability().then((val) {
});
}
checkPhoneAvailability() async {
var phoneEmailAvailabilityResponse =
await ProfileRepository().getPhoneEmailAvailabilityResponse();
print(phoneEmailAvailabilityResponse.toString());
if (phoneEmailAvailabilityResponse.phone_available == false) {
ToastComponent.showDialog(
phoneEmailAvailabilityResponse.phone_available_message!,
gravity: Toast.center, duration: Toast.lengthLong);
Navigator.of(context).pop();
return;
}
return;
}
@override
Widget build(BuildContext context) {
return Directionality(
textDirection: app_language_rtl.$! ? TextDirection.rtl : TextDirection.ltr,
child: Scaffold(
backgroundColor: Colors.white,
appBar: buildAppBar(context),
body: buildBody(),
),
);
}
void getData() {
_webViewController
.runJavaScriptReturningResult("document.body.innerText")
.then((data) {
var responseJSON = jsonDecode(data as String);
if(responseJSON.runtimeType ==String ){
responseJSON = jsonDecode(responseJSON);
}
//print(data.toString());
ToastComponent.showDialog(responseJSON["message"],
duration: Toast.lengthLong, gravity: Toast.center);
Navigator.pop(context);
});
}
buildBody() {
print(initial_url);
return SingleChildScrollView(
child: Container(
width: MediaQuery.of(context).size.width,
height: MediaQuery.of(context).size.height,
child: WebViewWidget(
controller: _webViewController,
),
),
);
}
AppBar buildAppBar(BuildContext context) {
return AppBar(
backgroundColor: Colors.white,
centerTitle: true,
leading: Builder(
builder: (context) => IconButton(
icon: Icon(Icons.arrow_back, color: MyTheme.dark_grey),
onPressed: () => Navigator.of(context).pop(),
),
),
title: Text(
AppLocalizations.of(context)!.pay_with_paytm,
style: TextStyle(fontSize: 16, color: MyTheme.app_accent_color),
),
elevation: 0.0,
titleSpacing: 0,
);
}
}

View File

@@ -0,0 +1,138 @@
import 'package:active_ecommerce_seller_app/app_config.dart';
import 'package:active_ecommerce_seller_app/custom/toast_component.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/payment_repository.dart';
import 'package:flutter/material.dart';
import 'package:toast/toast.dart';
import 'dart:convert';
import 'package:webview_flutter/webview_flutter.dart';
import 'package:flutter_gen/gen_l10n/app_localizations.dart';
class RazorpayScreen extends StatefulWidget {
double amount;
String payment_type;
String? payment_method_key;
String? package_id;
RazorpayScreen(
{Key? key,
this.amount = 0.00,
this.payment_type = "",
this.payment_method_key = "",this.package_id})
: super(key: key);
@override
_RazorpayScreenState createState() => _RazorpayScreenState();
}
class _RazorpayScreenState extends State<RazorpayScreen> {
int _combined_order_id = 0;
bool _order_init = false;
String initial_url ="";
late WebViewController _webViewController;
@override
void initState() {
initial_url =
"${AppConfig.BASE_URL}/razorpay/pay-with-razorpay?payment_type=${widget.payment_type}&combined_order_id=${_combined_order_id}&amount=${widget.amount}&user_id=${seller_id.$}&package_id=${widget.package_id}";
_webViewController = WebViewController()
..setJavaScriptMode(JavaScriptMode.unrestricted)
..setNavigationDelegate(
NavigationDelegate(
onPageFinished: (page) {
getData();
},
),
)
..loadRequest(Uri.parse(initial_url));
super.initState();
}
@override
Widget build(BuildContext context) {
return Directionality(
textDirection: app_language_rtl.$! ? TextDirection.rtl : TextDirection.ltr,
child: Scaffold(
backgroundColor: Colors.white,
appBar: buildAppBar(context),
body: buildBody(),
),
);
}
void getData() {
print('called.........');
String? payment_details = '';
_webViewController
.runJavaScriptReturningResult("document.body.innerText")
.then((data) {
var responseJSON = jsonDecode(data as String);
if(responseJSON.runtimeType ==String ){
responseJSON = jsonDecode(responseJSON);
}
//print(responseJSON.toString());
if (responseJSON["result"] == false) {
ToastComponent.showDialog(responseJSON["message"],
duration: Toast.lengthLong, gravity: Toast.center);
Navigator.pop(context);
} else if (responseJSON["result"] == true) {
print("a");
payment_details = responseJSON['payment_details'];
onPaymentSuccess(payment_details);
}
});
}
onPaymentSuccess(payment_details) async {
var razorpayPaymentSuccessResponse = await PaymentRepository()
.getRazorpayPaymentSuccessResponse(widget.payment_type, widget.amount,
_combined_order_id, payment_details);
ToastComponent.showDialog(razorpayPaymentSuccessResponse.message!,
duration: Toast.lengthLong, gravity: Toast.center);
Navigator.pop(context);
return;
}
buildBody() {
print("init url");
print(initial_url);
return SizedBox.expand(
child: Container(
child: WebViewWidget(
controller: _webViewController,
),
),
);
}
AppBar buildAppBar(BuildContext context) {
return AppBar(
backgroundColor: Colors.white,
centerTitle: true,
leading: Builder(
builder: (context) => IconButton(
icon: Icon(Icons.arrow_back, color: MyTheme.dark_grey),
onPressed: () => Navigator.of(context).pop(),
),
),
title: Text(
AppLocalizations.of(context)!.pay_with_razorpay,
style: TextStyle(fontSize: 16, color: MyTheme.app_accent_color),
),
elevation: 0.0,
titleSpacing: 0,
);
}
}

View File

@@ -0,0 +1,164 @@
import 'package:active_ecommerce_seller_app/custom/toast_component.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/payment_repository.dart';
import 'package:flutter/material.dart';
import 'package:toast/toast.dart';
import 'dart:convert';
import 'package:webview_flutter/webview_flutter.dart';
import 'package:flutter_gen/gen_l10n/app_localizations.dart';
class SslCommerzScreen extends StatefulWidget {
double amount;
String payment_type;
String? payment_method_key;
String package_id;
SslCommerzScreen(
{Key? key,
this.amount = 0.00,
this.payment_type = "",
this.payment_method_key = "",
this.package_id="0"
})
: super(key: key);
@override
_SslCommerzScreenState createState() => _SslCommerzScreenState();
}
class _SslCommerzScreenState extends State<SslCommerzScreen> {
int _combined_order_id = 0;
bool _order_init = false;
String? _initial_url = "";
bool _initial_url_fetched = false;
late WebViewController _webViewController;
@override
void initState() {
_webViewController = WebViewController()
..setJavaScriptMode(JavaScriptMode.unrestricted)
..setNavigationDelegate(
NavigationDelegate(
onPageFinished: (page) {
//print(page.toString());
if (page.contains("/sslcommerz/success")) {
getData();
} else if (page.contains("/sslcommerz/cancel") || page.contains("/sslcommerz/fail")) {
ToastComponent.showDialog("Payment cancelled or failed",
gravity: Toast.center, duration: Toast.lengthLong);
Navigator.of(context).pop();
return;
}
},
),
)
;
super.initState();
getSetInitialUrl();
}
getSetInitialUrl() async {
var sslcommerzUrlResponse = await PaymentRepository().getSslcommerzBeginResponse(
widget.payment_type, _combined_order_id,widget.package_id, widget.amount);
if (sslcommerzUrlResponse.result == false) {
ToastComponent.showDialog(sslcommerzUrlResponse.message!,
gravity: Toast.center, duration: Toast.lengthLong);
Navigator.of(context).pop();
return;
}
_initial_url = sslcommerzUrlResponse.url;
_initial_url_fetched = true;
_webViewController.loadRequest(Uri.parse(_initial_url!));
setState(() {});
//print(_initial_url);
//print(_initial_url_fetched);
}
@override
Widget build(BuildContext context) {
return Directionality(
textDirection: app_language_rtl.$! ? TextDirection.rtl : TextDirection.ltr,
child: Scaffold(
backgroundColor: Colors.white,
appBar: buildAppBar(context),
body: buildBody(),
),
);
}
void getData() {
_webViewController
.runJavaScriptReturningResult("document.body.innerText")
.then((data) {
var responseJSON = jsonDecode(data as String);
if(responseJSON.runtimeType ==String ){
responseJSON = jsonDecode(responseJSON);
}
//print(data.toString());
ToastComponent.showDialog(responseJSON["message"],
duration: Toast.lengthLong, gravity: Toast.center);
Navigator.pop(context);
});
}
buildBody() {
/* String initial_url =
"${AppConfig.BASE_URL}/sslcommerz/begin?payment_type=${widget.payment_type}&combined_order_id=${_combined_order_id}&amount=${widget.amount}&user_id=${user_id.$}";*/
//print("init url");
//print(initial_url);
if (_initial_url_fetched == false) {
return Container(
child: Center(
child: Text(AppLocalizations.of(context)!.fetching_sslcommerz_url),
),
);
} else {
return SingleChildScrollView(
child: Container(
width: MediaQuery.of(context).size.width,
height: MediaQuery.of(context).size.height,
child: WebViewWidget(
controller: _webViewController,
),
),
);
}
}
AppBar buildAppBar(BuildContext context) {
return AppBar(
backgroundColor: Colors.white,
centerTitle: true,
leading: Builder(
builder: (context) => IconButton(
icon: Icon(Icons.arrow_back, color: MyTheme.dark_grey),
onPressed: () => Navigator.of(context).pop(),
),
),
title: Text(
AppLocalizations.of(context)!.pay_with_sslcommerz ,
style: TextStyle(fontSize: 16, color: MyTheme.app_accent_color),
),
elevation: 0.0,
titleSpacing: 0,
);
}
}

View File

@@ -0,0 +1,154 @@
import 'package:active_ecommerce_seller_app/app_config.dart';
import 'package:active_ecommerce_seller_app/custom/toast_component.dart';
import 'package:active_ecommerce_seller_app/helpers/shared_value_helper.dart';
import 'package:active_ecommerce_seller_app/my_theme.dart';
import 'package:flutter/material.dart';
import 'package:toast/toast.dart';
import 'dart:convert';
import 'package:webview_flutter/webview_flutter.dart';
import 'package:flutter_gen/gen_l10n/app_localizations.dart';
class StripeScreen extends StatefulWidget {
double amount;
String payment_type;
String? payment_method_key;
String? package_id;
StripeScreen(
{Key? key,
this.amount = 0.00,
this.payment_type = "",
this.payment_method_key = "",this.package_id})
: super(key: key);
@override
_StripeScreenState createState() => _StripeScreenState();
}
class _StripeScreenState extends State<StripeScreen> {
int _combined_order_id = 0;
bool _order_init = false;
String initial_url ="";
late WebViewController _webViewController;
@override
void initState() {
// TODO: implement initState
super.initState();
initial_url =
"${AppConfig.BASE_URL}/stripe?payment_type=${widget.payment_type}&combined_order_id=${_combined_order_id}&amount=${widget.amount}&user_id=${seller_id.$}&package_id=${widget.package_id}";
_webViewController = WebViewController()
..setJavaScriptMode(JavaScriptMode.unrestricted)
..setNavigationDelegate(
NavigationDelegate(
onPageFinished: (page) {
//print(page.toString());
if (page.contains("/stripe/success")) {
getData();
} else if (page.contains("/stripe/cancel")) {
ToastComponent.showDialog(
AppLocalizations.of(context)!.payment_cancelled_ucf,
gravity: Toast.center,
duration: Toast.lengthLong);
Navigator.of(context).pop();
return;
}
},
),
)
..loadRequest(Uri.parse(initial_url));
}
// createOrder() async {
// var orderCreateResponse = await PaymentRepository()
// .getOrderCreateResponse(widget.payment_method_key);
//
// if (orderCreateResponse.result == false) {
// ToastComponent.showDialog(orderCreateResponse.message, context,
// gravity: Toast.center, duration: Toast.lengthLong);
// Navigator.of(context).pop();
// return;
// }
//
// _combined_order_id = orderCreateResponse.combined_order_id;
// _order_init = true;
// setState(() {});
// }
@override
Widget build(BuildContext context) {
return Directionality(
textDirection: app_language_rtl.$! ? TextDirection.rtl : TextDirection.ltr,
child: Scaffold(
backgroundColor: Colors.white,
appBar: buildAppBar(context),
body: buildBody(),
),
);
}
void getData() {
_webViewController
.runJavaScriptReturningResult("document.body.innerText")
.then((data) {
var responseJSON = jsonDecode(data as String);
if(responseJSON.runtimeType ==String ){
responseJSON = jsonDecode(responseJSON);
}
//print(data.toString());
ToastComponent.showDialog(responseJSON["message"],
duration: Toast.lengthLong, gravity: Toast.center);
Navigator.pop(context);
});
}
buildBody() {
//print("init url");
//print(initial_url);
if (_order_init == false &&
_combined_order_id == 0 &&
widget.payment_type == "cart_payment") {
return Container(
child: Center(
child: Text(AppLocalizations.of(context)!.date_ucf),
),
);
} else {
return SingleChildScrollView(
child: Container(
width: MediaQuery.of(context).size.width,
height: MediaQuery.of(context).size.height,
child: WebViewWidget(
controller: _webViewController,
),
),
);
}
}
AppBar buildAppBar(BuildContext context) {
return AppBar(
backgroundColor: Colors.white,
centerTitle: true,
leading: Builder(
builder: (context) => IconButton(
icon: Icon(Icons.arrow_back, color: MyTheme.dark_grey),
onPressed: () => Navigator.of(context).pop(),
),
),
title: Text(
AppLocalizations.of(context)!.pay_with_stripe,
style: TextStyle(fontSize: 16, color: MyTheme.app_accent_color),
),
elevation: 0.0,
titleSpacing: 0,
);
}
}

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,176 @@
import 'package:active_ecommerce_seller_app/custom/device_info.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/data_model/product_review_response.dart';
import 'package:active_ecommerce_seller_app/helpers/shimmer_helper.dart';
import 'package:active_ecommerce_seller_app/my_theme.dart';
import 'package:active_ecommerce_seller_app/repositories/product_repository.dart';
import 'package:flutter/material.dart';
import 'package:flutter_gen/gen_l10n/app_localizations.dart';
import 'package:flutter_rating_bar/flutter_rating_bar.dart';
import 'package:http/http.dart';
class ProductReviews extends StatefulWidget {
const ProductReviews({Key? key}) : super(key: key);
@override
_ProductReviewsState createState() => _ProductReviewsState();
}
class _ProductReviewsState extends State<ProductReviews> {
List<Review> _reviews= [];
bool _isLoadData = false;
Future<bool> getReviews()async{
var response = await ProductRepository().getProductReviewsReq();
_reviews.addAll(response.data!);
_isLoadData = true;
setState(() {
});
return true;
}
fetchData()async{
await getReviews();
}
clearData()async{
_reviews= [];
_isLoadData = false;
setState(() {
});
}
Future<void> reFresh()async{
clearData();
await fetchData();
return Future.delayed(const Duration(microseconds: 100));
}
@override
void initState() {
getReviews();
// TODO: implement initState
super.initState();
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: MyAppBar(
title: AppLocalizations.of(context)!.product_reviews_ucf,
context: context)
.show(),
body: Container(
padding: EdgeInsets.symmetric(horizontal: 15),
child: RefreshIndicator(
onRefresh: reFresh,
child: SingleChildScrollView(
physics: AlwaysScrollableScrollPhysics(),
child: _isLoadData?buildReviewList():buildShimmer(),
),
),
),
);
}
Widget buildReviewList() {
return ListView.builder(
itemCount: _reviews.length,
physics: NeverScrollableScrollPhysics(),
shrinkWrap: true,
itemBuilder: (context, index) {
return Container(
child: reviewItem(index),
);
});
}
Widget reviewItem(int index) {
return MyWidget().customCard(
elevation:15.0,
margin: EdgeInsets.only(bottom: 20,top: index==0?20:0),
//padding:EdgeInsets.symmetric(horizontal: 15,vertical: 5) ,
//width: DeviceInfo(context).getWidth(),
backgroundColor: MyTheme.app_accent_color_extra_light,
borderRadius: 10.0,
borderColor: MyTheme.light_grey,
shadowColor: MyTheme.app_accent_shado,
child: Padding(
padding: const EdgeInsets.symmetric(horizontal: 15.0,vertical: 15),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Container(
width: DeviceInfo(context).getWidth()/2,
child: Text(
_reviews[index].productName!,
maxLines: 1,
style: TextStyle(
fontSize: 13,
fontWeight: FontWeight.bold,
color: MyTheme.app_accent_color,),
)),
Container(
width: DeviceInfo(context).getWidth(),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Container(
width: DeviceInfo(context).getWidth()/2,
child: Text(
_reviews[index].name!,
style: TextStyle(
fontSize: 12,
color: MyTheme.font_grey,
),
)),
Container(
child: Text(
_reviews[index].status==1? "Publish":"UnPublish",
style: TextStyle(
fontSize: 16,
color: MyTheme.app_accent_color,
),
)),
],
),
),
RatingBarIndicator(
rating:double.parse(_reviews[index].rating.toString()) ,
itemBuilder: (context, index) => Icon(
Icons.star,
color: Colors.amber,
),
itemCount: 5,
itemSize: 20.0,
direction: Axis.horizontal,
),
_reviews[index].comment!.isNotEmpty?Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Divider(color: MyTheme.white,),
Text(_reviews[index].comment!),
],
):Container()
],
),
));
}
Widget buildShimmer(){
return Container(
child: ShimmerHelper().buildListShimmer(item_height: 160.0,item_count: 10),
);
}
}

View File

@@ -0,0 +1,789 @@
import 'package:active_ecommerce_seller_app/const/app_style.dart';
import 'package:active_ecommerce_seller_app/custom/buttons.dart';
import 'package:active_ecommerce_seller_app/custom/common_style.dart';
import 'package:active_ecommerce_seller_app/custom/device_info.dart';
import 'package:active_ecommerce_seller_app/custom/loading.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/route_transaction.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/product_review_response.dart';
import 'package:active_ecommerce_seller_app/data_model/products_response.dart';
import 'package:active_ecommerce_seller_app/dummy_data/allProducts.dart';
import 'package:active_ecommerce_seller_app/dummy_data/topProduct.dart';
import 'package:active_ecommerce_seller_app/helpers/reg_ex_inpur_formatter.dart';
import 'package:active_ecommerce_seller_app/helpers/shared_value_helper.dart';
import 'package:active_ecommerce_seller_app/helpers/shimmer_helper.dart';
import 'package:active_ecommerce_seller_app/my_theme.dart';
import 'package:active_ecommerce_seller_app/repositories/product_repository.dart';
import 'package:active_ecommerce_seller_app/repositories/shop_repository.dart';
import 'package:active_ecommerce_seller_app/screens/product/new_product.dart';
import 'package:active_ecommerce_seller_app/screens/product/product_reviews.dart';
import 'package:active_ecommerce_seller_app/screens/packages.dart';
import 'package:active_ecommerce_seller_app/screens/product/update_product.dart';
import 'package:active_ecommerce_seller_app/ui_elements/product_card.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter_gen/gen_l10n/app_localizations.dart';
import 'package:one_context/one_context.dart';
import 'package:route_transitions/route_transitions.dart';
import 'package:toast/toast.dart';
class Products extends StatefulWidget {
final bool fromBottomBar;
const Products({Key? key, this.fromBottomBar = false}) : super(key: key);
@override
_ProductsState createState() => _ProductsState();
}
class _ProductsState extends State<Products> {
bool _isProductInit = false;
bool _showMoreProductLoadingContainer = false;
List<Product> _productList = [];
// List<bool> _productStatus=[];
// List<bool> _productFeatured=[];
String _remainingProduct = "...";
String? _currentPackageName = "...";
late BuildContext loadingContext;
late BuildContext switchContext;
late BuildContext featuredSwitchContext;
//MenuOptions _menuOptionSelected = MenuOptions.Published;
ScrollController _scrollController =
new ScrollController(initialScrollOffset: 0);
// double variables
double mHeight = 0.0, mWidht = 0.0;
int _page = 1;
getProductList() async {
var productResponse = await ProductRepository().getProducts(page: _page);
if (productResponse.data!.isEmpty) {
ToastComponent.showDialog(
LangText(context: context).getLocal()!.no_more_products_ucf,
gravity: Toast.center,
bgColor: MyTheme.white,
textStyle:TextStyle(color:Colors.black) );
}
_productList.addAll(productResponse.data!);
_showMoreProductLoadingContainer = false;
_isProductInit = true;
setState(() {});
}
Future<bool> _getAccountInfo() async {
var response = await ShopRepository().getShopInfo();
_currentPackageName=response.shopInfo!.sellerPackage;
setState(() {});
return true;
}
getProductRemainingUpload() async {
var productResponse = await ProductRepository().remainingUploadProducts();
_remainingProduct = productResponse.ramainingProduct.toString();
setState(() {});
}
duplicateProduct(int? id) async {
loading();
var response = await ProductRepository().productDuplicateReq(id: id);
Navigator.pop(loadingContext);
if (response.result) {
resetAll();
}
ToastComponent.showDialog(response.message,
gravity: Toast.center,
duration: 3,
textStyle: TextStyle(color: MyTheme.black),
);
}
deleteProduct(int? id) async {
loading();
var response = await ProductRepository().productDeleteReq(id: id);
Navigator.pop(loadingContext);
if (response.result) {
resetAll();
}
ToastComponent.showDialog(response.message,
gravity: Toast.center,
duration: 3,
textStyle: TextStyle(color: MyTheme.black),
);
}
productStatusChange(int? index, bool value, setState, id) async {
loading();
var response = await ProductRepository()
.productStatusChangeReq(id: id, status: value ? 1 : 0);
Navigator.pop(loadingContext);
if (response.result) {
// _productStatus[index] = value;
_productList[index!].status = value;
resetAll();
}
Navigator.pop(switchContext);
ToastComponent.showDialog(response.message,
gravity: Toast.center,
duration: 3,
textStyle: TextStyle(color: MyTheme.black),
);
}
productFeaturedChange({int? index, required bool value, setState, id}) async {
print(value);
loading();
var response = await ProductRepository()
.productFeaturedChangeReq(id: id, featured: value ? 1 : 0);
Navigator.pop(loadingContext);
if (response.result) {
// _productFeatured[index]=value;
_productList[index!].featured = value;
resetAll();
}
Navigator.pop(featuredSwitchContext);
ToastComponent.showDialog(response.message,
gravity: Toast.center,
duration: 3,
textStyle: TextStyle(color: MyTheme.black),
);
}
scrollControllerPosition() {
_scrollController.addListener(() {
if (_scrollController.position.pixels ==
_scrollController.position.maxScrollExtent) {
_showMoreProductLoadingContainer = true;
setState(() {
_page++;
});
getProductList();
}
});
}
cleanAll() {
_isProductInit = false;
_showMoreProductLoadingContainer = false;
_productList = [];
_page = 1;
// _productStatus=[];
// _productFeatured=[];
_remainingProduct = "....";
_currentPackageName="...";
setState(() {});
}
fetchAll() {
getProductList();
_getAccountInfo();
getProductRemainingUpload();
setState(() {});
}
resetAll() {
cleanAll();
fetchAll();
}
_tabOption(int index, productId, listIndex) {
switch (index) {
case 0:
slideRightWidget( newPage: UpdateProduct(productId: productId,),context: context).then((value){
resetAll();
});
break;
case 1:
showPublishUnPublishDialog(listIndex, productId);
break;
case 2:
showFeaturedUnFeaturedDialog(listIndex, productId);
break;
case 3:
showDeleteWarningDialog(productId);
//deleteProduct(productId);
break;
case 4:
print(productId);
duplicateProduct(productId);
break;
default:
break;
}
}
@override
void initState() {
scrollControllerPosition();
fetchAll();
super.initState();
}
@override
Widget build(BuildContext context) {
mHeight = MediaQuery.of(context).size.height;
mWidht = MediaQuery.of(context).size.width;
return Directionality(
textDirection: app_language_rtl.$! ? TextDirection.rtl : TextDirection.ltr,
child: Scaffold(
appBar: !widget.fromBottomBar?MyAppBar(
context: context,
title:
LangText(context: context).getLocal()!.products_ucf)
.show():null,
body: RefreshIndicator(
triggerMode: RefreshIndicatorTriggerMode.anywhere,
onRefresh: () async {
resetAll();
// Future.delayed(Duration(seconds: 1));
},
child: SingleChildScrollView(
physics: AlwaysScrollableScrollPhysics(),
controller: _scrollController,
child: Column(
children: [
SizedBox(height: 20,),
buildTop2BoxContainer(context),
Visibility(
visible: seller_package_addon.$,
child: buildPackageUpgradeContainer(context)),
SizedBox(
height: 20,
),
Container(
child: _isProductInit
? productsContainer()
: ShimmerHelper().buildListShimmer(
item_count: 20, item_height: 80.0),
),
],
),
),
),
),
);
}
Widget buildPackageUpgradeContainer(BuildContext context) {
return Column(
children: [
SizedBox(
height: AppStyles.itemMargin,
),
MyWidget().myContainer(
marginY: 15,
height: 40,
width: DeviceInfo(context).getWidth(),
borderRadius: 6,
borderColor: MyTheme.app_accent_color,
bgColor: MyTheme.app_accent_color_extra_light,
child: InkWell(
onTap: () {
MyTransaction(context: context).push(Packages());
},
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: [
Row(
children: [
Image.asset("assets/icon/package.png", height: 20, width: 20),
SizedBox(
width: 5,
),
Text(
LangText(context: context)
.getLocal()!
.current_package_ucf,
style: TextStyle(fontSize: 10, color: MyTheme.grey_153),
),
SizedBox(
width: 5,
),
Text(
_currentPackageName!,
style: TextStyle(
fontSize: 10,
color: MyTheme.app_accent_color,
fontWeight: FontWeight.bold),
),
],
),
SizedBox(
width: 5,
),
Row(
children: [
Text(
LangText(context: context)
.getLocal()!
.upgrade_package_ucf,
style: TextStyle(
fontSize: 12,
color: MyTheme.app_accent_color,
fontWeight: FontWeight.bold),
),
SizedBox(
width: 8,
),
Image.asset("assets/icon/next_arrow.png",
color: MyTheme.app_accent_color,
height: 8.7, width: 7),
],
),
],
),
)),
],
);
}
Container buildTop2BoxContainer(BuildContext context) {
return Container(
margin: EdgeInsets.symmetric(horizontal: 15),
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Container(
padding: EdgeInsets.all(10),
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(10),
//border: Border.all(color: MyTheme.app_accent_border),
color: MyTheme.app_accent_color,
),
height: 75,
width: mWidht / 2 - 23,
child: Container(
child: Column(
crossAxisAlignment: CrossAxisAlignment.center,
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: [
Text(
LangText(context: context)
.getLocal()!
.remaining_uploads,
style: MyTextStyle().dashboardBoxText(context),
),
Text(
_remainingProduct,
style: MyTextStyle().dashboardBoxNumber(context),
),
],
),
)),
SizedBox(width: AppStyles.itemMargin,),
Container(
child: SubmitBtn.show(
onTap: () {
MyTransaction(context: context).push( NewProduct()).then((value){
resetAll();
});
},
borderColor: MyTheme.app_accent_color,
backgroundColor: MyTheme.app_accent_color_extra_light,
height: 75,
width: mWidht / 2 - 23,
radius: 10,
child: Container(
padding: EdgeInsets.all(10),
height: 75,
child: Column(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: [
Text(
LangText(context: context)
.getLocal()!
.add_new_product_ucf,
style: MyTextStyle()
.dashboardBoxText(context)
.copyWith(color: MyTheme.app_accent_color),
),
Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Image.asset(
'assets/icon/add.png',
color: MyTheme.app_accent_color,
height: 24,
width: 42,
fit: BoxFit.contain,
),
],
)
],
),
),
)),
],
),
);
}
Widget productsContainer() {
return Container(
padding: EdgeInsets.symmetric(horizontal: 15),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
LangText(context: context).getLocal()!.all_products_ucf,
style: TextStyle(
fontSize: 14,
fontWeight: FontWeight.bold,
color: MyTheme.app_accent_color),
),
SizedBox(
height: 10,
),
ListView.builder(
physics: NeverScrollableScrollPhysics(),
itemCount: _productList.length + 1,
shrinkWrap: true,
itemBuilder: (context, index) {
// print(index);
if (index == _productList.length) {
return moreProductLoading();
}
return productItem(
index: index,
productId: _productList[index].id,
imageUrl: _productList[index].thumbnailImg,
productTitle: _productList[index].name!,
category: _productList[index].category,
productPrice: _productList[index].price.toString(),
quantity: _productList[index].quantity.toString());
}),
],
),
);
}
Container productItem(
{int? index,
productId,
String? imageUrl,
required String productTitle,
required category,
required String productPrice,
required String quantity}) {
return MyWidget.customCardView(
elevation: 5,
backgroundColor: MyTheme.white,
height: 90,
width: mWidht,
margin: EdgeInsets.only(bottom: 20,),
borderColor: MyTheme.light_grey,
borderRadius: 6,
child: InkWell(
onTap: (){
slideRightWidget( newPage: UpdateProduct(productId: productId,),context: context).then((value){
resetAll();
});
},
child: Row(
children: [
MyWidget.imageWithPlaceholder(
width: 84.0,
height: 90.0,
fit: BoxFit.cover,
url: imageUrl,
radius: BorderRadius.only(
topLeft: Radius.circular(5),
bottomLeft: Radius.circular(5),),),
// Image.asset(ImageUrl,width: 80,height: 80,fit: BoxFit.contain,),
SizedBox(
width: 11,
),
Container(
width: mWidht - 129,
child: Column(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Container(
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Container(
width: mWidht - 170,
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
productTitle,
style:
TextStyle(fontSize: 12, color: MyTheme.font_grey,fontWeight: FontWeight.w400),
maxLines: 1,
overflow: TextOverflow.ellipsis,
),
SizedBox(
height: 3,
),
Text(
category,
style: TextStyle(
fontSize: 10,
color: MyTheme.grey_153,
fontWeight: FontWeight.w400
),
maxLines: 1,
overflow: TextOverflow.ellipsis,
),
],
),
),
Container(
child:
showOptions(listIndex: index, productId: productId),
),
],
),
),
Container(
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Container(
child: Text(productPrice,
style: TextStyle(
fontSize: 13, color: MyTheme.app_accent_color,fontWeight: FontWeight.w500)),
),
Row(
children: [
Image.asset(
"assets/icon/product.png",
width: 10,
height: 10,
fit: BoxFit.contain,
),
SizedBox(
width: 7,
),
Padding(
padding: const EdgeInsets.only(right: 15.0),
child: Text(quantity,
style: TextStyle(
fontSize: 13, color: MyTheme.grey_153)),
),
],
),
],
),
),
],
),
),
],
),
)) as Container;
}
showDeleteWarningDialog(id){
showDialog(context: context, builder: (context)=>Container(
width: DeviceInfo(context).getWidth()*1.5,
child: AlertDialog(
title: Text(LangText(context: context).getLocal()!.warning_ucf,style: TextStyle(fontWeight: FontWeight.bold,fontSize: 15,color: MyTheme.red),),
content: Text(LangText(context: context).getLocal()!.do_you_want_to_delete_it,style:const TextStyle(fontWeight: FontWeight.w400,fontSize: 14),),
actions: [
Buttons(
color: MyTheme.app_accent_color,
onPressed: (){
Navigator.pop(context);
}, child: Text(LangText(context: context).getLocal()!.no_ucf,style: TextStyle(color: MyTheme.white,fontSize: 12),)),
Buttons(
color: MyTheme.app_accent_color,
onPressed: (){
Navigator.pop(context);
deleteProduct(id);
}, child: Text(LangText(context: context).getLocal()!.yes_ucf,style: TextStyle(color: MyTheme.white,fontSize: 12))),
],
),
));
}
Widget showOptions({listIndex, productId}) {
return Container(
width: 35,
child: PopupMenuButton<MenuOptions>(
offset: Offset(-12, 0),
child: Padding(
padding: EdgeInsets.zero,
child: Container(
width: 35,
padding: EdgeInsets.symmetric(horizontal: 15),
alignment: Alignment.topRight,
child: Image.asset("assets/icon/more.png",
width: 3, height: 15, fit: BoxFit.contain, color: MyTheme.grey_153),
),
),
onSelected: (MenuOptions result) {
_tabOption(result.index, productId, listIndex);
// setState(() {
// //_menuOptionSelected = result;
// });
},
itemBuilder: (BuildContext context) => <PopupMenuEntry<MenuOptions>>[
const PopupMenuItem<MenuOptions>(
value: MenuOptions.Edit,
child: Text('Edit'),
),
const PopupMenuItem<MenuOptions>(
value: MenuOptions.Published,
child: Text('Published'),
),
const PopupMenuItem<MenuOptions>(
value: MenuOptions.Featured,
child: Text('Featured'),
),
const PopupMenuItem<MenuOptions>(
value: MenuOptions.Delete,
child: Text('Delete'),
),
const PopupMenuItem<MenuOptions>(
value: MenuOptions.Duplicate,
child: Text('Duplicate'),
),
],
),
);
}
void showPublishUnPublishDialog(int? index, id) {
//print(index.toString()+" "+_productStatus[index].toString());
showDialog(
context: context,
builder: (context) {
switchContext = context;
return StatefulBuilder(builder: (context, setState) {
return Container(
height: 75,
width: DeviceInfo(context).getWidth(),
child: AlertDialog(
content: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Text(
_productList[index!].status ? "Published" : "Unpublished",
style: TextStyle(
fontSize: 13,
fontWeight: FontWeight.w500,
color: Colors.black),
),
Switch(
value: _productList[index].status,
activeColor: MyTheme.green,
inactiveThumbColor: MyTheme.grey_153,
onChanged: (value) {
productStatusChange(index, value, setState, id);
},
),
],
),
),
);
});
});
}
void showFeaturedUnFeaturedDialog(int? index, id) {
//print(_productFeatured[index]);
print(index);
showDialog(
context: context,
builder: (context) {
featuredSwitchContext = context;
return StatefulBuilder(builder: (context, setState) {
return Container(
height: 75,
width: DeviceInfo(context).getWidth(),
child: AlertDialog(
content: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Text(
_productList[index!].featured ? "Featured" : "Unfeatured",
style: TextStyle(
fontSize: 13,
fontWeight: FontWeight.w500,
color: Colors.black),
),
Switch(
value: _productList[index].featured,
activeColor: MyTheme.green,
inactiveThumbColor: MyTheme.grey_153,
onChanged: (value) {
productFeaturedChange(
index: index,
value: value,
setState: setState,
id: id);
},
),
],
),
),
);
});
});
}
loading() {
showDialog(
context: context,
builder: (context) {
loadingContext = context;
return AlertDialog(
content: Row(
children: [
CircularProgressIndicator(),
SizedBox(
width: 10,
),
Text("${AppLocalizations.of(context)!.please_wait_ucf}"),
],
));
});
}
Widget moreProductLoading() {
return _showMoreProductLoadingContainer
? Container(
alignment: Alignment.center,
child: SizedBox(
height: 40,
width: 40,
child: Row(
children: [
SizedBox(
width: 2,
height: 2,
),
CircularProgressIndicator(),
],
),
),
)
: SizedBox(
height: 5,
width: 5,
);
}
}
enum MenuOptions { Edit,Published, Featured, Delete, Duplicate }

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,435 @@
import 'package:active_ecommerce_seller_app/custom/buttons.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/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/profile_repository.dart';
import 'package:flutter/material.dart';
import 'package:toast/toast.dart';
import 'package:image_picker/image_picker.dart';
import 'package:permission_handler/permission_handler.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter_gen/gen_l10n/app_localizations.dart';
class ProfileEdit extends StatefulWidget {
const ProfileEdit({Key? key}) : super(key: key);
@override
_ProfileEditState createState() => _ProfileEditState();
}
class _ProfileEditState extends State<ProfileEdit> {
ScrollController _mainScrollController = ScrollController();
String? avatar_original="";
TextEditingController _nameController =
TextEditingController(text: "");
TextEditingController _passwordController = TextEditingController();
TextEditingController _passwordConfirmController = TextEditingController();
//for image uploading
final ImagePicker _picker = ImagePicker();
XFile? _file;
sellerInfo()async{
var response = await ProfileRepository().getSellerInfo();
_nameController.text = response.name.toString();
avatar_original = response.avatarOriginal;
setState(() {
});
}
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()!.photo_permission_ucf),
content: Text(
AppLocalizations.of(context)!.this_app_needs_permission),
actions: <Widget>[
CupertinoDialogAction(
child: Text(LangText(context: context).getLocal()!.deny_ucf),
onPressed: () => Navigator.of(context).pop(),
),
CupertinoDialogAction(
child: Text(LangText(context: context).getLocal()!.settings_ucf),
onPressed: () => openAppSettings(),
),
],
));
} else if (status.isRestricted) {
ToastComponent.showDialog(
LangText(context: context).getLocal()!.go_to_your_application_settings_and_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(AppLocalizations.of(context)!.no_file_is_chosen,
gravity: Toast.center, duration: Toast.lengthLong);
return;
}
//return;
String base64Image = FileHelper.getBase64FormateFile(_file!.path);
String fileName = _file!.path.split("/").last;
var profileImageUpdateResponse =
await ProfileRepository().getProfileImageUpdateResponse(
base64Image,
fileName,
);
if (profileImageUpdateResponse.result == false) {
ToastComponent.showDialog(profileImageUpdateResponse.message!,
gravity: Toast.center, duration: Toast.lengthLong);
return;
} else {
ToastComponent.showDialog(profileImageUpdateResponse.message!,
gravity: Toast.center, duration: Toast.lengthLong);
avatar_original = profileImageUpdateResponse.path;
setState(() {});
}
}
}
Future<void> _onPageRefresh() async {}
onPressUpdate() async {
var name = _nameController.text.toString();
var password = _passwordController.text.toString();
var password_confirm = _passwordConfirmController.text.toString();
var change_password = password != "" ||
password_confirm !=
""; // if both fields are empty we will not change user's password
if (name == "") {
ToastComponent.showDialog(AppLocalizations.of(context)!.enter_your_name,
gravity: Toast.center, duration: Toast.lengthLong);
return;
}
if (change_password && password == "") {
ToastComponent.showDialog(AppLocalizations.of(context)!.enter_password,
gravity: Toast.center, duration: Toast.lengthLong);
return;
}
if (change_password && password_confirm == "") {
ToastComponent.showDialog(AppLocalizations.of(context)!.confirm_your_password,
gravity: Toast.center, duration: Toast.lengthLong);
return;
}
if (change_password && password.length < 6) {
ToastComponent.showDialog(
AppLocalizations.of(context)!.password_must_contain_at_least_6_characters,
gravity: Toast.center, duration: Toast.lengthLong);
return;
}
if (change_password && password != password_confirm) {
ToastComponent.showDialog(AppLocalizations.of(context)!.passwords_do_not_match,
gravity: Toast.center, duration: Toast.lengthLong);
return;
}
var profileUpdateResponse =
await ProfileRepository().getProfileUpdateResponse(
name,
change_password ? password : "",
);
if (profileUpdateResponse.result == false) {
ToastComponent.showDialog(profileUpdateResponse.message!,
gravity: Toast.center, duration: Toast.lengthLong);
} else {
ToastComponent.showDialog(profileUpdateResponse.message!,
gravity: Toast.center, duration: Toast.lengthLong);
setState(() {});
}
}
@override
void initState() {
sellerInfo();
// TODO: implement initState
super.initState();
}
@override
Widget build(BuildContext context) {
return Directionality(
textDirection: app_language_rtl.$! ? TextDirection.rtl : TextDirection.ltr,
child: Scaffold(
backgroundColor: Colors.white,
appBar:MyAppBar(context: context,title:AppLocalizations.of(context)!.edit_profile_ucf, ).show(),
body: buildBody(context),
),
);
}
AppBar buildAppBar(BuildContext context) {
return AppBar(
backgroundColor: Colors.white,
centerTitle: true,
leading: Builder(
builder: (context) => IconButton(
icon: Icon(Icons.arrow_back, color: MyTheme.dark_grey),
onPressed: () => Navigator.of(context).pop(),
),
),
title: Text(
AppLocalizations.of(context)!.edit_profile_ucf,
style: TextStyle(fontSize: 16, color: MyTheme.app_accent_color),
),
elevation: 0.0,
titleSpacing: 0,
);
}
buildBody(context) {
if (!is_logged_in.$) {
return Container(
height: 100,
child: Center(
child: Text(
AppLocalizations.of(context)!.please_log_in_to_see_the_profile,
style: TextStyle(color: MyTheme.font_grey),
)));
} else {
return RefreshIndicator(
color: MyTheme.app_accent_color,
backgroundColor: Colors.white,
onRefresh: _onPageRefresh,
displacement: 10,
child: CustomScrollView(
controller: _mainScrollController,
physics: const BouncingScrollPhysics(
parent: AlwaysScrollableScrollPhysics()),
slivers: [
SliverList(
delegate: SliverChildListDelegate([
buildTopSection(),
Padding(
padding: const EdgeInsets.symmetric(horizontal: 16.0),
child: Divider(
height: 24,
),
),
buildProfileForm(context)
]),
)
],
),
);
}
}
buildTopSection() {
return Column(
children: [
Padding(
padding: const EdgeInsets.only(top: 16.0, bottom: 8.0),
child: Stack(
children: [
MyWidget.roundImageWithPlaceholder(height: 120.0,width: 120.0,borderRadius: 60,url: avatar_original),
/* Container(
width: 120,
height: 120,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(100),
border: Border.all(
color: Color.fromRGBO(112, 112, 112, .3), width: 2),
//shape: BoxShape.rectangle,
),
child: ClipRRect(
clipBehavior: Clip.hardEdge,
borderRadius: BorderRadius.all(Radius.circular(100.0)),
child: FadeInImage.assetNetwork(
placeholder: 'assets/placeholder.png',
image: "${avatar_original.$}",
fit: BoxFit.fill,
)),
),*/
Positioned(
right: 8,
bottom: 8,
child: SizedBox(
width: 24,
height: 24,
child: Buttons(
padding: EdgeInsets.all(0),
child: Icon(
Icons.edit,
color: MyTheme.font_grey,
size: 14,
),
shape: CircleBorder(
side:
new BorderSide(color: MyTheme.light_grey, width: 1.0),
),
color: MyTheme.light_grey,
onPressed: () {
chooseAndUploadImage(context);
},
),
),
)
],
),
),
],
);
}
buildProfileForm(context) {
return Padding(
padding:
const EdgeInsets.only(top: 8.0, bottom: 8.0, left: 16.0, right: 16.0),
child: Container(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Padding(
padding: const EdgeInsets.only(bottom: 8.0),
child: Text(
AppLocalizations.of(context)!.basic_information_ucf,
style: TextStyle(
color: MyTheme.grey_153,
fontWeight: FontWeight.w600,
fontSize: 14.0),
),
),
Padding(
padding: const EdgeInsets.only(bottom: 4.0),
child: Text(
AppLocalizations.of(context)!.name_ucf,
style: TextStyle(
color: MyTheme.app_accent_color, fontWeight: FontWeight.w600),
),
),
Padding(
padding: const EdgeInsets.only(bottom: 8.0),
child: Container(
height: 36,
child: TextField(
controller: _nameController,
autofocus: false,
decoration: InputDecorations.buildInputDecoration_1(
hint_text: "John Doe"),
),
),
),
Padding(
padding: const EdgeInsets.only(bottom: 4.0),
child: Text(
AppLocalizations.of(context)!.password_ucf,
style: TextStyle(
color: MyTheme.app_accent_color, fontWeight: FontWeight.w600),
),
),
Padding(
padding: const EdgeInsets.only(bottom: 8.0),
child: Column(
crossAxisAlignment: CrossAxisAlignment.end,
children: [
Container(
height: 36,
child: TextField(
controller: _passwordController,
autofocus: false,
obscureText: true,
enableSuggestions: false,
autocorrect: false,
decoration: InputDecorations.buildInputDecoration_1(
hint_text: "• • • • • • • •"),
),
),
Text(
AppLocalizations.of(context)!.password_must_contain_at_least_6_characters,
style: TextStyle(
color: MyTheme.textfield_grey,
fontStyle: FontStyle.italic),
)
],
),
),
Padding(
padding: const EdgeInsets.only(bottom: 4.0),
child: Text(
AppLocalizations.of(context)!.retype_password_ucf,
style: TextStyle(
color: MyTheme.app_accent_color, fontWeight: FontWeight.w600),
),
),
Padding(
padding: const EdgeInsets.only(bottom: 8.0),
child: Container(
height: 36,
child: TextField(
controller: _passwordConfirmController,
autofocus: false,
obscureText: true,
enableSuggestions: false,
autocorrect: false,
decoration: InputDecorations.buildInputDecoration_1(
hint_text: "• • • • • • • •"),
),
),
),
Row(
children: [
Spacer(),
Padding(
padding: const EdgeInsets.only(top: 16.0),
child: Container(
width: 120,
height: 36,
decoration: BoxDecoration(
border:
Border.all(color: MyTheme.textfield_grey, width: 1),
borderRadius:
const BorderRadius.all(Radius.circular(8.0))),
child: Buttons(
width: MediaQuery.of(context).size.width,
//height: 50,
color: MyTheme.app_accent_color,
shape: RoundedRectangleBorder(
borderRadius:
const BorderRadius.all(Radius.circular(8.0))),
child: Text(
AppLocalizations.of(context)!.update_profile_ucf,
style: TextStyle(
color: Colors.white,
fontSize: 12,
fontWeight: FontWeight.w600),
),
onPressed: () {
onPressUpdate();
},
),
),
),
],
),
],
),
),
);
}
}

View File

@@ -0,0 +1,610 @@
import 'package:active_ecommerce_seller_app/const/app_style.dart';
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/toast_component.dart';
import 'package:active_ecommerce_seller_app/dummy_data/refundList.dart';
import 'package:active_ecommerce_seller_app/helpers/shimmer_helper.dart';
import 'package:active_ecommerce_seller_app/main.dart';
import 'package:active_ecommerce_seller_app/my_theme.dart';
import 'package:active_ecommerce_seller_app/repositories/refund_order_repository.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:toast/toast.dart';
class RefundRequest extends StatefulWidget {
const RefundRequest({Key? key}) : super(key: key);
@override
State<RefundRequest> createState() => _RefundRequestState();
}
class _RefundRequestState extends State<RefundRequest> {
var _refundOrderList = [];
int _page = 0;
bool _showLoadingContainer = false;
bool _faceData = false;
RefundOptions? _refundOptions;
ScrollController _scrollController = ScrollController();
TextEditingController rejectReasonController= TextEditingController() ;
String? _rejectReason;
getRefundOrders() async {
var response =
await RefundOrderRepository().getRefundOrderList(page: _page);
if (response.data!.isEmpty) {
ToastComponent.showDialog(
LangText(context: context).getLocal()!.no_more_refund_requests_ucf,
gravity: Toast.center,
bgColor: MyTheme.white,
textStyle:TextStyle(color: Colors.black) );
}
if (response.success!) {
_refundOrderList.addAll(response.data!);
}
_showLoadingContainer = false;
_faceData = true;
print("data face" + _faceData.toString());
setState(() {});
}
approveRefundReq(id) async {
var response = await RefundOrderRepository().approveRefundSellerStatusRequest(id);
refresh();
ToastComponent.showDialog(response.message,
gravity: Toast.bottom,
duration: 2,
bgColor: MyTheme.white );
}
rejectRefundReq(id) async {
var sms = getDataFromTextEditingController();
if(sms.isEmpty){
ToastComponent.showDialog("Please provide reason.",
gravity: Toast.bottom,
duration: 2,
bgColor: MyTheme.white);
return;
}
print("true");
var response = await RefundOrderRepository().rejectRefundSellerStatusRequest(id,sms);
refresh();
ToastComponent.showDialog(response.message,
gravity: Toast.bottom,
duration: 2,
bgColor: MyTheme.white );
}
scrollControllerListener() {
_scrollController.addListener(() {
// print("position: " + _scrollController.position.pixels.toString());
//print("max: " + _xcrollController.position.maxScrollExtent.toString());
if (_scrollController.position.pixels ==
_scrollController.position.maxScrollExtent) {
setState(() {
_page++;
});
_showLoadingContainer = true;
fetchData();
}
});
}
setDataInTextEditingController(text){
rejectReasonController.text= text??"";
setState(() {
});
}
String getDataFromTextEditingController(){
return rejectReasonController.text.trim();
}
fetchData() {
getRefundOrders();
}
clearData() {
_faceData = false;
_refundOrderList = [];
_page = 0;
_showLoadingContainer = false;
setState(() {});
}
Future<void> refresh() async {
clearData();
fetchData();
}
@override
void initState() {
// TODO: implement initState
scrollControllerListener();
fetchData();
super.initState();
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: MyAppBar(
context: context,
title: LangText(context: context)
.getLocal()!
.refund_requests_ucf)
.show(),
body: RefreshIndicator(
onRefresh: refresh,
child: CustomScrollView(
controller: _scrollController,
physics: AlwaysScrollableScrollPhysics(),
slivers: [
SliverToBoxAdapter(
child: Container(
padding: EdgeInsets.symmetric(horizontal: 15),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Container(
child: !_faceData
? ShimmerHelper().buildListShimmer(
item_count: 10, item_height: 100.0)
: _refundOrderList.isNotEmpty
? ListView.builder(
physics: NeverScrollableScrollPhysics(),
shrinkWrap: true,
itemCount: _refundOrderList.length + 1,
itemBuilder: (context, index) {
if (index == _refundOrderList.length) {
return moreLoading();
}
return refundReqItem(context, index);
})
: Container(
height: DeviceInfo(context).getHeight() / 1.5,
child: Center(
child: Text(LangText(context: context)
.getLocal()!
.no_data_is_available)),
),
)
],
),
),
),
],
),
),
);
}
refundReqItem(BuildContext context, int index) {
return InkWell(
onTap: (){
showStatusChangeDialog(_refundOrderList[index].id,_refundOrderList[index].refundStatus,_refundOrderList[index].seller_approval,_refundOrderList[index].refundReson,_refundOrderList[index].rejectReson);
},
child: MyWidget.customCardView(
backgroundColor: MyTheme.app_accent_color_extra_light,
elevation: 5,
height: 96,
padding: EdgeInsets.symmetric(horizontal: 10,vertical: 15),
width: DeviceInfo(context).getWidth(),
margin: EdgeInsets.only(top: AppStyles.listItemsMargin),
borderColor: MyTheme.app_accent_border,
borderWidth: 1,
alignment: Alignment.center,
borderRadius: 6,
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Container(
width: DeviceInfo(context).getWidth() / 2,
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
_refundOrderList[index].orderCode,
style: TextStyle(
fontSize: 13,
fontWeight: FontWeight.bold,
color: MyTheme.app_accent_color),
),
SizedBox(
height: 5,
),
Row(
children: [
Image.asset(
'assets/icon/calender.png',
width: 12,
height: 12,
),
SizedBox(
width: 8,
),
Text(
_refundOrderList[index].date,
style: TextStyle(
fontSize: 12,
fontWeight: FontWeight.normal,
color: MyTheme.font_grey),
),
],
),
SizedBox(
height: 5,
),
Row(
children: [
Image.asset(
'assets/icon/refund.png',
width: 12,
height: 12,
color: MyTheme.font_grey,
),
SizedBox(
width: 8,
),
Text(
"Refund Status - ",
style: TextStyle(
fontSize: 12,
fontWeight: FontWeight.normal,
color: MyTheme.font_grey),
),
Text(
_refundOrderList[index].refundLabel,
style: TextStyle(
fontSize: 12,
fontWeight: FontWeight.normal,
color: MyTheme.font_grey),
),
SizedBox(width: 5,),
_refundOrderList[index].refundStatus == 1
? Icon(
Icons.check_circle,
color: MyTheme.green,
size: 14,
)
: _refundOrderList[index].refundStatus == 0
? Icon(
Icons.error,
color: Colors.yellow,
size: 14,
)
: Icon(
Icons.cancel,
color: MyTheme.red,
size: 14,
)
],
),
]),
),
Container(
child: Column(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
crossAxisAlignment: CrossAxisAlignment.end,
children: [
Container(
height:16,
width:8,
child: Image.asset("assets/icon/ios-back-arrow.png",height: 12,width: 8,color: MyTheme.app_accent_color,),
),
SizedBox(height: 20,),
Text(
_refundOrderList[index].productPrice.toString(),
style: TextStyle(
fontSize: 16,
fontWeight: FontWeight.bold,
color: MyTheme.app_accent_color),
),
],
),
),
],
),
),
);
}
Future showStatusChangeDialog(id,refundStatus ,seller_approval,String? refundSMS,rejectReason) {
_refundOptions = seller_approval==2?RefundOptions.Reject:RefundOptions.Approve;
setDataInTextEditingController(rejectReason);
var showFullText = false;
return showDialog(
context: context,
builder: (context) {
return StatefulBuilder(
builder: (context,setState) {
return AlertDialog(
contentPadding: EdgeInsets.only( top: 15,right: 20,left: 20,bottom: 0),
insetPadding: EdgeInsets.zero,
content: AnimatedContainer(
duration: Duration(milliseconds: 500),
height: setAlertDialogHeight(refundSMS, DeviceInfo(context).getWidth()*.7,showFullText),
width: DeviceInfo(context).getWidth()*.7,
child: Container(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
// mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Text("Refund Reason ",style: TextStyle(fontSize: 14,color: MyTheme.app_accent_color)),
SizedBox(height: 5,),
Text(refundSMS!,style: TextStyle(fontSize: 14,color: Colors.grey),
maxLines:showFullText?textLines(refundSMS, DeviceInfo(context).getWidth()*.7): 2,
overflow: TextOverflow.ellipsis,
),
Visibility(
visible: textIsOverFlow(refundSMS, DeviceInfo(context).getWidth()*.7),
child: InkWell(
onTap: (){
setState((){
showFullText =!showFullText;
});
},
child: Text(showFullText?"less":"read more",style: TextStyle(fontSize: 14,color: MyTheme.app_accent_color,decoration: TextDecoration.underline,),),
),
),
Visibility(
visible: refundStatus !=2,
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
SizedBox(height: 15,),
Text("Seller Approval",style: TextStyle(fontSize: 15,color: MyTheme.app_accent_color,fontWeight: FontWeight.bold),),
SizedBox(height: 10,),
Row(
children: [
Visibility(
visible: seller_approval==0 || seller_approval==1,
child: Row(
children: [
Container(
height: 15,
width: 15,
child: Radio(
toggleable: true,
value: RefundOptions.Approve,
groupValue: _refundOptions,
onChanged: (dynamic newValue) {
if(seller_approval==0) {
setState(() {
_refundOptions = newValue;
});
}
}),
),
SizedBox(width: 10,),
Text(seller_approval==1?LangText(context: context).getLocal()!.approved_ucf:LangText(context: context).getLocal()!.approve_ucf,
style: TextStyle(fontSize: 14,color: MyTheme.app_accent_color),
),
SizedBox(width: 30,),
],
),
),
Visibility(
visible: seller_approval==0 || seller_approval==2,
child: Row(
mainAxisAlignment: MainAxisAlignment.start,
children: [
Container(
width: 15,
height: 15,
child: Radio(
value: RefundOptions.Reject,
groupValue: _refundOptions,
onChanged: (dynamic newValue) {
if(seller_approval==0) {
setState(() {
_refundOptions = newValue;
});
}
}),
),
SizedBox(width: 10,),
Text(seller_approval==2?LangText(context: context).getLocal()!.rejected_ucf:LangText(context: context).getLocal()!.reject_ucf,style: TextStyle(fontSize: 14,color: MyTheme.app_accent_color),),
],
),
),
],
),
Visibility(
visible: _refundOptions!.index==1,
child: MyWidget.customContainer(
backgroundColor: MyTheme.app_accent_color_extra_light,
borderColor: MyTheme.app_accent_color,
padding: EdgeInsets.all(5.0),
margin: EdgeInsets.only(top: 10),
borderRadius: 5.0,
height:_refundOptions!.index==0?0:70,
alignment: Alignment.topLeft,
child: SingleChildScrollView(
child: TextField(
readOnly:seller_approval!=0 ,
controller: rejectReasonController,
style: TextStyle(fontSize: 14,color: MyTheme.app_accent_color,),
scrollPhysics: AlwaysScrollableScrollPhysics(),
// scrollController:,
maxLines:4,
decoration: InputDecoration.collapsed(hintText: "Type reason",hintStyle: TextStyle(fontSize: 14,color: MyTheme.app_accent_border)),
),
),
width: double.infinity,
),
),
],
),
)
],
),
),
),
actions: [
Buttons(
color: MyTheme.app_accent_color,
onPressed: (){
Navigator.pop(context);
}, child: Text(LangText(context: context).getLocal()!.close_ucf,style: TextStyle(color: MyTheme.white,fontSize: 12),)),
Visibility(
visible: seller_approval==0 && refundStatus !=2,
child: Buttons(
color: MyTheme.app_accent_color,
onPressed: (){
if(_refundOptions!.index==0){
approveRefundReq(id);
}if(_refundOptions!.index==1){
rejectRefundReq(id);
}
Navigator.pop(context);
}, child: Text(LangText(context: context).getLocal()!.submit_ucf,style: TextStyle(color: MyTheme.white,fontSize: 12))),
),
],
);
}
);
});
}
double? setAlertDialogHeight(mytext,maxWidth,showFullText){
var height;
if(_refundOptions!.index==0 && textIsOverFlow(mytext, maxWidth) && showFullText){
height= 120+textLineHeight(mytext,DeviceInfo(context).getWidth()*.7);
}else if(_refundOptions!.index==0 && textIsOverFlow(mytext, maxWidth)){
height= 140.0;
}else if(_refundOptions!.index==0){
height= 120.0;
}
else if (_refundOptions!.index==1 && textIsOverFlow(mytext, maxWidth) && showFullText) {
height= 220+textLineHeight(mytext,DeviceInfo(context).getWidth()*.7);
}else if(_refundOptions!.index==1 )
{
height= 220.0;
}
print(height);
return height;
}
bool textIsOverFlow(mytext,maxWidth){
// Build the textspan
var span = TextSpan(
text: mytext,
style: TextStyle(fontSize: 12),
);
// Use a textpainter to determine if it will exceed max lines
var tp = TextPainter(
maxLines: 2,
textAlign: TextAlign.left,
textDirection: TextDirection.ltr,
text: span,
);
// trigger it to layout
tp.layout(maxWidth: maxWidth);
// whether the text overflowed or not
var exceeded = tp.didExceedMaxLines;
return exceeded;
}
double textLineHeight(mytext,maxWidth){
// Build the textspan
var span = TextSpan(
text: mytext,
style: TextStyle(fontSize: 12),
);
// Use a textpainter to determine if it will exceed max lines
var tp = TextPainter(
textAlign: TextAlign.left,
textDirection: TextDirection.ltr,
text: span,
);
// trigger it to layout
tp.layout(maxWidth: maxWidth);
// whether the text overflowed or not
var exceeded = tp.height;
return exceeded;
}
int textLines(mytext,maxWidth){
// Build the textspan
var span = TextSpan(
text: mytext,
style: TextStyle(fontSize: 12),
);
// Use a textpainter to determine if it will exceed max lines
var tp = TextPainter(
textAlign: TextAlign.left,
textDirection: TextDirection.ltr,
text: span,
);
// trigger it to layout
tp.layout(maxWidth: maxWidth);
// whether the text overflowed or not
var exceeded = tp.computeLineMetrics().length;
return exceeded;
}
Widget moreLoading() {
return _showLoadingContainer
? Container(
alignment: Alignment.center,
child: SizedBox(
height: 40,
width: 40,
child: Row(
children: [
SizedBox(
width: 2,
height: 2,
),
CircularProgressIndicator(),
],
),
),
)
: SizedBox(
height: 5,
width: 5,
);
}
}
enum RefundOptions { Approve, Reject }

View File

@@ -0,0 +1,240 @@
import 'package:active_ecommerce_seller_app/app_config.dart';
import 'package:active_ecommerce_seller_app/custom/buttons.dart';
import 'package:active_ecommerce_seller_app/custom/dialog_box.dart';
import 'package:active_ecommerce_seller_app/custom/input_decorations.dart';
import 'package:active_ecommerce_seller_app/custom/intl_phone_input.dart';
import 'package:active_ecommerce_seller_app/custom/localization.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/helpers/auth_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/address_repository.dart';
import 'package:active_ecommerce_seller_app/repositories/auth_repository.dart';
import 'package:active_ecommerce_seller_app/screens/home.dart';
import 'package:active_ecommerce_seller_app/screens/main.dart';
import 'package:active_ecommerce_seller_app/screens/password_forget.dart';
import 'package:flutter/material.dart';
import 'package:intl_phone_number_input/intl_phone_number_input.dart';
import 'package:toast/toast.dart';
import 'package:flutter/services.dart';
import 'package:flutter_gen/gen_l10n/app_localizations.dart';
class Registration extends StatefulWidget {
@override
_RegistrationState createState() => _RegistrationState();
}
class _RegistrationState extends State<Registration> {
String _login_by = "email"; //phone or email
String initialCountry = 'US';
PhoneNumber phoneCode = PhoneNumber(isoCode: 'US', dialCode: "+1");
String _phone = "";
late BuildContext loadingContext;
var countries_code = <String>[];
//controllers
TextEditingController nameController = TextEditingController();
TextEditingController shopNameController = TextEditingController();
TextEditingController addressController = TextEditingController();
TextEditingController emailController = TextEditingController();
TextEditingController passwordController = TextEditingController();
TextEditingController confirmPassController = TextEditingController();
MyWidget? myWidget;
onPressReg()async{
String name = nameController.text.trim();
String email = emailController.text.trim();
String password = passwordController.text.trim();
String confirmPassword = confirmPassController.text.trim();
String shopName = shopNameController.text.trim();
String address = addressController.text.trim();
loading();
var response = await AuthRepository().getRegResponse(name: name, email: email, password: password, confirmPassword: confirmPassword, shopName: shopName, address: address);
Navigator.pop(loadingContext);
if(response.result!){
ToastComponent.showDialog(response.message);
Navigator.pop(context);
}else{
if(context.mounted) {
DialogBox.warningShow(context, response.message);
}
}
}
@override
Widget build(BuildContext context) {
return Scaffold(
backgroundColor: MyTheme.app_accent_color,
body: buildBody(context),
);
}
Widget buildBody(BuildContext context) {
return Container(
padding: const EdgeInsets.symmetric(horizontal: 36),
width: double.infinity,
child: SingleChildScrollView(
child: Column(
crossAxisAlignment: CrossAxisAlignment.center,
children: [
SizedBox(height: 10,),
Text(
LangText(context: context).getLocal()!.registration,
style:
TextStyle(color: MyTheme.app_accent_border, fontSize: 20,fontWeight: FontWeight.bold),
),
spacer(height: 14),
Container(
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(10),
border: Border.all(width: 1,color: MyTheme.medium_grey)
),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Padding(
padding: const EdgeInsets.symmetric(vertical: 8.0,horizontal: 24),
child: Text(
LangText(context: context).getLocal()!.personal_info_ucf,
style:
const TextStyle(color: MyTheme.app_accent_border, fontSize: 17,fontWeight: FontWeight.bold),
),
),
// Container(height: 1,color: MyTheme.medium_grey,),
// spacer(height: 14),
inputFieldModel(LangText(context: context).getLocal()!.name_ucf,"Mr. Jhon" , nameController),
spacer(height: 14),
inputFieldModel(LangText(context: context).getLocal()!.email_ucf,"seller@example.com" , emailController),
spacer(height: 14),
inputFieldModel(LangText(context: context).getLocal()!.password_ucf,"● ● ● ● ●" , passwordController,isPassword: true),
spacer(height: 14),
inputFieldModel(LangText(context: context).getLocal()!.confirm_your_password,"● ● ● ● ●" , confirmPassController,isPassword: true),
spacer(height: 14),
],
),
),
spacer(height: 20),
Container(
decoration: BoxDecoration(
border: Border.all(width: 1,color: MyTheme.medium_grey),
borderRadius: BorderRadius.circular(10),
),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Padding(
padding: const EdgeInsets.symmetric(vertical: 8.0,horizontal: 24),
child: Text(
LangText(context: context).getLocal()!.basic_info_ucf,
style:
TextStyle(color: MyTheme.app_accent_border, fontSize: 17,fontWeight: FontWeight.bold),
),
),
//Container(height: 1,color: MyTheme.medium_grey,),
// spacer(height: 14),
inputFieldModel(LangText(context: context).getLocal()!.shop_name,"Shop" , shopNameController),
spacer(height: 14),
inputFieldModel(LangText(context: context).getLocal()!.address_ucf,"Dhaka" , addressController),
spacer(height: 14),
],
),
),
spacer(height: 20),
Buttons(
width: MediaQuery.of(context).size.width,
height: 50,
color: Colors.white.withOpacity(0.8),
shape:const RoundedRectangleBorder(
borderRadius: BorderRadius.all(
Radius.circular(11.0),
),
),
child: Text(
LangText(context: context).getLocal()!.registration,
style:const TextStyle(
color: MyTheme.app_accent_color,
fontSize: 17,
fontWeight: FontWeight.w500),
),
onPressed: () {
onPressReg();
},
),
],
),
),
);
}
Widget inputFieldModel(String title,String hint,TextEditingController controller,{bool isPassword=false}){
return Padding(
padding: const EdgeInsets.symmetric(horizontal: 24.0),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
title,
style: const TextStyle(
color: MyTheme.app_accent_border,
fontWeight: FontWeight.w400,
fontSize: 12),
),
const SizedBox(height: 8,),
Container(
height: 36,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(10),
color: const Color.fromRGBO(255, 255, 255, 0.5)),
child: TextField(
style: TextStyle(color: MyTheme.white),
controller: controller,
autofocus: false,
obscureText: isPassword,
decoration:
InputDecorations.buildInputDecoration_1(
borderColor: MyTheme.noColor,
hint_text: hint,
hintTextColor: MyTheme.dark_grey
),
),
),
],
),
);
}
Widget spacer({height=24}){
return SizedBox(height: double.parse(height.toString()),);
}
loading() {
return showDialog(
context: context,
builder: (context) {
loadingContext=context;
return AlertDialog(
content: Row(
children: [
const CircularProgressIndicator(),
const SizedBox(
width: 10,
),
Text(AppLocalizations.of(context)!.please_wait_ucf),
],
));
});
}
}

View File

@@ -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}"),
],
));
});
}
}

View File

@@ -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,
);
},
);
}
}

View File

@@ -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}"),
],
));
});
}
}

View File

@@ -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,
)
],
)),
],
),
),
),
);
}
}

View File

@@ -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}"),
],
));
});
}
}

View File

@@ -0,0 +1,243 @@
import 'package:active_ecommerce_seller_app/app_config.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/auth_repository.dart';
import 'package:active_ecommerce_seller_app/screens/home.dart';
import 'package:active_ecommerce_seller_app/screens/login.dart';
import 'package:active_ecommerce_seller_app/screens/main.dart';
import 'package:flutter/material.dart';
import 'package:package_info/package_info.dart';
import 'dart:async';
import 'package:flutter/services.dart';
class Splash extends StatefulWidget {
@override
_SplashState createState() => _SplashState();
}
class _SplashState extends State<Splash> {
PackageInfo _packageInfo = PackageInfo(
appName: AppConfig.app_name,
packageName: 'Unknown',
version: 'Unknown',
buildNumber: 'Unknown',
);
@override
void initState() {
//on Splash Screen hide statusbar
SystemChrome.setEnabledSystemUIMode(SystemUiMode.manual, overlays: [SystemUiOverlay.bottom]);
super.initState();
_initPackageInfo();
}
@override
void dispose() {
//before going to other screen show statusbar
SystemChrome.setEnabledSystemUIMode(SystemUiMode.manual,
overlays: [SystemUiOverlay.top, SystemUiOverlay.bottom]);
super.dispose();
}
Future<void> _initPackageInfo() async {
final PackageInfo info = await PackageInfo.fromPlatform();
setState(() {
_packageInfo = info;
});
}
@override
Widget build(BuildContext context) {
return CustomSplashScreen(
//comment this
seconds: 3,
//comment this
navigateAfterSeconds: access_token.$!.isNotEmpty ? Home() : Login(),
// navigateAfterFuture: loadFromFuture(), //uncomment this
// version: Text(
// "version " + _packageInfo.version,
// style: TextStyle(
// fontWeight: FontWeight.bold,
// fontSize: 11.0,
// color: MyTheme.app_accent_border),
// ),
useLoader: false,
loadingText: Text(
AppConfig.app_name,
style: TextStyle(
fontWeight: FontWeight.w500,
fontSize: 20.0,
color: Colors.white,
),
),
image: Image.asset(
"assets/logo/white_logo.png",
width: 350,
height: 100,
),
backgroundColor: MyTheme.splash_screen_color,
backgroundPhotoSize: 200.0,
photoSize: 55,
);
}
}
class CustomSplashScreen extends StatefulWidget {
/// Seconds to navigate after for time based navigation
final int? seconds;
/// App version, shown in the middle of screen in case of no image available
final Text version;
/// Page background color
final Color backgroundColor;
/// Style for the laodertext
final TextStyle styleTextUnderTheLoader;
/// The page where you want to navigate if you have chosen time based navigation
final dynamic navigateAfterSeconds;
/// Main image size
final double? photoSize;
final double? backgroundPhotoSize;
/// Triggered if the user clicks the screen
final dynamic onClick;
/// Loader color
final Color? loaderColor;
/// Main image mainly used for logos and like that
final Image? image;
final Image? backgroundImage;
/// Loading text, default: "Loading"
final Text loadingText;
/// Background image for the entire screen
final ImageProvider? imageBackground;
/// Background gradient for the entire screen
final Gradient? gradientBackground;
/// Whether to display a loader or not
final bool useLoader;
/// Custom page route if you have a custom transition you want to play
final Route? pageRoute;
/// RouteSettings name for pushing a route with custom name (if left out in MaterialApp route names) to navigator stack (Contribution by Ramis Mustafa)
final String? routeName;
/// expects a function that returns a future, when this future is returned it will navigate
final Future<dynamic>? navigateAfterFuture;
final Function? afterSplashScreen;
/// Use one of the provided factory constructors instead of.
@protected
CustomSplashScreen({
this.loaderColor,
this.navigateAfterFuture,
this.seconds,
this.photoSize,
this.backgroundPhotoSize,
this.pageRoute,
this.onClick,
this.navigateAfterSeconds,
this.version = const Text(''),
this.backgroundColor = Colors.white,
this.styleTextUnderTheLoader = const TextStyle(
fontSize: 18.0, fontWeight: FontWeight.bold, color: Colors.black),
this.image,
this.backgroundImage,
this.loadingText = const Text(""),
this.imageBackground,
this.gradientBackground,
this.useLoader = true,
this.routeName,
this.afterSplashScreen,
});
@override
_CustomSplashScreenState createState() => _CustomSplashScreenState();
}
class _CustomSplashScreenState extends State<CustomSplashScreen> {
@override
void initState() {
print(1);
super.initState();
access_token.load().then((value) {
print("2");
AuthRepository().getUserByTokenResponse().then((value) {
print("3");
Navigator.pushAndRemoveUntil(
context,
MaterialPageRoute(
builder: (context) => value.result! ? Main() : Login()),
(route) => false);
});
});
// Future.delayed(Duration(seconds: widget.seconds)).then((value) {
// Navigator.pushAndRemoveUntil(context, MaterialPageRoute(builder:(context)=> access_token.$.isNotEmpty?Main():Login()), (route) => false);
//
// });
}
@override
Widget build(BuildContext context) {
return Scaffold(
body: InkWell(
onTap: widget.onClick,
child: Stack(
fit: StackFit.expand,
children: <Widget>[
Container(
decoration: BoxDecoration(
image: widget.imageBackground == null
? null
: DecorationImage(
fit: BoxFit.cover,
image: widget.imageBackground!,
),
gradient: widget.gradientBackground,
color: widget.backgroundColor,
),
),
Column(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.center,
children: <Widget>[
Container(
width: double.infinity,
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.center,
children: <Widget>[
Padding(
padding: const EdgeInsets.all(8.0),
child: widget.image,
),
Padding(
padding: const EdgeInsets.all(8.0),
child: widget.loadingText,
),
widget.version,
Padding(
padding: const EdgeInsets.only(top: 10.0),
),
],
)),
],
),
],
),
),
);
}
}

View File

@@ -0,0 +1,166 @@
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/route_transaction.dart';
import 'package:active_ecommerce_seller_app/my_theme.dart';
import 'package:active_ecommerce_seller_app/screens/create_ticket.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
class SupportTicket extends StatefulWidget {
const SupportTicket({Key? key}) : super(key: key);
@override
State<SupportTicket> createState() => _SupportTicketState();
}
class _SupportTicketState extends State<SupportTicket> {
List<bool> _mailHide = [];
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: MyAppBar(context: context,title: LangText(context: context).getLocal()!.support_tickets_ucf).show(),
body: SingleChildScrollView(
child: Container(
padding: EdgeInsets.symmetric(horizontal: 15),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
buildAddSupportTicketContainer(context),
SizedBox(height: 20,),
Container(
child: ListView.builder(
physics: NeverScrollableScrollPhysics(),
shrinkWrap: true,
itemCount: 16,
itemBuilder: (context,index){
_mailHide.add(false);
return buildTicketItemContainer(context,index);
}),
)
],
),
),
),
);
}
Widget buildTicketItemContainer(BuildContext context,int index) {
return AnimatedContainer(
constraints:BoxConstraints(
minHeight: _mailHide[index]?150:110
) ,
duration: Duration(seconds: 1),
padding: EdgeInsets.all(15),
curve: Curves.fastOutSlowIn,
margin: EdgeInsets.only(bottom: 20),
alignment: Alignment.topLeft,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(6),
border: Border.all(color: MyTheme.light_grey,width: 1),
color: MyTheme.app_accent_color_extra_light,
),
width: DeviceInfo(context).getWidth(),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text("Damaged Product",style: TextStyle(fontSize: 13,fontWeight: FontWeight.bold,color: MyTheme.app_accent_color),),
SizedBox(height: 5,),
Row(
children: [
Image.asset('assets/icon/calender.png',width: 12,height: 12,),
SizedBox(width: 8,),
Text("Damaged Product",style: TextStyle(fontSize: 12,fontWeight: FontWeight.normal,color: MyTheme.font_grey),),
],
),
SizedBox(height: 5,),
Row(
children: [
Image.asset('assets/icon/ticket_id.png',width: 12,height: 12,),
SizedBox(width: 8,),
Text("Damaged Product",style: TextStyle(fontSize: 12,fontWeight: FontWeight.normal,color: MyTheme.font_grey),),
],
),
SizedBox(height: 5,),
Row(
children: [
Image.asset('assets/icon/car.png',width: 12,height: 12,),
SizedBox(width: 8,),
Row(
children: [
Text(LangText(context: context).getLocal()!.options_ucf +" - ",style: TextStyle(fontSize: 12,fontWeight: FontWeight.normal,color: MyTheme.font_grey),),
InkWell(
onTap:(){
print('dd');
setState(() {
_mailHide[index] = !_mailHide[index];
});
},
child: Text(
LangText(context: context).getLocal()!.view_details_ucf,
style: TextStyle(fontSize: 12,fontWeight: FontWeight.normal,color: MyTheme.app_accent_color,decoration: TextDecoration.underline ),),
),
],
),
],
),
Visibility(
visible: _mailHide[index],
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Divider(),
Text("Damaged Product",style: TextStyle(fontSize: 13,fontWeight: FontWeight.bold,color: MyTheme.app_accent_color),),
Container(
width: DeviceInfo(context).getWidth(),
child: Text("But I must explain to you how all this mistaken idea of denouncing pleasure and praising pain was born and I will give you a complete account of the system, and expound the actual teachings of the great explorer of the truth, the master-builder of human happiness. No one rejects, dislikes, or avoids pleasure itself, because it is pleasure, but because those who do not know how to pursue pleasure rationally encounter consequences that are extremely painful. Nor again is there anyone who loves or pursues or desires to obtain pain of itself, because it is pain, but because occasionally circumstances occur ",
style: TextStyle(fontSize: 12,color: MyTheme.font_grey),)),
],
),
)
],
)
);
}
Widget buildAddSupportTicketContainer(BuildContext context) {
return InkWell(
onTap: (){
MyTransaction(context: context).push(CreateTicket());
},
child: MyWidget().myContainer(
height: 75,
width: DeviceInfo(context).getWidth(),
borderRadius: 10,
bgColor: MyTheme.app_accent_color_extra_light,
borderColor: MyTheme.app_accent_color,
child: Column(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: [
Text(
LangText(context: context)
.getLocal()!
.create_a_ticket,
style: TextStyle(
fontWeight: FontWeight.bold,
fontSize: 12,
color: MyTheme.app_accent_color),
),
Image.asset(
'assets/icon/add.png',
width: 18,
height: 18,
color: MyTheme.app_accent_color,
)
],
)),
);
}
}

View File

@@ -0,0 +1,573 @@
import 'dart:io';
import 'package:active_ecommerce_seller_app/const/app_style.dart';
import 'package:active_ecommerce_seller_app/const/dropdown_models.dart';
import 'package:active_ecommerce_seller_app/custom/common_style.dart';
import 'package:active_ecommerce_seller_app/custom/decorations.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/route_transaction.dart';
import 'package:active_ecommerce_seller_app/custom/toast_component.dart';
import 'package:active_ecommerce_seller_app/data_model/coupon_list_response.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/helpers/shimmer_helper.dart';
import 'package:active_ecommerce_seller_app/my_theme.dart';
import 'package:active_ecommerce_seller_app/repositories/coupon_repository.dart';
import 'package:active_ecommerce_seller_app/repositories/file_upload_repository.dart';
import 'package:active_ecommerce_seller_app/screens/coupon/new_coupon.dart';
import 'package:file_picker/file_picker.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 UploadFile extends StatefulWidget {
const UploadFile({Key? key, this.fileType="", this.canSelect=false, this.canMultiSelect=false, this.prevData}) : super(key: key);
final String fileType;
final bool canSelect;
final bool canMultiSelect;
final List<FileInfo>? prevData;
@override
State<UploadFile> createState() => _UploadFileState();
}
class _UploadFileState extends State<UploadFile> {
ScrollController mainScrollController = ScrollController();
TextEditingController searchEditingController =TextEditingController();
String searchTxt="";
//for image uploading
CommonDropDownItem? sortBy ;
List<CommonDropDownItem> sortList =[
CommonDropDownItem("newest", "Sort By Newest"),
CommonDropDownItem("oldest", "Sort By Oldest"),
CommonDropDownItem("smallest", "Sort By Smallest"),
CommonDropDownItem("largest", "Sort By Largest")
];
List<FileInfo> _images = [];
List<FileInfo>? _selectedImages = [];
bool _faceData = false;
int currentPage=1;
int? lastPage=1;
Future<FilePickerResult?> pickSingleFile() async {
return await FilePicker.platform
.pickFiles(type: FileType.custom, allowedExtensions: [
"jpg",
"jpeg",
"png",
"svg",
"webp",
"gif",
"mp4",
"mpg",
"mpeg",
"webm",
"ogg",
"avi",
"mov",
"flv",
"swf",
"mkv",
"wmv",
"wma",
"aac",
"wav",
"mp3",
"zip",
"rar",
"7z",
"doc",
"txt",
"docx",
"pdf",
"csv",
"xml",
"ods",
"xlr",
"xls",
"xlsx"]);
}
chooseAndUploadFile(context) async {
FilePickerResult? file = await pickSingleFile();
if (file == null) {
ToastComponent.showDialog(
LangText(context: context)
.getLocal()!
.no_file_is_chosen,
gravity: Toast.center,
duration: Toast.lengthLong);
return;
}
var fileUploadResponse = await FileUploadRepository().fileUpload(
File(file.paths.first!));
if (fileUploadResponse.result == false) {
ToastComponent.showDialog(fileUploadResponse.message,
gravity: Toast.center, duration: Toast.lengthLong);
return;
} else {
resetData();
ToastComponent.showDialog(fileUploadResponse.message,
gravity: Toast.center, duration: Toast.lengthLong);
resetData();
}
}
getImageList() async {
var response = await FileUploadRepository().getFiles(currentPage,searchTxt,widget.fileType,sortBy!.key);
_images.addAll(response.data!);
_faceData = true;
lastPage=response.meta!.lastPage;
setState(() {});
}
Future<bool> fetchData()async {
getImageList();
return true;
}
_tabOption(int index, imageId, listIndex) {
switch (index) {
case 0:
delete(imageId);
break;
default:
break;
}
}
delete(id)async{
var response = await FileUploadRepository().deleteFile(id);
if(response.result!){
resetData();
}
ToastComponent.showDialog(response.message);
}
Future<bool> clearData()async {
_images = [];
_faceData = false;
setState((){});
return true;
}
sorted(){
refresh();
}
search(){
searchTxt=searchEditingController.text.trim();
refresh();
}
Future<bool> resetData() async{
await clearData();
await fetchData();
return true;
}
Future<void> refresh() async {
await resetData();
return Future.delayed(Duration(seconds: 1));
}
scrollControllerPosition() {
mainScrollController.addListener(() {
if (mainScrollController.position.pixels ==
mainScrollController.position.maxScrollExtent) {
if(currentPage>=lastPage!) {
currentPage++;
getImageList();
}
}
});
}
@override
void initState() {
// TODO: implement initState
if(widget.canMultiSelect && widget.prevData !=null){
_selectedImages=widget.prevData;
setState((){});
}
sortBy=sortList.first;
fetchData();
scrollControllerPosition();
super.initState();
}
@override
Widget build(BuildContext context) {
return WillPopScope(
onWillPop: ()async{
Navigator.pop(context,_selectedImages);
return false;
},
child: Scaffold(
appBar: AppBar(
backgroundColor: MyTheme.white,
iconTheme: IconThemeData(color: MyTheme.dark_grey),
title:Text(LangText(context: context)
.getLocal()!
.upload_file_ucf,style: MyTextStyle().appbarText(),) ,
// bottom: PreferredSize(child: buildUploadFileContainer(context),preferredSize: Size(DeviceInfo(context).getWidth(),75)),
actions: [
if(widget.canSelect && _selectedImages!.isNotEmpty)
IconButton(
splashRadius: 1.0,
iconSize: 50,
onPressed: (){
Navigator.pop(context, _selectedImages);
}, icon: Text("Select",style: MyTextStyle().appbarText().copyWith(color: MyTheme.green),)),
const SizedBox(width: 10,),
],
),
body: RefreshIndicator(
onRefresh: refresh,
child:Stack(children: [
_faceData
? _images.isEmpty
? Center(
child: Text(LangText(context: context)
.getLocal()!
.no_data_is_available),
)
: buildImageListView()
: buildShimmerList(context),
Container(
child: buildFilterSection(context),
)
],)
),
),
);
}
Widget buildShimmerList(BuildContext context) {
return SingleChildScrollView(
child: Column(
children: List.generate(
5,
(index) =>
Container(
margin: EdgeInsets.only(bottom: 20),
child: ShimmerHelper().buildBasicShimmer(
height: 96, width: DeviceInfo(context).getWidth()))),
),
);
}
Widget buildImageListView() {
return Padding(
padding: const EdgeInsets.only(top: 145.0),
child: GridView.builder(
controller: mainScrollController,
gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
crossAxisCount: 2, crossAxisSpacing: AppStyles.itemMargin),
//physics: NeverScrollableScrollPhysics(),
// shrinkWrap: true,
padding: EdgeInsets.all(AppStyles.itemMargin),
itemCount: _images.length,
itemBuilder: (context, index) {
return buildImageItem(index);
}),
);
}
int findIndex(id){
int index =0;
_selectedImages!.forEach((element) {
if(element.id==id){
index =_selectedImages!.indexOf(element);
}
});
return index;
}
Widget buildImageItem(int index) {
return InkWell(
splashColor: MyTheme.noColor,
onTap: (){
if(widget.canSelect){
if (widget.canMultiSelect) {
if (_selectedImages!.any((element) => element.id==_images[index].id)) {
int getIndex = findIndex(_images[index].id);
_selectedImages!.removeAt(getIndex);
} else {
_selectedImages!.add(_images[index]);
}
}else{
if (_selectedImages!.any((element) => element.id==_images[index].id)) {
_selectedImages!.removeWhere((element) => _selectedImages!.any((element) => element.id==_images[index].id));
} else {
_selectedImages=[];
_selectedImages!.add(_images[index]);
}
}
}
setState((){});
},
child: Stack(
children: [
MyWidget().productContainer(
width: DeviceInfo(context).getWidth(),
margin: EdgeInsets.only(bottom: 20),
padding: EdgeInsets.symmetric(horizontal: 10, vertical: 10),
height: 170,
borderColor: MyTheme.grey_153,
borderRadius: 10,
child: Column(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
_images[index].type!="document"? MyWidget.imageWithPlaceholder(
url: _images[index].url, height: 100.0, width: 100.0):
Container(
color: MyTheme.light_grey,
alignment: Alignment.center,
height: 100,
width: DeviceInfo(context).getWidth(),
child:Icon(Icons.description,size: 35,color: MyTheme.white,)
//Text("${_images[index].extension.toUpperCase()}",maxLines: 1,style: TextStyle(fontSize: 18,),overflow: TextOverflow.ellipsis,),
),
Text("${_images[index].fileOriginalName}.${_images[index].extension}",maxLines: 1,style: TextStyle(fontSize: 12,),overflow: TextOverflow.ellipsis,)
],
),
),
if(_selectedImages!.any((element) => element.id==_images[index].id))
Positioned(
top: 10,
right: 10,
child: buildCheckContainer()),
if(!widget.canMultiSelect && !widget.canSelect)
Positioned(
top: 10,
right: 10,
child: showOptions(imageId: _images[index].id,listIndex: index))
],
),
);
}
Widget buildUploadFileContainer(BuildContext context) {
return InkWell(
onTap: () {
chooseAndUploadFile(context);
},
child: MyWidget().myContainer(
marginY: 10.0,
marginX: 5,
height: 75,
width: DeviceInfo(context).getWidth(),
borderRadius: 10,
bgColor: MyTheme.app_accent_color_extra_light,
borderColor: MyTheme.app_accent_color,
child: Column(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: [
Text(
LangText(context: context)
.getLocal()!
.upload_file_ucf,
style: TextStyle(
fontWeight: FontWeight.bold,
fontSize: 12,
color: MyTheme.app_accent_color),
),
Icon(
Icons.upload_file,
size: 18,
color: MyTheme.app_accent_color,
)
/*
Image.asset(
'assets/icon/add.png',
width: 18,
height: 18,
color: MyTheme.app_accent_color,
)*/
],
)),
);
}
buildFilterSection(BuildContext context) {
return Column(
children: [
SizedBox(height: 10,),
buildUploadFileContainer(context),
Container(
height: 40,
margin: EdgeInsets.only(top: 10),
child: Padding(
padding: EdgeInsets.symmetric(horizontal: AppStyles.layoutMargin),
child: Row(
//mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Container(
width: DeviceInfo(context).getWidth()/2-AppStyles.layoutMargin*1.5,
padding: const EdgeInsets.symmetric(horizontal: 8, vertical: 8),
decoration: MDecoration.decoration1(),
child: DropdownButton<CommonDropDownItem>(
isDense: true,
underline: Container(),
isExpanded: true,
onChanged: (value) {
sortBy=value;
sorted();
//onchange(value);
},
icon: const Icon(Icons.arrow_drop_down),
value: sortBy,
items: sortList
.map(
(value) => DropdownMenuItem<CommonDropDownItem>(
value: value,
child: Text(
value.value!,
),
),
)
.toList(),
),
),
const Spacer(),
Container(
decoration: MDecoration.decoration1(),
width:DeviceInfo(context).getWidth()/2-AppStyles.layoutMargin*1.5,
child: Row(
children: [
buildFlatEditTextFiled(),
InkWell(
onTap: (){
search();
},
child:const SizedBox(
width: 40,
child: Icon(Icons.search_sharp),
),
)
],
))
// SizedBox(width: 10,)
],
),
)),
],
);
}
Widget buildFlatEditTextFiled() {
return Container(
// decoration: BoxDecoration(
// borderRadius: BorderRadius.circular(8),
// color: MyTheme.app_accent_color_extra_light),
width: DeviceInfo(context).getWidth()/2-(AppStyles.layoutMargin*1.5+50),
padding: EdgeInsets.symmetric(horizontal: 8),
height: 45,
alignment: Alignment.center,
child: TextField(
controller: searchEditingController,
decoration: const InputDecoration.collapsed(hintText: "Search"),
),
);
}
Widget buildCheckContainer() {
return AnimatedOpacity(
duration: Duration(milliseconds: 400),
opacity: 1,
child: Container(
height: 16,
width: 16,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(16.0), color: Colors.green),
child: Padding(
padding: const EdgeInsets.all(3),
child: Icon(Icons.check, color: Colors.white, size: 10),
),
),
);
/* Visibility(
visible: check,
child: Container(
height: 16,
width: 16,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(16.0), color: Colors.green),
child: Padding(
padding: const EdgeInsets.all(3),
child: Icon(FontAwesome.check, color: Colors.white, size: 10),
),
),
);*/
}
Widget showOptions({listIndex, imageId}) {
return Container(
width: 35,
child: PopupMenuButton<MenuOptions>(
offset: Offset(-12, 0),
child: Padding(
padding: EdgeInsets.zero,
child: Container(
width: 35,
padding: EdgeInsets.symmetric(horizontal: 15),
alignment: Alignment.topRight,
child: Image.asset("assets/icon/more.png",
width: 3, height: 15, fit: BoxFit.contain, color: MyTheme.grey_153),
),
),
onSelected: (MenuOptions result) {
_tabOption(result.index, imageId, listIndex);
// setState(() {
// //_menuOptionSelected = result;
// });
},
itemBuilder: (BuildContext context) => <PopupMenuEntry<MenuOptions>>[
const PopupMenuItem<MenuOptions>(
value: MenuOptions.Delete,
child: Text('Delete'),
),
],
),
);
}
}
enum MenuOptions { Delete }

View File

@@ -0,0 +1,521 @@
import 'dart:convert';
import 'dart:io';
import 'package:active_ecommerce_seller_app/data_model/common_response.dart';
import 'package:http/http.dart' as http;
import 'package:active_ecommerce_seller_app/app_config.dart';
import 'package:active_ecommerce_seller_app/custom/buttons.dart';
import 'package:active_ecommerce_seller_app/custom/decorations.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_widget.dart';
import 'package:active_ecommerce_seller_app/custom/toast_component.dart';
import 'package:active_ecommerce_seller_app/data_model/verification_form_response.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/shop_repository.dart';
import 'package:file_picker/file_picker.dart';
import 'package:flutter/material.dart';
import 'package:toast/toast.dart';
class VerifyPage extends StatefulWidget {
const VerifyPage({Key? key}) : super(key: key);
@override
State<VerifyPage> createState() => _VerifyPageState();
}
class _VerifyPageState extends State<VerifyPage> {
List<VerificationModel> formList = [];
late BuildContext loadingContext;
bool isFetchData = false;
getFormData() async {
var response = await ShopRepository.getFormDataRequest();
for (int i = 0; i < response.length; i++) {
if (response[i].type == "text") {
TextEditingController value = TextEditingController();
formList.add(VerificationModel<TextEditingController?>(
key: "element_$i",
type: response[i].type,
title: response[i].label,
data: value));
} else if (response[i].type == "file") {
File? value;
formList.add(VerificationModel<File?>(
key: "element_$i",
type: response[i].type,
title: response[i].label,
data: value));
} else if (response[i].type == "select") {
String? value;
var options = jsonDecode(response[i].options!);
print(options);
formList.add(VerificationModel<String?>(
key: "element_$i",
type: response[i].type,
title: response[i].label,
data: value,
options: options));
} else if (response[i].type == "multi_select") {
List<String> value = [];
var options = jsonDecode(response[i].options!);
formList.add(VerificationModel<List<String>?>(
key: "element_$i",
type: response[i].type,
title: response[i].label,
data: value,
options: options));
} else if (response[i].type == "radio") {
var options = jsonDecode(response[i].options!);
String? value = options.first;
formList.add(VerificationModel<String?>(
key: "element_$i",
type: response[i].type,
title: response[i].label,
data: value,
options: options));
}
}
isFetchData = true;
setState(() {});
}
onVerify() async {
Map<String?, String> data = Map();
Uri url =
Uri.parse("${AppConfig.BASE_URL_WITH_PREFIX}/shop-verify-info-store");
Map<String, String> header = {
"App-Language": app_language.$!,
"Authorization": "Bearer ${access_token.$}",
"Content-Type":
"multipart/form-data; boundary=<calculated when request is sent>",
"Accept": "*/*",
};
final httpReq = http.MultipartRequest("POST", url);
httpReq.headers.addAll(header);
for (VerificationModel element in formList) {
if (element.type == "text") {
if (element.data.text.trim().toString().isEmpty) {
ToastComponent.showDialog("${element.title} is Empty");
return;
}
data.addAll({element.key: element.data.text.trim().toString()});
} else if (element.type == "select") {
if (element.data == null || element.data.toString().isEmpty) {
ToastComponent.showDialog("${element.title} is Empty");
return;
}
data.addAll({element.key: element.data.toString()});
} else if (element.type == "multi_select") {
if (element.data == null || element.data.isEmpty) {
ToastComponent.showDialog("${element.title} is Empty");
return;
}
data.addAll({element.key: element.data.join(",").toString()});
} else if (element.type == "radio") {
if (element.data == null || element.data.toString().isEmpty) {
ToastComponent.showDialog("${element.title} is Empty");
return;
}
data.addAll({element.key: element.data.toString()});
} else if (element.type == "file") {
if (element.data == null || element.data.toString().isEmpty) {
ToastComponent.showDialog("${element.title} is Empty");
return;
}
final image =
await http.MultipartFile.fromPath(element.key!, element.data.path);
httpReq.files.add(image);
}
}
httpReq.fields.addAll(data as Map<String, String>);
loading();
var response = await httpReq.send();
Navigator.pop(loadingContext);
response.stream.bytesToString().then((value) {
var res = commonResponseFromJson(value);
ToastComponent.showDialog(res.message);
if (res.result!) {
Navigator.pop(context, true);
verify_form_submitted.$ = true;
verify_form_submitted.save();
}
});
}
@override
void initState() {
getFormData();
// TODO: implement initState
super.initState();
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: buildAppBar(context),
body: isFetchData
? ListView.separated(
padding: EdgeInsets.symmetric(horizontal: 24, vertical: 24),
itemBuilder: (context, index) => Container(
padding: EdgeInsets.only(bottom: 10),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
buildTitle(formList[index].title),
SizedBox(
height: 10,
),
if (formList[index].type == "text")
buildEditTextField(
formList[index].title, formList[index].data)
else if (formList[index].type == "select")
buildDropDown(index, formList[index] as VerificationModel<String?>)
else if (formList[index].type == "multi_select")
buildMultiSelect(index)
else if (formList[index].type == "file")
buildFile(index)
else if (formList[index].type == "radio")
buildRadio(index),
],
),
),
separatorBuilder: (context, index) => const SizedBox(
height: 10,
),
itemCount: formList.length)
: Center(
child: CircularProgressIndicator(),
),
bottomNavigationBar: Buttons(
height: 50,
shape: RoundedRectangleBorder(),
onPressed: () {
onVerify();
},
color: MyTheme.app_accent_color,
width: DeviceInfo(context).getWidth(),
child: Text(
LangText(context: context).getLocal()!.submit_ucf,
style: TextStyle(fontSize: 14, color: MyTheme.white),
),
),
);
}
AppBar buildAppBar(BuildContext context) {
return AppBar(
backgroundColor: Colors.white,
centerTitle: true,
leading: Builder(
builder: (context) => IconButton(
icon: Icon(Icons.arrow_back, color: MyTheme.dark_grey),
onPressed: () => Navigator.of(context).pop(),
),
),
title: Text(
LangText(context: context).getLocal()!.verification_form_ucf,
style: TextStyle(fontSize: 16, color: MyTheme.app_accent_color),
),
elevation: 0.0,
titleSpacing: 0,
);
}
Widget buildEditTextField(
String? hint, TextEditingController? textEditingController) {
return MyWidget.customCardView(
backgroundColor: MyTheme.white,
elevation: 5,
width: DeviceInfo(context).getWidth(),
height: 46,
borderRadius: 10,
child: TextField(
controller: textEditingController,
decoration: InputDecorations.buildInputDecoration_1(
hint_text: hint,
borderColor: MyTheme.noColor,
hintTextColor: MyTheme.grey_153),
),
);
}
Text buildTitle(title) {
return Text(
title,
style: const TextStyle(
fontSize: 14, fontWeight: FontWeight.bold, color: MyTheme.font_grey),
);
}
setChange() {
setState(() {});
}
Widget buildDropDown(int index, VerificationModel<String?> model) {
return Container(
height: 46,
width: DeviceInfo(context).getWidth(),
padding: const EdgeInsets.symmetric(horizontal: 18, vertical: 10),
decoration: MDecoration.decoration1(),
child: DropdownButton<String>(
menuMaxHeight: 300,
isDense: true,
underline: Container(),
isExpanded: true,
onChanged: (String? value) {
formList[index].data = value;
setChange();
},
icon: const Icon(Icons.arrow_drop_down),
value: model.data,
items: formList[index]
.options!
.map(
(value) => DropdownMenuItem<String>(
value: value,
child: Text(
value,
),
),
)
.toList(),
),
);
}
Widget buildMultiSelect(int index) {
return Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Container(
height: 46,
width: DeviceInfo(context).getWidth(),
padding: const EdgeInsets.symmetric(horizontal: 18, vertical: 10),
decoration: MDecoration.decoration1(),
child: DropdownButton<String>(
menuMaxHeight: 300,
isDense: true,
underline: Container(),
isExpanded: true,
onChanged: (String? value) {
if (!formList[index].data.contains(value)) {
formList[index].data.add(value);
}
setChange();
},
icon: const Icon(Icons.arrow_drop_down),
items: formList[index]
.options!
.map(
(value) => DropdownMenuItem<String>(
value: value,
child: Text(
value,
),
),
)
.toList(),
),
),
Wrap(
children: List.generate(
formList[index].data.length,
(subIndex) => SizedBox(
width: 90,
child: Row(
children: [
SizedBox(
width: 40, child: Text(formList[index].data[subIndex])),
Buttons(
onPressed: () {
formList[index].data.removeAt(subIndex);
setState(() {});
},
width: 30,
height: 30,
child: Icon(
Icons.close,
size: 15,
),
)
],
),
),
),
)
],
);
}
Widget buildFile(int index) {
return Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Buttons(
padding: EdgeInsets.zero,
onPressed: () async {
FilePickerResult? file = await pickSingleFile();
if (file == null) {
ToastComponent.showDialog(
LangText(context: context).getLocal()!.no_file_is_chosen,
gravity: Toast.center,
duration: Toast.lengthLong);
return;
}
formList[index].data = File(file.paths.first!);
setState(() {});
},
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(6)),
child: MyWidget().myContainer(
width: DeviceInfo(context).getWidth(),
height: 46,
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: 46,
width: 80,
color: MyTheme.light_grey,
child: Text(
"Browse",
style: TextStyle(fontSize: 12, color: MyTheme.grey_153),
)),
],
)),
),
SizedBox(
height: 8,
),
formList[index].data != null
? Image.file(
formList[index].data,
height: 100,
width: 100,
)
: const SizedBox.shrink(),
],
);
}
Future<FilePickerResult?> pickSingleFile() async {
return await FilePicker.platform
.pickFiles(type: FileType.custom, allowedExtensions: [
"jpg",
"jpeg",
"png",
"svg",
"webp",
"gif",
"mp4",
"mpg",
"mpeg",
"webm",
"ogg",
"avi",
"mov",
"flv",
"swf",
"mkv",
"wmv",
"wma",
"aac",
"wav",
"mp3",
"zip",
"rar",
"7z",
"doc",
"txt",
"docx",
"pdf",
"csv",
"xml",
"ods",
"xlr",
"xls",
"xlsx"
]);
}
Widget radio(index, subIndex) {
return Radio<String>(
value: formList[index].options![subIndex],
groupValue: formList[index].data,
onChanged: (String? value) {
formList[index].data = value;
setState(() {});
},
);
}
buildRadio(index) {
return Column(
children: List.generate(
formList[index].options!.length,
(subIndex) => Row(
children: [
radio(index, subIndex),
Text(
formList[index].options![subIndex],
style: TextStyle(fontSize: 14, color: MyTheme.font_grey),
)
],
)),
);
}
loading() {
return showDialog(
context: context,
builder: (context) {
loadingContext = context;
return AlertDialog(
content: Row(
children: [
const CircularProgressIndicator(),
const SizedBox(
width: 10,
),
Text(LangText(context: context).getLocal()!.please_wait_ucf),
],
));
});
}
}
class VerificationModel<T> {
String? key, type, title;
T data;
List<dynamic>? options;
VerificationModel(
{required this.key,
required this.type,
required this.title,
required this.data,
this.options});
}

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,767 @@
import 'package:active_ecommerce_seller_app/const/app_style.dart';
import 'package:active_ecommerce_seller_app/custom/buttons.dart';
import 'package:active_ecommerce_seller_app/custom/common_style.dart';
import 'package:active_ecommerce_seller_app/custom/device_info.dart';
import 'package:active_ecommerce_seller_app/custom/loading.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/route_transaction.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/product_review_response.dart';
import 'package:active_ecommerce_seller_app/data_model/products_response.dart';
import 'package:active_ecommerce_seller_app/dummy_data/allProducts.dart';
import 'package:active_ecommerce_seller_app/dummy_data/topProduct.dart';
import 'package:active_ecommerce_seller_app/helpers/reg_ex_inpur_formatter.dart';
import 'package:active_ecommerce_seller_app/helpers/shared_value_helper.dart';
import 'package:active_ecommerce_seller_app/helpers/shimmer_helper.dart';
import 'package:active_ecommerce_seller_app/my_theme.dart';
import 'package:active_ecommerce_seller_app/repositories/product_repository.dart';
import 'package:active_ecommerce_seller_app/repositories/shop_repository.dart';
import 'package:active_ecommerce_seller_app/screens/product/new_product.dart';
import 'package:active_ecommerce_seller_app/screens/product/product_reviews.dart';
import 'package:active_ecommerce_seller_app/screens/packages.dart';
import 'package:active_ecommerce_seller_app/screens/whole_sale_product/update_product.dart';
import 'package:active_ecommerce_seller_app/screens/whole_sale_product/new_product.dart';
import 'package:active_ecommerce_seller_app/ui_elements/product_card.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter_gen/gen_l10n/app_localizations.dart';
import 'package:one_context/one_context.dart';
import 'package:route_transitions/route_transitions.dart';
import 'package:toast/toast.dart';
class WholeSaleProducts extends StatefulWidget {
final bool fromBottomBar;
const WholeSaleProducts({Key? key, this.fromBottomBar = false}) : super(key: key);
@override
WholeSaleProductsState createState() => WholeSaleProductsState();
}
class WholeSaleProductsState extends State<WholeSaleProducts> {
bool _isProductInit = false;
bool _showMoreProductLoadingContainer = false;
List<Product> _productList = [];
// List<bool> _productStatus=[];
// List<bool> _productFeatured=[];
String _remainingProduct = "...";
String? _currentPackageName = "...";
late BuildContext loadingContext;
late BuildContext switchContext;
late BuildContext featuredSwitchContext;
//MenuOptions _menuOptionSelected = MenuOptions.Published;
ScrollController _scrollController =
new ScrollController(initialScrollOffset: 0);
// double variables
double mHeight = 0.0, mWidht = 0.0;
int _page = 1;
getProductList() async {
var productResponse = await ProductRepository().getWholesaleProducts(page: _page);
if (productResponse.data!.isEmpty) {
ToastComponent.showDialog(
LangText(context: context).getLocal()!.no_more_products_ucf,
gravity: Toast.center,
bgColor: MyTheme.white,
textStyle:TextStyle(color:Colors.black) );
}
_productList.addAll(productResponse.data!);
_showMoreProductLoadingContainer = false;
_isProductInit = true;
setState(() {});
}
Future<bool> _getAccountInfo() async {
var response = await ShopRepository().getShopInfo();
_currentPackageName=response.shopInfo!.sellerPackage;
setState(() {});
return true;
}
getProductRemainingUpload() async {
var productResponse = await ProductRepository().remainingUploadProducts();
_remainingProduct = productResponse.ramainingProduct.toString();
setState(() {});
}
deleteProduct(int? id) async {
loading();
var response = await ProductRepository().wholesaleProductDeleteReq(id: id);
Navigator.pop(loadingContext);
if (response.result) {
resetAll();
}
ToastComponent.showDialog(response.message,
gravity: Toast.center,
duration: 3,
textStyle: TextStyle(color: MyTheme.black),
);
}
productStatusChange(int? index, bool value, setState, id) async {
loading();
var response = await ProductRepository()
.productStatusChangeReq(id: id, status: value ? 1 : 0);
Navigator.pop(loadingContext);
if (response.result) {
// _productStatus[index] = value;
_productList[index!].status = value;
resetAll();
}
Navigator.pop(switchContext);
ToastComponent.showDialog(response.message,
gravity: Toast.center,
duration: 3,
textStyle: TextStyle(color: MyTheme.black),
);
}
productFeaturedChange({int? index, required bool value, setState, id}) async {
print(value);
loading();
var response = await ProductRepository()
.productFeaturedChangeReq(id: id, featured: value ? 1 : 0);
Navigator.pop(loadingContext);
if (response.result) {
// _productFeatured[index]=value;
_productList[index!].featured = value;
resetAll();
}
Navigator.pop(featuredSwitchContext);
ToastComponent.showDialog(response.message,
gravity: Toast.center,
duration: 3,
textStyle: TextStyle(color: MyTheme.black),
);
}
scrollControllerPosition() {
_scrollController.addListener(() {
if (_scrollController.position.pixels ==
_scrollController.position.maxScrollExtent) {
_showMoreProductLoadingContainer = true;
setState(() {
_page++;
});
getProductList();
}
});
}
cleanAll() {
_isProductInit = false;
_showMoreProductLoadingContainer = false;
_productList = [];
_page = 1;
// _productStatus=[];
// _productFeatured=[];
_remainingProduct = "....";
_currentPackageName="...";
setState(() {});
}
fetchAll() {
getProductList();
_getAccountInfo();
getProductRemainingUpload();
setState(() {});
}
resetAll() {
cleanAll();
fetchAll();
}
_tabOption(int index, productId, listIndex) {
switch (index) {
case 0:
slideRightWidget( newPage: UpdateProduct(productId: productId,),context: context).then((value){
resetAll();
});
break;
case 1:
showPublishUnPublishDialog(listIndex, productId);
break;
case 2:
showFeaturedUnFeaturedDialog(listIndex, productId);
break;
case 3:
showDeleteWarningDialog(productId);
//deleteProduct(productId);
break;
default:
break;
}
}
@override
void initState() {
scrollControllerPosition();
fetchAll();
super.initState();
}
@override
Widget build(BuildContext context) {
mHeight = MediaQuery.of(context).size.height;
mWidht = MediaQuery.of(context).size.width;
return Directionality(
textDirection: app_language_rtl.$! ? TextDirection.rtl : TextDirection.ltr,
child: Scaffold(
appBar:!widget.fromBottomBar? MyAppBar(
context: context,
title:
LangText(context: context).getLocal()!.wholesale_products_ucf)
.show():null,
body: RefreshIndicator(
triggerMode: RefreshIndicatorTriggerMode.anywhere,
onRefresh: () async {
resetAll();
// Future.delayed(Duration(seconds: 1));
},
child: SingleChildScrollView(
physics: AlwaysScrollableScrollPhysics(),
controller: _scrollController,
child: Column(
children: [
SizedBox(height: 20,),
buildTop2BoxContainer(context),
Visibility(
visible: seller_package_addon.$,
child: buildPackageUpgradeContainer(context)),
SizedBox(
height: 20,
),
Container(
child: _isProductInit
? productsContainer()
: ShimmerHelper().buildListShimmer(
item_count: 20, item_height: 80.0),
),
],
),
),
),
),
);
}
Widget buildPackageUpgradeContainer(BuildContext context) {
return Column(
children: [
SizedBox(
height: AppStyles.itemMargin,
),
MyWidget().myContainer(
marginY: 15,
height: 40,
width: DeviceInfo(context).getWidth(),
borderRadius: 6,
borderColor: MyTheme.app_accent_color,
bgColor: MyTheme.app_accent_color_extra_light,
child: InkWell(
onTap: () {
MyTransaction(context: context).push(Packages());
},
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: [
Row(
children: [
Image.asset("assets/icon/package.png", height: 20, width: 20),
SizedBox(
width: 5,
),
Text(
LangText(context: context)
.getLocal()!
.current_package_ucf,
style: TextStyle(fontSize: 10, color: MyTheme.grey_153),
),
SizedBox(
width: 5,
),
Text(
_currentPackageName!,
style: TextStyle(
fontSize: 10,
color: MyTheme.app_accent_color,
fontWeight: FontWeight.bold),
),
],
),
SizedBox(
width: 5,
),
Row(
children: [
Text(
LangText(context: context)
.getLocal()!
.upgrade_package_ucf,
style: TextStyle(
fontSize: 12,
color: MyTheme.app_accent_color,
fontWeight: FontWeight.bold),
),
SizedBox(
width: 8,
),
Image.asset("assets/icon/next_arrow.png",
color: MyTheme.app_accent_color,
height: 8.7, width: 7),
],
),
],
),
)),
],
);
}
Container buildTop2BoxContainer(BuildContext context) {
return Container(
margin: EdgeInsets.symmetric(horizontal: 15),
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Container(
padding: EdgeInsets.all(10),
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(10),
//border: Border.all(color: MyTheme.app_accent_border),
color: MyTheme.app_accent_color,
),
height: 75,
width: mWidht / 2 - 23,
child: Column(
crossAxisAlignment: CrossAxisAlignment.center,
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: [
Text(
LangText(context: context)
.getLocal()!
.remaining_uploads,
style: MyTextStyle().dashboardBoxText(context),
),
Text(
_remainingProduct,
style: MyTextStyle().dashboardBoxNumber(context),
),
],
)),
SizedBox(width: AppStyles.itemMargin,),
Container(
child: SubmitBtn.show(
onTap: () {
MyTransaction(context: context).push( const NewWholeSaleProduct()).then((value){
resetAll();
});
},
borderColor: MyTheme.app_accent_color,
backgroundColor: MyTheme.app_accent_color_extra_light,
height: 75,
width: mWidht / 2 - 23,
radius: 10,
child: Container(
padding: EdgeInsets.all(10),
height: 75,
child: Column(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: [
Text(
LangText(context: context)
.getLocal()!
.add_new_product_ucf,
style: MyTextStyle()
.dashboardBoxText(context)
.copyWith(color: MyTheme.app_accent_color),
),
Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Image.asset(
'assets/icon/add.png',
color: MyTheme.app_accent_color,
height: 24,
width: 42,
fit: BoxFit.contain,
),
],
)
],
),
),
)),
],
),
);
}
Widget productsContainer() {
return Container(
padding: EdgeInsets.symmetric(horizontal: 15),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
LangText(context: context).getLocal()!.all_products_ucf,
style: TextStyle(
fontSize: 14,
fontWeight: FontWeight.bold,
color: MyTheme.app_accent_color),
),
SizedBox(
height: 10,
),
ListView.builder(
physics: NeverScrollableScrollPhysics(),
itemCount: _productList.length + 1,
shrinkWrap: true,
itemBuilder: (context, index) {
// print(index);
if (index == _productList.length) {
return moreProductLoading();
}
return productItem(
index: index,
productId: _productList[index].id,
imageUrl: _productList[index].thumbnailImg,
productTitle: _productList[index].name!,
category: _productList[index].category,
productPrice: _productList[index].price.toString(),
quantity: _productList[index].quantity.toString());
}),
],
),
);
}
Container productItem(
{int? index,
productId,
String? imageUrl,
required String productTitle,
required category,
required String productPrice,
required String quantity}) {
return MyWidget.customCardView(
elevation: 5,
backgroundColor: MyTheme.white,
height: 90,
width: mWidht,
margin: EdgeInsets.only(bottom: 20,),
borderColor: MyTheme.light_grey,
borderRadius: 6,
child: InkWell(
onTap: (){
slideRightWidget( newPage: UpdateProduct(productId: productId,),context: context).then((value){
resetAll();
});
},
child: Row(
children: [
MyWidget.imageWithPlaceholder(
width: 84.0,
height: 90.0,
fit: BoxFit.cover,
url: imageUrl,
radius: BorderRadius.only(
topLeft: Radius.circular(5),
bottomLeft: Radius.circular(5),),),
// Image.asset(ImageUrl,width: 80,height: 80,fit: BoxFit.contain,),
SizedBox(
width: 11,
),
Container(
width: mWidht - 129,
child: Column(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Container(
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Container(
width: mWidht - 170,
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
productTitle,
style:
TextStyle(fontSize: 12, color: MyTheme.font_grey,fontWeight: FontWeight.w400),
maxLines: 1,
overflow: TextOverflow.ellipsis,
),
SizedBox(
height: 3,
),
Text(
category,
style: TextStyle(
fontSize: 10,
color: MyTheme.grey_153,
fontWeight: FontWeight.w400
),
maxLines: 1,
overflow: TextOverflow.ellipsis,
),
],
),
),
Container(
child:
showOptions(listIndex: index, productId: productId),
),
],
),
),
Container(
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Container(
child: Text(productPrice,
style: TextStyle(
fontSize: 13, color: MyTheme.app_accent_color,fontWeight: FontWeight.w500)),
),
Row(
children: [
Image.asset(
"assets/icon/product.png",
width: 10,
height: 10,
fit: BoxFit.contain,
),
SizedBox(
width: 7,
),
Padding(
padding: const EdgeInsets.only(right: 15.0),
child: Text(quantity,
style: TextStyle(
fontSize: 13, color: MyTheme.grey_153)),
),
],
),
],
),
),
],
),
),
],
),
)) as Container;
}
showDeleteWarningDialog(id){
showDialog(context: context, builder: (context)=>Container(
width: DeviceInfo(context).getWidth()*1.5,
child: AlertDialog(
title: Text(LangText(context: context).getLocal()!.warning_ucf,style: TextStyle(fontWeight: FontWeight.bold,fontSize: 15,color: MyTheme.red),),
content: Text(LangText(context: context).getLocal()!.do_you_want_to_delete_it,style:const TextStyle(fontWeight: FontWeight.w400,fontSize: 14),),
actions: [
Buttons(
color: MyTheme.app_accent_color,
onPressed: (){
Navigator.pop(context);
}, child: Text(LangText(context: context).getLocal()!.no_ucf,style: TextStyle(color: MyTheme.white,fontSize: 12),)),
Buttons(
color: MyTheme.app_accent_color,
onPressed: (){
Navigator.pop(context);
deleteProduct(id);
}, child: Text(LangText(context: context).getLocal()!.yes_ucf,style: TextStyle(color: MyTheme.white,fontSize: 12))),
],
),
));
}
Widget showOptions({listIndex, productId}) {
return Container(
width: 35,
child: PopupMenuButton<MenuOptions>(
offset: Offset(-12, 0),
child: Padding(
padding: EdgeInsets.zero,
child: Container(
width: 35,
padding: EdgeInsets.symmetric(horizontal: 15),
alignment: Alignment.topRight,
child: Image.asset("assets/icon/more.png",
width: 3, height: 15, fit: BoxFit.contain, color: MyTheme.grey_153),
),
),
onSelected: (MenuOptions result) {
_tabOption(result.index, productId, listIndex);
// setState(() {
// //_menuOptionSelected = result;
// });
},
itemBuilder: (BuildContext context) => <PopupMenuEntry<MenuOptions>>[
const PopupMenuItem<MenuOptions>(
value: MenuOptions.Edit,
child: Text('Edit'),
),
const PopupMenuItem<MenuOptions>(
value: MenuOptions.Published,
child: Text('Published'),
),
const PopupMenuItem<MenuOptions>(
value: MenuOptions.Featured,
child: Text('Featured'),
),
const PopupMenuItem<MenuOptions>(
value: MenuOptions.Delete,
child: Text('Delete'),
),
],
),
);
}
void showPublishUnPublishDialog(int? index, id) {
//print(index.toString()+" "+_productStatus[index].toString());
showDialog(
context: context,
builder: (context) {
switchContext = context;
return StatefulBuilder(builder: (context, setState) {
return Container(
height: 75,
width: DeviceInfo(context).getWidth(),
child: AlertDialog(
content: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Text(
_productList[index!].status ? "Published" : "Unpublished",
style: TextStyle(
fontSize: 13,
fontWeight: FontWeight.w500,
color: Colors.black),
),
Switch(
value: _productList[index].status,
activeColor: MyTheme.green,
inactiveThumbColor: MyTheme.grey_153,
onChanged: (value) {
productStatusChange(index, value, setState, id);
},
),
],
),
),
);
});
});
}
void showFeaturedUnFeaturedDialog(int? index, id) {
//print(_productFeatured[index]);
print(index);
showDialog(
context: context,
builder: (context) {
featuredSwitchContext = context;
return StatefulBuilder(builder: (context, setState) {
return Container(
height: 75,
width: DeviceInfo(context).getWidth(),
child: AlertDialog(
content: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Text(
_productList[index!].featured ? "Featured" : "Unfeatured",
style: TextStyle(
fontSize: 13,
fontWeight: FontWeight.w500,
color: Colors.black),
),
Switch(
value: _productList[index].featured,
activeColor: MyTheme.green,
inactiveThumbColor: MyTheme.grey_153,
onChanged: (value) {
productFeaturedChange(
index: index,
value: value,
setState: setState,
id: id);
},
),
],
),
),
);
});
});
}
loading() {
showDialog(
context: context,
builder: (context) {
loadingContext = context;
return AlertDialog(
content: Row(
children: [
CircularProgressIndicator(),
SizedBox(
width: 10,
),
Text("${AppLocalizations.of(context)!.please_wait_ucf}"),
],
));
});
}
Widget moreProductLoading() {
return _showMoreProductLoadingContainer
? Container(
alignment: Alignment.center,
child: SizedBox(
height: 40,
width: 40,
child: Row(
children: [
SizedBox(
width: 2,
height: 2,
),
CircularProgressIndicator(),
],
),
),
)
: SizedBox(
height: 5,
width: 5,
);
}
}
enum MenuOptions { Edit,Published, Featured, Delete, Duplicate }

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,196 @@
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/my_theme.dart';
import 'package:active_ecommerce_seller_app/repositories/withdraw_repository.dart';
import 'package:flutter/material.dart';
import 'package:toast/toast.dart';
import 'package:validators/validators.dart';
class SendAWithdrwRequest extends StatefulWidget {
const SendAWithdrwRequest({Key? key}) : super(key: key);
@override
State<SendAWithdrwRequest> createState() => _SendAWithdrwRequestState();
}
class _SendAWithdrwRequestState extends State<SendAWithdrwRequest> {
sendRequest() async {
var response =
await WithdrawRepository().sendWithdrawReq(_message, _amount);
if (response.result!) {
ToastComponent.showDialog(response.message,
gravity: Toast.center, duration: Toast.lengthLong);
cleanAll();
} else {
ToastComponent.showDialog(response.message,
gravity: Toast.center, duration: Toast.lengthLong);
}
}
String? _message, _amount;
TextEditingController _messageTextController = TextEditingController();
TextEditingController _amountTextController = TextEditingController();
List<String> _errors = [];
cleanAll(){
_message=""; _amount="";
_messageTextController.text="";
_amountTextController.text="";
_errors = [];
setState(() {
});
}
checkData() {
_errors = [];
_message = _messageTextController.text.trim();
_amount = _amountTextController.text.trim();
if (!isNumeric(_amount!) || _amount!.isEmpty) {
_errors.add(LangText(context: context)
.getLocal()!
.amount_is_invalid);
}
if (_message!.isEmpty) {
_errors.add(LangText(context: context)
.getLocal()!
.message_is_invalid);
}
setState(() {
});
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: MyAppBar(
context: context,
title: LangText(context: context)
.getLocal()!
.send_withdraw_request_ucf)
.show(),
body: SingleChildScrollView(
child: Container(
padding: EdgeInsets.symmetric(horizontal: 15),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
SizedBox(height: 20,),
Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
LangText(context: context)
.getLocal()!
.amount_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(
keyboardType: TextInputType.number,
controller: _amountTextController,
decoration: InputDecorations.buildInputDecoration_1(
hint_text: LangText(context: context)
.getLocal()!
.amount_ucf,
borderColor: MyTheme.noColor,
hintTextColor: MyTheme.grey_153),
),
),
],
),
SizedBox(
height: 14,
),
Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
LangText(context: context)
.getLocal()!
.message_ucf,
style: TextStyle(
fontSize: 12,
color: MyTheme.font_grey,
fontWeight: FontWeight.bold),
),
SizedBox(
height: 10,
),
MyWidget.customCardView(
width: DeviceInfo(context).getWidth(),
backgroundColor: MyTheme.white,
borderRadius: 6,
elevation: 5,
height: 80,
padding: EdgeInsets.all(6),
borderColor: MyTheme.light_grey,
child: TextField(
controller: _messageTextController,
decoration: InputDecoration.collapsed(
hintText: "Type your message",
hintStyle:
TextStyle(color: MyTheme.grey_153, fontSize: 12)),
maxLines: 6,
),
),
],
),
Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: List.generate(
_errors.length,
(index) => Text(
_errors[index],
style: TextStyle(fontSize: 15, color: MyTheme.red),
)),
),
Container(
width: DeviceInfo(context).getWidth(),
alignment: Alignment.topRight,
child: SubmitBtn.show(
elevation: 10,
height: 30.0,
alignment: Alignment.center,
width: 120.0,
child: Text(
LangText(context: context)
.getLocal()!
.submit_ucf,
style: TextStyle(color: MyTheme.white, fontSize: 13),
),
backgroundColor: MyTheme.app_accent_color,
onTap: () {
checkData();
if (_errors.isEmpty) {
sendRequest();
}
},
radius: 2.0),
),
],
),
),
),
);
}
}