update setting tab or hp
This commit is contained in:
@@ -6,6 +6,7 @@ import 'package:flutter_svg/flutter_svg.dart';
|
||||
import 'package:flutter_typeahead/flutter_typeahead.dart';
|
||||
import 'package:mobile_pos/constant.dart';
|
||||
import 'package:mobile_pos/currency.dart';
|
||||
import 'package:shared_preferences/shared_preferences.dart';
|
||||
|
||||
import '../../Const/api_config.dart';
|
||||
import '../../GlobalComponents/bar_code_scaner_widget.dart';
|
||||
@@ -41,6 +42,7 @@ class PosSaleScreen extends ConsumerStatefulWidget {
|
||||
|
||||
class _PosSaleScreenState extends ConsumerState<PosSaleScreen> {
|
||||
final productController = TextEditingController();
|
||||
bool isTab = true;
|
||||
List<Product> filteredProducts = [];
|
||||
Party? selectedCustomer;
|
||||
CategoryModel? selectedCategory;
|
||||
@@ -63,6 +65,7 @@ class _PosSaleScreenState extends ConsumerState<PosSaleScreen> {
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
_loadState();
|
||||
ref.refresh(cartNotifier);
|
||||
filteredProducts = ref.read(productProvider).value ?? [];
|
||||
productController.addListener(_applyFilters);
|
||||
@@ -147,6 +150,13 @@ class _PosSaleScreenState extends ConsumerState<PosSaleScreen> {
|
||||
});
|
||||
}
|
||||
|
||||
Future<void> _loadState() async {
|
||||
final prefs = await SharedPreferences.getInstance();
|
||||
setState(() {
|
||||
isTab = prefs.getBool('isTab') ?? true;
|
||||
});
|
||||
}
|
||||
|
||||
final TextEditingController _searchController = TextEditingController();
|
||||
bool _hasInitializedFilters = false;
|
||||
|
||||
@@ -163,6 +173,111 @@ class _PosSaleScreenState extends ConsumerState<PosSaleScreen> {
|
||||
appBar: AppBar(
|
||||
title: Text(lang.S.of(context).posSale),
|
||||
centerTitle: true,
|
||||
actions: [
|
||||
Row(
|
||||
children: [
|
||||
Text(
|
||||
'Tab',
|
||||
style: TextStyle(
|
||||
color: isTab ? kMainColor : kSubPeraColor,
|
||||
fontWeight: FontWeight.bold,
|
||||
fontSize: 16,
|
||||
),
|
||||
),
|
||||
Switch(
|
||||
value: !isTab,
|
||||
activeColor: kMainColor,
|
||||
onChanged: (value) async {
|
||||
setState(() {
|
||||
isTab = !value;
|
||||
});
|
||||
final prefs = await SharedPreferences.getInstance();
|
||||
await prefs.setBool('isTab', isTab);
|
||||
},
|
||||
),
|
||||
Text(
|
||||
'HP',
|
||||
style: TextStyle(
|
||||
color: !isTab ? kMainColor : kSubPeraColor,
|
||||
fontWeight: FontWeight.bold,
|
||||
fontSize: 16,
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 16),
|
||||
],
|
||||
)
|
||||
],
|
||||
),
|
||||
bottomNavigationBar: isTab
|
||||
? null
|
||||
: Container(
|
||||
padding: const EdgeInsets.all(16),
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.white,
|
||||
boxShadow: [
|
||||
BoxShadow(
|
||||
color: Colors.black.withOpacity(0.05),
|
||||
spreadRadius: 1,
|
||||
blurRadius: 5,
|
||||
offset: const Offset(0, -3),
|
||||
),
|
||||
],
|
||||
),
|
||||
child: ElevatedButton(
|
||||
style: ElevatedButton.styleFrom(
|
||||
backgroundColor: kMainColor,
|
||||
padding: const EdgeInsets.symmetric(vertical: 12),
|
||||
),
|
||||
onPressed: providerData.cartItemList.isEmpty
|
||||
? null
|
||||
: () async {
|
||||
if (!permissionService.hasPermission(Permit.saleReturnsRead.value)) {
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
SnackBar(
|
||||
backgroundColor: kMainColor,
|
||||
content: Text(lang.S.of(context).inventoryPermission),
|
||||
),
|
||||
);
|
||||
return;
|
||||
}
|
||||
bool branchResult = await checkActionWhenNoBranch(context: context, ref: ref);
|
||||
if (!branchResult) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Navigate to the next screen if permission is granted
|
||||
bool result = await Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(
|
||||
builder: (context) => AddSalesScreen(
|
||||
customerModel: selectedCustomer,
|
||||
isFromPos: true,
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
// Handle result after returning from AddSalesScreen
|
||||
if (result) {
|
||||
_searchController.clear();
|
||||
selectedCustomer = null;
|
||||
setState(() {});
|
||||
}
|
||||
},
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
const Text(
|
||||
'Continue',
|
||||
style: TextStyle(color: Colors.white, fontSize: 16),
|
||||
),
|
||||
const SizedBox(width: 8),
|
||||
Text(
|
||||
'(${providerData.cartItemList.length} Items): $currency${providerData.getTotalAmount()}',
|
||||
style: const TextStyle(color: Colors.white, fontSize: 14),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
body: Row(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
@@ -866,8 +981,12 @@ class _PosSaleScreenState extends ConsumerState<PosSaleScreen> {
|
||||
),
|
||||
),
|
||||
),
|
||||
if (isTab)
|
||||
Expanded(
|
||||
flex: 1,
|
||||
child: Column(
|
||||
children: [
|
||||
Expanded(
|
||||
child: Container(
|
||||
margin: const EdgeInsets.all(16),
|
||||
decoration: BoxDecoration(
|
||||
@@ -1149,6 +1268,9 @@ class _PosSaleScreenState extends ConsumerState<PosSaleScreen> {
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user