Merge branch 'zik_new_design_flutter_v2.5' into 'development_v2.5'
Packages and offers fixes, HMG Internet work in progress, See merge request Cloud_Solution/diplomatic-quarter!582merge-requests/583/merge
commit
9674376163
@ -0,0 +1,160 @@
|
|||||||
|
package com.ejada.hmg.hmgwifi
|
||||||
|
|
||||||
|
import android.annotation.SuppressLint
|
||||||
|
import android.content.Context
|
||||||
|
import android.net.ConnectivityManager
|
||||||
|
import android.net.Network
|
||||||
|
import android.net.NetworkCapabilities
|
||||||
|
import android.net.NetworkRequest
|
||||||
|
import android.net.wifi.*
|
||||||
|
import android.net.wifi.SupplicantState.ASSOCIATED
|
||||||
|
import android.net.wifi.SupplicantState.COMPLETED
|
||||||
|
import android.os.Build
|
||||||
|
import android.util.Log
|
||||||
|
import androidx.annotation.RequiresApi
|
||||||
|
import com.ejada.hmg.MainActivity
|
||||||
|
import com.ejada.hmg.utils.HMGUtils
|
||||||
|
|
||||||
|
class WpaEnterprise(private val mainActivity: MainActivity, private var SSID: String) {
|
||||||
|
private var TAG = "WpaEnterprise"
|
||||||
|
|
||||||
|
private lateinit var identity:String
|
||||||
|
private lateinit var password:String
|
||||||
|
private lateinit var completion:((status: Boolean, message: String) -> Unit)
|
||||||
|
|
||||||
|
fun connect(identity:String, password:String, completion: (status: Boolean, message: String) -> Unit) {
|
||||||
|
this.password = password
|
||||||
|
this.identity = identity
|
||||||
|
this.completion = completion
|
||||||
|
|
||||||
|
if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q){
|
||||||
|
apiGreaterThen28()
|
||||||
|
}else if(Build.VERSION.SDK_INT < Build.VERSION_CODES.Q){
|
||||||
|
apiLessThen29()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@RequiresApi(Build.VERSION_CODES.LOLLIPOP)
|
||||||
|
fun apiLessThen29(){
|
||||||
|
val wifiManager = mainActivity.applicationContext.getSystemService(Context.WIFI_SERVICE) as WifiManager
|
||||||
|
|
||||||
|
val wifi = WifiConfiguration()
|
||||||
|
wifi.SSID = """"$SSID""""
|
||||||
|
wifi.allowedKeyManagement.set(WifiConfiguration.KeyMgmt.WPA_EAP)
|
||||||
|
wifi.allowedKeyManagement.set(WifiConfiguration.KeyMgmt.IEEE8021X)
|
||||||
|
wifi.enterpriseConfig = enterpriseConfig()
|
||||||
|
wifi.networkId = ssidToNetworkId(wifi.SSID, wifiManager)
|
||||||
|
if (wifi.networkId == -1) {
|
||||||
|
wifiManager.addNetwork(wifi)
|
||||||
|
} else {
|
||||||
|
Log.v(TAG, "WiFi found - updating it.\n")
|
||||||
|
wifiManager.updateNetwork(wifi)
|
||||||
|
}
|
||||||
|
Log.v(TAG, "saving config.\n")
|
||||||
|
wifiManager.saveConfiguration()
|
||||||
|
wifi.networkId = ssidToNetworkId(wifi.SSID, wifiManager)
|
||||||
|
|
||||||
|
Log.v(TAG, "wifi ID in device = " + wifi.networkId)
|
||||||
|
|
||||||
|
var supState: SupplicantState
|
||||||
|
val networkIdToConnect = wifi.networkId
|
||||||
|
if (networkIdToConnect >= 0) {
|
||||||
|
Log.v(TAG, "Start connecting...\n")
|
||||||
|
|
||||||
|
// We disable the network before connecting, because if this was the last connection before
|
||||||
|
// a disconnect(), this will not reconnect.
|
||||||
|
wifiManager.disableNetwork(networkIdToConnect)
|
||||||
|
wifiManager.enableNetwork(networkIdToConnect, true)
|
||||||
|
|
||||||
|
val wifiInfo: WifiInfo = wifiManager.connectionInfo
|
||||||
|
|
||||||
|
HMGUtils.timer(5000,false){
|
||||||
|
supState = wifiInfo.supplicantState
|
||||||
|
Log.i(TAG, "Done connect to network : status = $supState")
|
||||||
|
val successStates = listOf(COMPLETED, ASSOCIATED)
|
||||||
|
if (successStates.contains(supState))
|
||||||
|
completion(true,"Connected to internet Wifi")
|
||||||
|
else
|
||||||
|
completion(false,"errorConnectingHmgNetwork")
|
||||||
|
}
|
||||||
|
|
||||||
|
} else {
|
||||||
|
Log.v(TAG, "WifiWizard: cannot connect to network")
|
||||||
|
completion(false,"errorConnectingHmgNetwork")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This method takes a given String, searches the current list of configured WiFi
|
||||||
|
* networks, and returns the networkId for the network if the SSID matches. If not,
|
||||||
|
* it returns -1.
|
||||||
|
*/
|
||||||
|
@SuppressLint("MissingPermission")
|
||||||
|
private fun ssidToNetworkId(ssid: String, wifiManager: WifiManager): Int {
|
||||||
|
val currentNetworks = wifiManager.configuredNetworks
|
||||||
|
var networkId = -1
|
||||||
|
// For each network in the list, compare the SSID with the given one
|
||||||
|
for (test in currentNetworks) {
|
||||||
|
if (test.SSID == ssid) {
|
||||||
|
networkId = test.networkId
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return networkId
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@RequiresApi(Build.VERSION_CODES.Q)
|
||||||
|
fun apiGreaterThen28(){
|
||||||
|
val connectivityManager = mainActivity.applicationContext.getSystemService(Context.CONNECTIVITY_SERVICE) as ConnectivityManager
|
||||||
|
|
||||||
|
Log.e(TAG, "connection wifi with Android Q+")
|
||||||
|
val wifiNetworkSpecifier: WifiNetworkSpecifier = WifiNetworkSpecifier.Builder()
|
||||||
|
.setWpa2EnterpriseConfig(enterpriseConfig())
|
||||||
|
.build()
|
||||||
|
|
||||||
|
val networkRequest: NetworkRequest = NetworkRequest.Builder()
|
||||||
|
.addTransportType(NetworkCapabilities.TRANSPORT_WIFI)
|
||||||
|
.setNetworkSpecifier(wifiNetworkSpecifier)
|
||||||
|
.removeCapability(NetworkCapabilities.NET_CAPABILITY_INTERNET) //removeCapability added for hotspots without internet
|
||||||
|
.build()
|
||||||
|
|
||||||
|
val networkCallback = object : ConnectivityManager.NetworkCallback() {
|
||||||
|
override fun onAvailable(network: Network) {
|
||||||
|
super.onAvailable(network)
|
||||||
|
connectivityManager.bindProcessToNetwork(network)
|
||||||
|
Log.e(TAG, "onAvailable")
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onLosing(network: Network, maxMsToLive: Int) {
|
||||||
|
super.onLosing(network, maxMsToLive)
|
||||||
|
Log.e(TAG, "onLosing")
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onLost(network: Network) {
|
||||||
|
super.onLost(network)
|
||||||
|
Log.e(TAG, "onLosing")
|
||||||
|
Log.e(TAG, "losing active connection")
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onUnavailable() {
|
||||||
|
super.onUnavailable()
|
||||||
|
Log.e(TAG, "onUnavailable")
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
//timeout add because "No devices found" wasn't handled correct and doesn't throw Unavailable
|
||||||
|
connectivityManager.requestNetwork(networkRequest, networkCallback, 30000)
|
||||||
|
}
|
||||||
|
|
||||||
|
fun enterpriseConfig() : WifiEnterpriseConfig{
|
||||||
|
// Initialize the WifiConfiguration object
|
||||||
|
val enterpriseConfig = WifiEnterpriseConfig()
|
||||||
|
enterpriseConfig.eapMethod = WifiEnterpriseConfig.Eap.PEAP
|
||||||
|
enterpriseConfig.identity = identity
|
||||||
|
enterpriseConfig.password = password
|
||||||
|
return enterpriseConfig;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@ -1,3 +1,6 @@
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
<svg xmlns="http://www.w3.org/2000/svg" width="61.183" height="61.227" viewBox="0 0 61.183 61.227">
|
<svg xmlns="http://www.w3.org/2000/svg" width="61.183" height="61.227" viewBox="0 0 61.183 61.227">
|
||||||
<path id="Path_4645" data-name="Path 4645" d="M240.521,51.17s2.141-.016,3.648-.016l11.428.056c1.364,0,2.5-1.45,2.564-3.545l.013-9.549c0-2.036.91-3.629,2.321-3.72L264,34.368c1.413.087,2.383,1.7,2.383,3.723l-.009,9.6c.062,2.094,1.014,3.461,2.385,3.461l15.384.042.028-11.8c0-2.03-.976-3.607-2.4-3.7l-6.18-.031c-1.367,0-2.442-1.443-2.5-3.54l-.024-3.192c.068-2.094,1.149-3.534,2.519-3.534l6.214.018c1.412-.091,2.332-1.758,2.332-3.785L284.147,6.9a6.275,6.275,0,0,1-4.76,2.976l-10.45-.009c-1.361,0-2.5,1.484-2.564,3.578v9.459c-.064,2.09-1.133,3.569-2.5,3.569l-3.162-.024c-1.371,0-2.467-1.431-2.529-3.515l.008-9.563c-.062-2.095-1.148-3.5-2.516-3.5l-15.165.007,0,11.764c0,2.032.949,3.659,2.365,3.753l6.214-.026c1.405.092,2.4,1.768,2.4,3.789l-.019,2.723c0,2.031-.96,3.656-2.372,3.748l-6.224-.015c-1.416.1-2.365,1.7-2.365,3.731Zm52.241-45.1v49.2a6.256,6.256,0,0,1-6.325,5.951H237.873a6.231,6.231,0,0,1-6.294-5.958l0-49.295A6.253,6.253,0,0,1,237.883,0L286.4.021a6.371,6.371,0,0,1,6.36,6.053" transform="translate(-231.579)" fill="#ec1c2b"/>
|
<path id="Path_4645" data-name="Path 4645" d="M240.521,51.17s2.141-.016,3.648-.016l11.428.056c1.364,0,2.5-1.45,2.564-3.545l.013-9.549c0-2.036.91-3.629,2.321-3.72L264,34.368c1.413.087,2.383,1.7,2.383,3.723l-.009,9.6c.062,2.094,1.014,3.461,2.385,3.461l15.384.042.028-11.8c0-2.03-.976-3.607-2.4-3.7l-6.18-.031c-1.367,0-2.442-1.443-2.5-3.54l-.024-3.192c.068-2.094,1.149-3.534,2.519-3.534l6.214.018c1.412-.091,2.332-1.758,2.332-3.785L284.147,6.9a6.275,6.275,0,0,1-4.76,2.976l-10.45-.009c-1.361,0-2.5,1.484-2.564,3.578v9.459c-.064,2.09-1.133,3.569-2.5,3.569l-3.162-.024c-1.371,0-2.467-1.431-2.529-3.515l.008-9.563c-.062-2.095-1.148-3.5-2.516-3.5l-15.165.007,0,11.764c0,2.032.949,3.659,2.365,3.753l6.214-.026c1.405.092,2.4,1.768,2.4,3.789l-.019,2.723c0,2.031-.96,3.656-2.372,3.748l-6.224-.015c-1.416.1-2.365,1.7-2.365,3.731Zm52.241-45.1v49.2a6.256,6.256,0,0,1-6.325,5.951H237.873a6.231,6.231,0,0,1-6.294-5.958l0-49.295A6.253,6.253,0,0,1,237.883,0L286.4.021a6.371,6.371,0,0,1,6.36,6.053" transform="translate(-231.579)" fill="#ec1c2b"/>
|
||||||
</svg>
|
</svg>
|
||||||
|
|||||||
|
Before Width: | Height: | Size: 1.1 KiB After Width: | Height: | Size: 1.1 KiB |
@ -0,0 +1,86 @@
|
|||||||
|
import 'package:diplomaticquarterapp/core/model/ImagesInfo.dart';
|
||||||
|
import 'package:diplomaticquarterapp/core/viewModels/project_view_model.dart';
|
||||||
|
import 'package:diplomaticquarterapp/models/Authentication/authenticated_user.dart';
|
||||||
|
import 'package:diplomaticquarterapp/pages/base/base_view.dart';
|
||||||
|
import 'package:diplomaticquarterapp/pages/packages_offers/OfferAndPackagesPage.dart';
|
||||||
|
import 'package:diplomaticquarterapp/pages/packages_offers/packages_orders_history.dart';
|
||||||
|
import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart';
|
||||||
|
import 'package:diplomaticquarterapp/widgets/others/app_scaffold_widget.dart';
|
||||||
|
import 'package:flutter/cupertino.dart';
|
||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:provider/provider.dart';
|
||||||
|
|
||||||
|
class PackagesOfferTabPage extends StatefulWidget{
|
||||||
|
|
||||||
|
AuthenticatedUser user;
|
||||||
|
PackagesOfferTabPage(this.user);
|
||||||
|
|
||||||
|
@override
|
||||||
|
State<StatefulWidget> createState() => PackagesOfferTabPageState();
|
||||||
|
}
|
||||||
|
|
||||||
|
class PackagesOfferTabPageState extends State<PackagesOfferTabPage> with SingleTickerProviderStateMixin{
|
||||||
|
TabController _tabController;
|
||||||
|
ProjectViewModel _projectViewModel;
|
||||||
|
|
||||||
|
@override
|
||||||
|
void initState() {
|
||||||
|
_tabController = TabController(length: 2, vsync: this);
|
||||||
|
super.initState();
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
_projectViewModel = Provider.of(context);
|
||||||
|
return AppScaffold(
|
||||||
|
description: TranslationBase.of(context).offerAndPackagesDetails,
|
||||||
|
imagesInfo: [ImagesInfo(imageAr: 'https://hmgwebservices.com/Images/MobileApp/CMC/ar/0.png', imageEn: 'https://hmgwebservices.com/Images/MobileApp/CMC/en/0.png')],
|
||||||
|
appBarTitle: TranslationBase.of(context).offerAndPackages,
|
||||||
|
isShowAppBar: true,
|
||||||
|
isPharmacy: false,
|
||||||
|
backgroundColor: Color(0xfff7f7f7),
|
||||||
|
showPharmacyCart: false,
|
||||||
|
isOfferPackages: true,
|
||||||
|
showOfferPackagesCart: false,
|
||||||
|
isShowDecPage: false,
|
||||||
|
showNewAppBar: true,
|
||||||
|
showNewAppBarTitle: true,
|
||||||
|
body: Column(
|
||||||
|
children: <Widget>[
|
||||||
|
TabBar(
|
||||||
|
controller: _tabController,
|
||||||
|
indicatorWeight: 3.0,
|
||||||
|
indicatorSize: TabBarIndicatorSize.tab,
|
||||||
|
labelColor: Color(0xff2B353E),
|
||||||
|
unselectedLabelColor: Color(0xff575757),
|
||||||
|
labelPadding: EdgeInsets.only(top: 15, bottom: 13, left: 20, right: 20),
|
||||||
|
labelStyle: TextStyle(
|
||||||
|
fontFamily: _projectViewModel.isArabic ? 'Cairo' : 'Poppins',
|
||||||
|
fontSize: 16,
|
||||||
|
fontWeight: FontWeight.w600,
|
||||||
|
letterSpacing: -0.48,
|
||||||
|
),
|
||||||
|
unselectedLabelStyle: TextStyle(
|
||||||
|
fontFamily: _projectViewModel.isArabic ? 'Cairo' : 'Poppins',
|
||||||
|
fontSize: 16,
|
||||||
|
fontWeight: FontWeight.w600,
|
||||||
|
letterSpacing: -0.48,
|
||||||
|
),
|
||||||
|
tabs: [Text(TranslationBase.of(context).offerAndPackages), Text(TranslationBase.of(context).orderLog)],
|
||||||
|
),
|
||||||
|
Expanded(
|
||||||
|
child: TabBarView(
|
||||||
|
physics: BouncingScrollPhysics(),
|
||||||
|
controller: _tabController,
|
||||||
|
children: <Widget>[
|
||||||
|
PackagesHomePage(widget.user),
|
||||||
|
PackagesOrdersHistory()
|
||||||
|
],
|
||||||
|
),
|
||||||
|
)
|
||||||
|
],
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,98 @@
|
|||||||
|
import 'package:diplomaticquarterapp/core/model/packages_offers/responses/PackagesCartItemsResponseModel.dart';
|
||||||
|
import 'package:diplomaticquarterapp/core/model/packages_offers/responses/PackagesResponseModel.dart';
|
||||||
|
import 'package:diplomaticquarterapp/core/viewModels/packages_offers/PackagesOffersViewModel.dart';
|
||||||
|
import 'package:diplomaticquarterapp/core/viewModels/project_view_model.dart';
|
||||||
|
import 'package:diplomaticquarterapp/pages/base/base_view.dart';
|
||||||
|
import 'package:diplomaticquarterapp/uitl/date_uitl.dart';
|
||||||
|
import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart';
|
||||||
|
import 'package:diplomaticquarterapp/uitl/utils_new.dart';
|
||||||
|
import 'package:diplomaticquarterapp/widgets/Loader/gif_loader_container.dart';
|
||||||
|
import 'package:diplomaticquarterapp/widgets/dialogs/ConfirmWithMessageDialog.dart';
|
||||||
|
import 'package:diplomaticquarterapp/widgets/offers_packages/PackagesOrderHistoryItemCard.dart';
|
||||||
|
import 'package:diplomaticquarterapp/widgets/others/app_scaffold_widget.dart';
|
||||||
|
import 'package:flutter/cupertino.dart';
|
||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:provider/provider.dart';
|
||||||
|
|
||||||
|
import 'OfferAndPackageDetailPage.dart';
|
||||||
|
class PackagesOrdersHistory extends StatefulWidget{
|
||||||
|
@override
|
||||||
|
State<StatefulWidget> createState() => PackagesOrdersHistorySatate();
|
||||||
|
}
|
||||||
|
|
||||||
|
class PackagesOrdersHistorySatate extends State<PackagesOrdersHistory>{
|
||||||
|
ProjectViewModel projectViewModel;
|
||||||
|
PackagesViewModel packagesViewModel;
|
||||||
|
|
||||||
|
List<PackagesResponseModel> orders;
|
||||||
|
|
||||||
|
@override
|
||||||
|
void initState() {
|
||||||
|
Future.delayed(Duration(milliseconds: 200)).then((value) async{
|
||||||
|
final orders_ = await packagesViewModel.service.orderHistory(context: context);
|
||||||
|
setState(() => orders = orders_ ?? []);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
projectViewModel = Provider.of(context);
|
||||||
|
return BaseView<PackagesViewModel>(
|
||||||
|
allowAny: true,
|
||||||
|
onModelReady: (model) => packagesViewModel = model,
|
||||||
|
builder: (_, model, wi) {
|
||||||
|
return content(context);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
Widget content(BuildContext context){
|
||||||
|
if(orders == null){
|
||||||
|
return SizedBox();
|
||||||
|
}else if(orders.isEmpty){
|
||||||
|
return getNoDataWidget(context);
|
||||||
|
}else {
|
||||||
|
return ListView.separated(
|
||||||
|
padding: EdgeInsets.all(20),
|
||||||
|
itemCount: orders.length,
|
||||||
|
itemBuilder: (ctx, idx) => item(ctx, order: orders[idx]),
|
||||||
|
separatorBuilder: (ctx, idx) => SizedBox(height: 10),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Widget item(BuildContext context, {@required PackagesResponseModel order}){
|
||||||
|
return InkWell(
|
||||||
|
child: PackagesOrderHistoryItemCard(itemModel: order, viewModel: packagesViewModel),
|
||||||
|
onTap: (){
|
||||||
|
final detailPage = OfferAndPackagesDetail(itemModel: order, onCartClick: null)..showAddToCartFooter = false;
|
||||||
|
Navigator.of(context).push(MaterialPageRoute(builder: (BuildContext context) => detailPage));
|
||||||
|
},
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
void showConfirmMessage(BuildContext context, {@required PackagesResponseModel order}){
|
||||||
|
showDialog(
|
||||||
|
context: context,
|
||||||
|
builder: (cxt) => ConfirmWithMessageDialog(
|
||||||
|
message: TranslationBase.of(context).cancelOrderMsg,
|
||||||
|
onTap: () {
|
||||||
|
},
|
||||||
|
),
|
||||||
|
);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
Color color(int status){
|
||||||
|
if (status == 1) { //pending
|
||||||
|
return Color(0xffCC9B14);
|
||||||
|
} else if (status == 2) { //processing
|
||||||
|
return Color(0xff2E303A);
|
||||||
|
} else if (status == 3) { //completed
|
||||||
|
return Color(0xff359846);
|
||||||
|
} else if (status == 4 || status == 6 || status == 7) { //cancel // Rejected
|
||||||
|
return Color(0xffD02127);
|
||||||
|
}
|
||||||
|
return Colors.transparent;
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,124 @@
|
|||||||
|
import 'package:diplomaticquarterapp/core/model/packages_offers/responses/PackagesCartItemsResponseModel.dart';
|
||||||
|
import 'package:diplomaticquarterapp/core/model/packages_offers/responses/PackagesResponseModel.dart';
|
||||||
|
import 'package:diplomaticquarterapp/core/viewModels/packages_offers/PackagesOffersViewModel.dart';
|
||||||
|
import 'package:diplomaticquarterapp/theme/colors.dart';
|
||||||
|
import 'package:diplomaticquarterapp/uitl/translations_delegate_base.dart';
|
||||||
|
import 'package:diplomaticquarterapp/uitl/utils.dart';
|
||||||
|
import 'package:diplomaticquarterapp/uitl/utils_new.dart';
|
||||||
|
import 'package:diplomaticquarterapp/widgets/CounterView.dart';
|
||||||
|
import 'package:flutter/cupertino.dart';
|
||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:flutter_svg/flutter_svg.dart';
|
||||||
|
|
||||||
|
bool wide = true;
|
||||||
|
|
||||||
|
class PackagesOrderHistoryItemCard extends StatefulWidget {
|
||||||
|
final PackagesResponseModel itemModel;
|
||||||
|
final PackagesViewModel viewModel;
|
||||||
|
final Function getCartItems;
|
||||||
|
|
||||||
|
const PackagesOrderHistoryItemCard({@required this.itemModel, @required this.viewModel, this.getCartItems, Key key}) : super(key: key);
|
||||||
|
|
||||||
|
@override
|
||||||
|
State<StatefulWidget> createState() => PackagesOrderHistoryItemCardState();
|
||||||
|
}
|
||||||
|
|
||||||
|
class PackagesOrderHistoryItemCardState extends State<PackagesOrderHistoryItemCard> {
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
wide = !wide;
|
||||||
|
return Container(
|
||||||
|
decoration: cardRadius(15.0),
|
||||||
|
height: 95,
|
||||||
|
padding: EdgeInsets.all(9),
|
||||||
|
child: Row(
|
||||||
|
mainAxisSize: MainAxisSize.max,
|
||||||
|
children: [
|
||||||
|
_image(widget.itemModel),
|
||||||
|
SizedBox(width: 7),
|
||||||
|
Expanded(
|
||||||
|
child: Column(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
children: [
|
||||||
|
_itemName(widget.itemModel.name),
|
||||||
|
Expanded(child: _itemDescription(widget.itemModel.shortDescription)),
|
||||||
|
Row(
|
||||||
|
mainAxisSize: MainAxisSize.max,
|
||||||
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||||
|
children: [
|
||||||
|
_itemPrice(widget.itemModel.price, context: context),
|
||||||
|
_cancelButton(context, itemModel: widget.itemModel)
|
||||||
|
],
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
)
|
||||||
|
],
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Widget _cancelButton(BuildContext context, {@required PackagesResponseModel itemModel, VoidCallback onClick}) => InkWell(
|
||||||
|
onTap:onClick,
|
||||||
|
child: Padding(
|
||||||
|
padding: const EdgeInsets.only(right: 3, bottom: 3),
|
||||||
|
child: Row(
|
||||||
|
mainAxisSize: MainAxisSize.min,
|
||||||
|
children: [
|
||||||
|
// Text(
|
||||||
|
// TranslationBase.of(context).removeMember,
|
||||||
|
// style: TextStyle(
|
||||||
|
// fontSize: 10,
|
||||||
|
// color: CustomColors.accentColor,
|
||||||
|
// fontWeight: FontWeight.w600,
|
||||||
|
// letterSpacing: -0.36,
|
||||||
|
// ),
|
||||||
|
// ),
|
||||||
|
// SizedBox(width: 2),
|
||||||
|
// SvgPicture.asset("assets/images/new-design/delete.svg", color: CustomColors.accentColor),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
|
||||||
|
Widget _image(PackagesResponseModel model) => AspectRatio(
|
||||||
|
aspectRatio: 1 / 1,
|
||||||
|
child: ClipRRect(
|
||||||
|
borderRadius: BorderRadius.circular(15), child: ((model.images ?? []).isNotEmpty) ? Utils.loadNetworkImage(url: model.images.first.src, fitting: BoxFit.fill) : Container(color: Colors.grey[200])),
|
||||||
|
);
|
||||||
|
|
||||||
|
Widget _itemName(String name) => Text(
|
||||||
|
name,
|
||||||
|
style: TextStyle(
|
||||||
|
fontSize: 14,
|
||||||
|
fontWeight: FontWeight.bold,
|
||||||
|
color: Color(0xff2B353E),
|
||||||
|
letterSpacing: -0.56,
|
||||||
|
),
|
||||||
|
);
|
||||||
|
|
||||||
|
Widget _itemDescription(String desc) => Text(
|
||||||
|
desc,
|
||||||
|
maxLines: 2,
|
||||||
|
overflow: TextOverflow.ellipsis,
|
||||||
|
style: TextStyle(
|
||||||
|
fontSize: 10,
|
||||||
|
fontWeight: FontWeight.w500,
|
||||||
|
color: Color(0xff535353),
|
||||||
|
letterSpacing: -0.4,
|
||||||
|
),
|
||||||
|
);
|
||||||
|
|
||||||
|
Widget _itemPrice(double price, {@required BuildContext context}) {
|
||||||
|
final prc = (price ?? 0.0).toStringAsFixed(2);
|
||||||
|
return Text(
|
||||||
|
'$prc ${TranslationBase.of(context).sar}',
|
||||||
|
style: TextStyle(
|
||||||
|
fontSize: 11,
|
||||||
|
fontWeight: FontWeight.w600,
|
||||||
|
color: Color(0xff5D5D5D),
|
||||||
|
letterSpacing: -0.44,
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue