Skip to content

Commit

Permalink
UI Fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
AkshithaReddy1899 committed Dec 17, 2023
1 parent d83fe46 commit 4628a1a
Show file tree
Hide file tree
Showing 11 changed files with 155 additions and 150 deletions.
217 changes: 105 additions & 112 deletions lib/common/app_constants.dart
Original file line number Diff line number Diff line change
Expand Up @@ -209,23 +209,44 @@ class AppConstant {
);
}

showAlert(context, title, content, buttonText, [buttonYes, onpressed]) {
showAlert(context, isDark, title, content, buttonText,
[buttonYes, onpressed]) {
return showDialog(
context: context,
builder: (BuildContext context) {
return AlertDialog(
title: Text(title),
content: Text(content),
backgroundColor: isDark ? AppConstant.darkBg1 : AppConstant.lightBg1,
iconColor: isDark ? AppConstant.darkAccent : AppConstant.lightAccent,
title: Text(
title,
style: TextStyle(
color:
isDark ? AppConstant.darkAccent : AppConstant.lightAccent),
),
content: Text(
content,
style: TextStyle(
color:
isDark ? AppConstant.darkAccent : AppConstant.lightAccent),
),
actions: <Widget>[
TextButton(
onPressed: () {
Navigator.of(context).pop();
},
child: Text(buttonText),
child: Text(
buttonText,
style: const TextStyle(
color: Color.fromARGB(255, 219, 114, 106),
),
),
),
TextButton(
onPressed: onpressed,
child: Text(buttonYes),
child: Text(
buttonYes,
style: const TextStyle(color: Colors.green),
),
),
],
);
Expand All @@ -252,7 +273,7 @@ class AppConstant {
minHeight: 100,
minWidth: double.infinity,
),
margin: const EdgeInsets.all(20),
margin: const EdgeInsets.all(10),
padding: const EdgeInsets.all(10),
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(10),
Expand All @@ -277,7 +298,7 @@ class AppConstant {
height: 5,
),
Column(
mainAxisAlignment: MainAxisAlignment.center,
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Row(
Expand All @@ -304,123 +325,95 @@ class AppConstant {
),
Row(
children: [
Visibility(
visible: status == 'Placed',
child: elevatedButton(isDark, acceptOrder, 'Accept order'),
),
Visibility(
visible: status == 'Accepted',
child: elevatedButton(isDark, servedOrder, 'Ready to serve'),
),
elevatedButton(
isDark,
status == 'Placed' ? acceptOrder : servedOrder,
status == 'Placed' ? 'Accept order' : 'Served'),
],
)
],
),
);
}

ordersList(isDark, List<Orders> orders, index, visible) {
return Container(
constraints: const BoxConstraints(
minHeight: 100,
minWidth: double.infinity,
),
margin: const EdgeInsets.all(20),
padding: const EdgeInsets.all(5),
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(10),
color: isDark ? AppConstant.darkBg1 : AppConstant.lightBg1,
),
child: Column(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
ordersList(isDark, List<Orders> orders, visible) {
List<Param> pastOrders = [];
for (var i = 0; i < orders.length; i++) {
for (var j = 0; j < orders[i].items!.length; j++) {
if (orders[i].items![j].orderStatus == 'Served') {
pastOrders.add(orders[i].items![j]);
}
}
}
return ListView.builder(
shrinkWrap: true,
itemCount: pastOrders.length,
itemBuilder: (context, i) {
return Container(
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(10),
color: isDark ? AppConstant.darkBg1 : AppConstant.lightBg1),
margin: const EdgeInsets.all(20),
padding: const EdgeInsets.all(10),
child: Column(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
'Order id: ${orders[index].ordersId}',
style: TextStyle(
fontSize: 12,
color: isDark
? AppConstant.darkAccent
: AppConstant.lightAccent),
),
Text(
'DateTime: ${orders[index].dateTime}',
style: TextStyle(
fontSize: 12,
color: isDark
? AppConstant.darkAccent
: AppConstant.lightAccent),
),
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Text(
'Order id: ${pastOrders[i].ordersId}',
style: TextStyle(
fontSize: 12,
color: isDark
? AppConstant.darkAccent
: AppConstant.lightAccent),
),
Text(
'DateTime: 1700118350667',
style: TextStyle(
fontSize: 12,
color: isDark
? AppConstant.darkAccent
: AppConstant.lightAccent),
),
const SizedBox(
height: 10,
),
Column(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
pastOrders[i].name.toString(),
style: TextStyle(
fontWeight: FontWeight.bold,
color: isDark
? AppConstant.darkSecondary
: AppConstant.lightAccent),
),
const SizedBox(
height: 2,
),
Text(
'Portions: ${pastOrders[i].quantity}',
style: TextStyle(
fontSize: 10,
color: isDark
? AppConstant.darkSecondary
: AppConstant.lightAccent),
),
],
)
],
)
],
),
const SizedBox(
height: 5,
),
ListView.builder(
shrinkWrap: true,
itemCount: orders[index].items!.length,
itemBuilder: (context, i) {
return Padding(
padding: const EdgeInsets.all(10),
child: Column(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
orders[index].items![i].name.toString(),
style: TextStyle(
fontWeight: FontWeight.bold,
color: isDark
? AppConstant.darkSecondary
: AppConstant.lightAccent),
),
const SizedBox(
height: 2,
),
Text(
'Portions: ${orders[index].items![i].quantity}',
style: TextStyle(
fontSize: 10,
color: isDark
? AppConstant.darkSecondary
: AppConstant.lightAccent),
),
],
),
);
},
),
Visibility(
visible: visible,
child:
AppConstant().elevatedButton(isDark, () {}, 'Generate QR code'),
),
],
),
);
},
);
}

