adding category slider
This commit is contained in:
@@ -536,6 +536,57 @@ class _PosSaleScreenState extends ConsumerState<PosSaleScreen> {
|
||||
],
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
categoryData.when(
|
||||
data: (data) {
|
||||
return SizedBox(
|
||||
height: 50,
|
||||
child: ListView.builder(
|
||||
itemCount: data.length + 1,
|
||||
scrollDirection: Axis.horizontal,
|
||||
itemBuilder: (context, index) {
|
||||
return GestureDetector(
|
||||
onTap: () {
|
||||
setState(() {
|
||||
selectedCategory = index == 0 ? null : data[index - 1];
|
||||
_applyFilters();
|
||||
});
|
||||
},
|
||||
child: Container(
|
||||
margin: EdgeInsets.only(left: index == 0 ? 0 : 8),
|
||||
decoration: BoxDecoration(
|
||||
borderRadius: BorderRadius.circular(5.0),
|
||||
color: (index == 0 && selectedCategory == null) ||
|
||||
(index != 0 && selectedCategory?.id == data[index - 1].id)
|
||||
? kMainColor
|
||||
: kMainColor.withOpacity(0.1),
|
||||
),
|
||||
padding: const EdgeInsets.all(10),
|
||||
child: Center(
|
||||
child: Text(
|
||||
index == 0 ? lang.S.of(context).all : data[index - 1].categoryName ?? '',
|
||||
style: TextStyle(
|
||||
fontSize: 14,
|
||||
color: (index == 0 && selectedCategory == null) ||
|
||||
(index != 0 && selectedCategory?.id == data[index - 1].id)
|
||||
? Colors.white
|
||||
: kMainColor,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
);
|
||||
},
|
||||
error: (Object error, StackTrace stackTrace) {
|
||||
return Text(error.toString());
|
||||
},
|
||||
loading: () {
|
||||
return const Center(child: CircularProgressIndicator());
|
||||
},
|
||||
),
|
||||
const SizedBox(height: 16),
|
||||
if (filteredProducts.isEmpty)
|
||||
Text(lang.S.of(context).noMatched, style: _theme.textTheme.bodyMedium)
|
||||
else
|
||||
|
||||
Reference in New Issue
Block a user