// REMOVE after implementing loading animation in past orders
// loading(Size screenSize) {
// return SizedBox(
// width: screenSize.width,
// height: screenSize.height / 2,
// child: Column(
// mainAxisAlignment: MainAxisAlignment.center,
// crossAxisAlignment: CrossAxisAlignment.center,
// children: [
// LoadingAnimationWidget.beat(
// color: AppConstant.darkBg,
// size: screenSize.width / 6,
// ),
// ],
// ),
// );
// }

loadingShimmer(isDark) {
return SizedBox(
child: Shimmer.fromColors(
Expand Down
6 changes: 4 additions & 2 deletions lib/common/components/menu.dart
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,7 @@ class _MenuCardState extends ConsumerState<MenuCard> {
if (!context.mounted) return;
AppConstant().showAlert(
context,
isDark,
'Error',
"There was an error while ${bisUpdate ? "updating" : "adding"} the category, Please try again later :(",
"OK");
Expand All @@ -244,6 +245,7 @@ class _MenuCardState extends ConsumerState<MenuCard> {
AppConstant().elevatedButton(isDark, () async {
AppConstant().showAlert(
context,
isDark,
'Are you sure?',
"This action can't be undone",
'No',
Expand Down Expand Up @@ -453,15 +455,15 @@ class _MenuCardState extends ConsumerState<MenuCard> {
.lightAccent,
),
AppConstant().commonText(
"\$${product.price}",
"${product.price}",
20.0,
FontWeight.w400,
kIsWeb
? themeProvider.darkMode
? AppConstant
.darkSecondary
: AppConstant
.lightPrimary
.lightAccent
: themeProvider.darkMode
? AppConstant
.darkSecondary
Expand Down
1 change: 1 addition & 0 deletions lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ class _HomeState extends ConsumerState<Home> {
return MaterialApp(
localizationsDelegates: AppLocalizations.localizationsDelegates,
supportedLocales: L10n.all,
debugShowCheckedModeBanner: false,
locale: Locale(themeProvider.lan),
theme: ThemeData(
textTheme: TextTheme(
Expand Down
2 changes: 2 additions & 0 deletions lib/views/mobile_screens/category.dart
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,7 @@ class _CRUDCategoryState extends ConsumerState<CRUDCategory> {
if (!context.mounted) return;
AppConstant().showAlert(
context,
isDark,
'Error',
"There was an error while ${bisUpdate ? "updating" : "adding"} the category, Please try again later :(",
"OK");
Expand All @@ -154,6 +155,7 @@ class _CRUDCategoryState extends ConsumerState<CRUDCategory> {
if (_formKey.currentState!.validate()) {
AppConstant().showAlert(
context,
isDark,
'Are you sure?',
"This action can't be undone",
'No',
Expand Down
8 changes: 6 additions & 2 deletions lib/views/mobile_screens/home_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,10 @@ class _HomeScreenState extends ConsumerState<HomeScreen>
orders = response.object!.orders!;
}

for(var i = 0; i < pendingOrders.length; i++){
print(pendingOrders[i].toJson());
}

pendingOrders = pendingOrders;
currentOrders = currentOrders;
servedOrders = servedOrders;
Expand Down Expand Up @@ -98,7 +102,7 @@ class _HomeScreenState extends ConsumerState<HomeScreen>
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Text(
'logo',
'Ruchulu',
style: AppConstant().logoTextStyle(
themeProvider.darkMode == true
? AppConstant.darkAccent
Expand Down Expand Up @@ -223,7 +227,7 @@ class _HomeScreenState extends ConsumerState<HomeScreen>
themeProvider.darkMode
? Icons.dark_mode
: Icons.sunny,
'Change theme',
'Theme',
),
AppConstant().containerWithLabelComponent(
themeProvider.darkMode,
Expand Down
2 changes: 1 addition & 1 deletion lib/views/mobile_screens/login_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ class _LoginScreenState extends ConsumerState<LoginScreen> {
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Text(
'logo',
'Ruchulu',
style: AppConstant().logoTextStyle(
themeProvider.darkMode == true
? AppConstant.darkAccent
Expand Down
1 change: 1 addition & 0 deletions lib/views/mobile_screens/menu_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,7 @@ class _MenuScreenState extends ConsumerState<MenuScreen> {
if (!context.mounted) return;
AppConstant().showAlert(
context,
isDark,
'Error',
"There was an error while ${bisUpdate ? "updating" : "adding"} the category, Please try again later :(",
"OK");
Expand Down
Loading

0 comments on commit 4628a1a

Please sign in to comment.