Merge pull request #141 from yaso-meth/NEW--Favourite-Cards
NEW--Favourite-Cards
This commit is contained in:
@@ -2,6 +2,7 @@ import 'dart:convert';
|
|||||||
|
|
||||||
import 'package:mzansi_innovation_hub/mih_components/mih_pop_up_messages/mih_loading_circle.dart';
|
import 'package:mzansi_innovation_hub/mih_components/mih_pop_up_messages/mih_loading_circle.dart';
|
||||||
import 'package:mzansi_innovation_hub/mih_objects/app_user.dart';
|
import 'package:mzansi_innovation_hub/mih_objects/app_user.dart';
|
||||||
|
import 'package:mzansi_innovation_hub/mih_objects/arguments.dart';
|
||||||
import 'package:mzansi_innovation_hub/mih_objects/loyalty_card.dart';
|
import 'package:mzansi_innovation_hub/mih_objects/loyalty_card.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
// import '../mih_components/mih_pop_up_messages/mih_error_message.dart';
|
// import '../mih_components/mih_pop_up_messages/mih_error_message.dart';
|
||||||
@@ -40,7 +41,36 @@ class MIHMzansiWalletApis {
|
|||||||
// print("Code: ${response.statusCode}");
|
// print("Code: ${response.statusCode}");
|
||||||
// errorCode = response.statusCode.toString();
|
// errorCode = response.statusCode.toString();
|
||||||
// errorBody = response.body;
|
// errorBody = response.body;
|
||||||
|
if (response.statusCode == 200) {
|
||||||
|
//print("Here1");
|
||||||
|
Iterable l = jsonDecode(response.body);
|
||||||
|
//print("Here2");
|
||||||
|
List<MIHLoyaltyCard> patientQueue = List<MIHLoyaltyCard>.from(
|
||||||
|
l.map((model) => MIHLoyaltyCard.fromJson(model)));
|
||||||
|
//print("Here3");
|
||||||
|
//print(patientQueue);
|
||||||
|
return patientQueue;
|
||||||
|
} else {
|
||||||
|
throw Exception('failed to fatch loyalty cards');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// This function is used to fetch a list of loyalty cards for a user.
|
||||||
|
///
|
||||||
|
/// Patameters: app_id .
|
||||||
|
///
|
||||||
|
/// Returns List<PatientQueue>.
|
||||||
|
static Future<List<MIHLoyaltyCard>> getFavouriteLoyaltyCards(
|
||||||
|
String app_id,
|
||||||
|
) async {
|
||||||
|
//print("Patien manager page: $endpoint");
|
||||||
|
final response = await http.get(Uri.parse(
|
||||||
|
"${AppEnviroment.baseApiUrl}/mzasni-wallet/loyalty-cards/favourites/$app_id"));
|
||||||
|
// print("Here");
|
||||||
|
// print("Body: ${response.body}");
|
||||||
|
// print("Code: ${response.statusCode}");
|
||||||
|
// errorCode = response.statusCode.toString();
|
||||||
|
// errorBody = response.body;
|
||||||
if (response.statusCode == 200) {
|
if (response.statusCode == 200) {
|
||||||
// print("Here1");
|
// print("Here1");
|
||||||
Iterable l = jsonDecode(response.body);
|
Iterable l = jsonDecode(response.body);
|
||||||
@@ -66,6 +96,7 @@ class MIHMzansiWalletApis {
|
|||||||
static Future<void> deleteLoyaltyCardAPICall(
|
static Future<void> deleteLoyaltyCardAPICall(
|
||||||
AppUser signedInUser,
|
AppUser signedInUser,
|
||||||
int idloyalty_cards,
|
int idloyalty_cards,
|
||||||
|
int navIndex,
|
||||||
BuildContext context,
|
BuildContext context,
|
||||||
) async {
|
) async {
|
||||||
loadingPopUp(context);
|
loadingPopUp(context);
|
||||||
@@ -83,14 +114,16 @@ class MIHMzansiWalletApis {
|
|||||||
Navigator.of(context).pop();
|
Navigator.of(context).pop();
|
||||||
Navigator.of(context).pop();
|
Navigator.of(context).pop();
|
||||||
Navigator.of(context).pop();
|
Navigator.of(context).pop();
|
||||||
|
Navigator.of(context).pop();
|
||||||
Navigator.of(context).pushNamed(
|
Navigator.of(context).pushNamed(
|
||||||
'/mzansi-wallet',
|
'/mzansi-wallet',
|
||||||
arguments: signedInUser,
|
arguments: WalletArguments(signedInUser, navIndex),
|
||||||
);
|
);
|
||||||
String message =
|
String message =
|
||||||
"The loyalty card has been deleted successfully. This means it will no longer be visible in your Mzansi Wallet.";
|
"The loyalty card has been deleted successfully. This means it will no longer be visible in your Mzansi Wallet.";
|
||||||
successPopUp(message, context);
|
successPopUp(message, context);
|
||||||
} else {
|
} else {
|
||||||
|
Navigator.pop(context);
|
||||||
internetConnectionPopUp(context);
|
internetConnectionPopUp(context);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -110,6 +143,9 @@ class MIHMzansiWalletApis {
|
|||||||
String app_id,
|
String app_id,
|
||||||
String shop_name,
|
String shop_name,
|
||||||
String card_number,
|
String card_number,
|
||||||
|
String favourite,
|
||||||
|
int priority_index,
|
||||||
|
int navIndex,
|
||||||
BuildContext context,
|
BuildContext context,
|
||||||
) async {
|
) async {
|
||||||
loadingPopUp(context);
|
loadingPopUp(context);
|
||||||
@@ -123,6 +159,8 @@ class MIHMzansiWalletApis {
|
|||||||
"app_id": app_id,
|
"app_id": app_id,
|
||||||
"shop_name": shop_name,
|
"shop_name": shop_name,
|
||||||
"card_number": card_number,
|
"card_number": card_number,
|
||||||
|
"favourite": favourite,
|
||||||
|
"priority_index": priority_index,
|
||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
if (response.statusCode == 201) {
|
if (response.statusCode == 201) {
|
||||||
@@ -133,7 +171,7 @@ class MIHMzansiWalletApis {
|
|||||||
Navigator.pop(context);
|
Navigator.pop(context);
|
||||||
Navigator.of(context).pushNamed(
|
Navigator.of(context).pushNamed(
|
||||||
'/mzansi-wallet',
|
'/mzansi-wallet',
|
||||||
arguments: signedInUser,
|
arguments: WalletArguments(signedInUser, navIndex),
|
||||||
);
|
);
|
||||||
successPopUp(message, context);
|
successPopUp(message, context);
|
||||||
} else {
|
} else {
|
||||||
@@ -142,6 +180,54 @@ class MIHMzansiWalletApis {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// This function is used to Update loyalty card from users mzansi wallet.
|
||||||
|
///
|
||||||
|
/// Patameters:-
|
||||||
|
/// AppUser signedInUser,
|
||||||
|
/// int idloyalty_cards,
|
||||||
|
/// BuildContext context,
|
||||||
|
///
|
||||||
|
/// Returns VOID (TRIGGERS NOTIGICATIOPN ON SUCCESS)
|
||||||
|
static Future<void> updateLoyaltyCardAPICall(
|
||||||
|
AppUser signedInUser,
|
||||||
|
int idloyalty_cards,
|
||||||
|
String favourite,
|
||||||
|
int priority_index,
|
||||||
|
int navIndex,
|
||||||
|
BuildContext context,
|
||||||
|
) async {
|
||||||
|
loadingPopUp(context);
|
||||||
|
var response = await http.put(
|
||||||
|
Uri.parse(
|
||||||
|
"${AppEnviroment.baseApiUrl}/mzasni-wallet/loyalty-cards/update/"),
|
||||||
|
headers: <String, String>{
|
||||||
|
"Content-Type": "application/json; charset=UTF-8"
|
||||||
|
},
|
||||||
|
body: jsonEncode(<String, dynamic>{
|
||||||
|
"idloyalty_cards": idloyalty_cards,
|
||||||
|
"favourite": favourite,
|
||||||
|
"priority_index": priority_index,
|
||||||
|
}),
|
||||||
|
);
|
||||||
|
//print("Here4");
|
||||||
|
//print(response.statusCode);
|
||||||
|
if (response.statusCode == 200) {
|
||||||
|
Navigator.of(context).pop();
|
||||||
|
Navigator.of(context).pop();
|
||||||
|
Navigator.of(context).pop();
|
||||||
|
Navigator.of(context).pop();
|
||||||
|
Navigator.of(context).pushNamed(
|
||||||
|
'/mzansi-wallet',
|
||||||
|
arguments: WalletArguments(signedInUser, navIndex),
|
||||||
|
);
|
||||||
|
String message = "The loyalty card has been added to your favourites.";
|
||||||
|
successPopUp(message, context);
|
||||||
|
} else {
|
||||||
|
Navigator.pop(context);
|
||||||
|
internetConnectionPopUp(context);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//================== POP UPS ==========================================================================
|
//================== POP UPS ==========================================================================
|
||||||
|
|
||||||
static void internetConnectionPopUp(BuildContext context) {
|
static void internetConnectionPopUp(BuildContext context) {
|
||||||
|
|||||||
@@ -35,15 +35,13 @@ class _MihAppTileState extends State<MihAppTile> {
|
|||||||
return MihAppWindow(
|
return MihAppWindow(
|
||||||
fullscreen: false,
|
fullscreen: false,
|
||||||
windowTitle: widget.appName,
|
windowTitle: widget.appName,
|
||||||
windowTools: const [],
|
// windowTools: const [],
|
||||||
onWindowTapClose: () {
|
onWindowTapClose: () {
|
||||||
Navigator.pop(context);
|
Navigator.pop(context);
|
||||||
},
|
},
|
||||||
windowBody: [
|
windowBody: MIHYTVideoPlayer(
|
||||||
MIHYTVideoPlayer(
|
|
||||||
videoYTLink: widget.ytVideoID!,
|
videoYTLink: widget.ytVideoID!,
|
||||||
),
|
),
|
||||||
],
|
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -1,17 +1,19 @@
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import '../../main.dart';
|
import 'package:mzansi_innovation_hub/main.dart';
|
||||||
|
|
||||||
class MihAppWindow extends StatefulWidget {
|
class MihAppWindow extends StatefulWidget {
|
||||||
final String windowTitle;
|
final String windowTitle;
|
||||||
final List<Widget> windowBody;
|
final Widget windowBody;
|
||||||
final List<Widget> windowTools;
|
final Widget? windowTools;
|
||||||
|
// final List<SpeedDialChild> menuOptions;
|
||||||
final void Function() onWindowTapClose;
|
final void Function() onWindowTapClose;
|
||||||
final bool fullscreen;
|
final bool fullscreen;
|
||||||
const MihAppWindow({
|
const MihAppWindow({
|
||||||
super.key,
|
super.key,
|
||||||
required this.fullscreen,
|
required this.fullscreen,
|
||||||
required this.windowTitle,
|
required this.windowTitle,
|
||||||
required this.windowTools,
|
this.windowTools,
|
||||||
|
// required this.menuOptions,
|
||||||
required this.onWindowTapClose,
|
required this.onWindowTapClose,
|
||||||
required this.windowBody,
|
required this.windowBody,
|
||||||
});
|
});
|
||||||
@@ -51,139 +53,45 @@ class _MihAppWindowState extends State<MihAppWindow> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Widget getWidnowClose() {
|
Widget getWindowHeader() {
|
||||||
return Container(
|
return Container(
|
||||||
alignment: Alignment.centerRight,
|
// color: Colors.green,
|
||||||
|
alignment: Alignment.center,
|
||||||
|
height: 50,
|
||||||
|
child: Row(
|
||||||
|
children: [
|
||||||
|
widget.windowTools != null ? widget.windowTools! : Container(),
|
||||||
|
Expanded(
|
||||||
|
child: Container(
|
||||||
|
padding: EdgeInsets.symmetric(horizontal: 15),
|
||||||
|
// color: Colors.pink,
|
||||||
|
child: Text(
|
||||||
|
widget.windowTitle,
|
||||||
|
textAlign: TextAlign.left,
|
||||||
|
style: TextStyle(
|
||||||
|
fontSize: windowTitleSize,
|
||||||
|
fontWeight: FontWeight.bold,
|
||||||
|
color:
|
||||||
|
MzanziInnovationHub.of(context)!.theme.secondaryColor(),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
Container(
|
||||||
|
// color: Colors.white,
|
||||||
|
alignment: Alignment.center,
|
||||||
child: IconButton(
|
child: IconButton(
|
||||||
onPressed: widget.onWindowTapClose,
|
iconSize: 35,
|
||||||
|
onPressed: () {
|
||||||
|
widget.onWindowTapClose();
|
||||||
|
},
|
||||||
icon: Icon(
|
icon: Icon(
|
||||||
Icons.close,
|
Icons.close,
|
||||||
color: MzanziInnovationHub.of(context)!.theme.errorColor(),
|
color: MzanziInnovationHub.of(context)!.theme.errorColor(),
|
||||||
size: 35,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
Widget getWidnowTools() {
|
|
||||||
return Row(
|
|
||||||
crossAxisAlignment: CrossAxisAlignment.center,
|
|
||||||
mainAxisAlignment: MainAxisAlignment.start,
|
|
||||||
mainAxisSize: MainAxisSize.max,
|
|
||||||
children: widget.windowTools,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
Widget getWidnowTitle() {
|
|
||||||
return Row(
|
|
||||||
crossAxisAlignment: CrossAxisAlignment.center,
|
|
||||||
mainAxisAlignment: MainAxisAlignment.center,
|
|
||||||
mainAxisSize: MainAxisSize.min,
|
|
||||||
children: [
|
|
||||||
Expanded(
|
|
||||||
child: Text(
|
|
||||||
widget.windowTitle,
|
|
||||||
textAlign: TextAlign.center,
|
|
||||||
overflow: TextOverflow.ellipsis,
|
|
||||||
style: TextStyle(
|
|
||||||
color: MzanziInnovationHub.of(context)!.theme.secondaryColor(),
|
|
||||||
fontSize: windowTitleSize,
|
|
||||||
fontWeight: FontWeight.bold,
|
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
Widget getWidnowHeader() {
|
|
||||||
return Row(
|
|
||||||
crossAxisAlignment: CrossAxisAlignment.center,
|
|
||||||
mainAxisAlignment: MainAxisAlignment.center,
|
|
||||||
mainAxisSize: MainAxisSize.max,
|
|
||||||
children: [
|
|
||||||
getWidnowTools(),
|
|
||||||
Expanded(
|
|
||||||
flex: 2,
|
|
||||||
child: getWidnowTitle(),
|
|
||||||
),
|
|
||||||
getWidnowClose(),
|
|
||||||
],
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
Widget getWidnowBody() {
|
|
||||||
if (widget.fullscreen) {
|
|
||||||
return Expanded(
|
|
||||||
child: Padding(
|
|
||||||
padding: const EdgeInsets.all(10.0),
|
|
||||||
child: Column(
|
|
||||||
crossAxisAlignment: CrossAxisAlignment.center,
|
|
||||||
mainAxisAlignment: MainAxisAlignment.center,
|
|
||||||
mainAxisSize: MainAxisSize.max,
|
|
||||||
children: widget.windowBody,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
} else {
|
|
||||||
return Padding(
|
|
||||||
padding: const EdgeInsets.all(10.0),
|
|
||||||
child: Column(
|
|
||||||
crossAxisAlignment: CrossAxisAlignment.center,
|
|
||||||
mainAxisAlignment: MainAxisAlignment.center,
|
|
||||||
mainAxisSize: MainAxisSize.max,
|
|
||||||
children: widget.windowBody,
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Widget createWindow(Widget header, Widget body) {
|
|
||||||
Widget visibleItems;
|
|
||||||
if (widget.fullscreen) {
|
|
||||||
visibleItems = Column(
|
|
||||||
crossAxisAlignment: CrossAxisAlignment.center,
|
|
||||||
mainAxisAlignment: MainAxisAlignment.start,
|
|
||||||
mainAxisSize: MainAxisSize.min,
|
|
||||||
children: [
|
|
||||||
header,
|
|
||||||
//const Divider(),
|
|
||||||
body,
|
|
||||||
],
|
|
||||||
);
|
|
||||||
} else {
|
|
||||||
visibleItems = SingleChildScrollView(
|
|
||||||
child: Column(
|
|
||||||
crossAxisAlignment: CrossAxisAlignment.center,
|
|
||||||
mainAxisAlignment: MainAxisAlignment.start,
|
|
||||||
mainAxisSize: MainAxisSize.min,
|
|
||||||
children: [
|
|
||||||
header,
|
|
||||||
//const Divider(),
|
|
||||||
body,
|
|
||||||
],
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
return Dialog(
|
|
||||||
insetPadding: EdgeInsets.symmetric(
|
|
||||||
horizontal: horizontralWindowPadding,
|
|
||||||
vertical: vertticalWindowPadding,
|
|
||||||
),
|
|
||||||
insetAnimationCurve: Easing.emphasizedDecelerate,
|
|
||||||
insetAnimationDuration: Durations.short1,
|
|
||||||
child: Container(
|
|
||||||
//padding: const EdgeInsets.all(10),
|
|
||||||
width: windowWidth,
|
|
||||||
//height: windowHeight,
|
|
||||||
decoration: BoxDecoration(
|
|
||||||
color: MzanziInnovationHub.of(context)!.theme.primaryColor(),
|
|
||||||
borderRadius: BorderRadius.circular(25.0),
|
|
||||||
border: Border.all(
|
|
||||||
color: MzanziInnovationHub.of(context)!.theme.secondaryColor(),
|
|
||||||
width: 5.0),
|
|
||||||
),
|
|
||||||
child: visibleItems,
|
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -206,9 +114,43 @@ class _MihAppWindowState extends State<MihAppWindow> {
|
|||||||
height = size.height;
|
height = size.height;
|
||||||
});
|
});
|
||||||
checkScreenSize();
|
checkScreenSize();
|
||||||
return createWindow(
|
return Dialog(
|
||||||
getWidnowHeader(),
|
insetPadding: EdgeInsets.symmetric(
|
||||||
getWidnowBody(),
|
horizontal: horizontralWindowPadding,
|
||||||
|
vertical: vertticalWindowPadding,
|
||||||
|
),
|
||||||
|
insetAnimationCurve: Easing.emphasizedDecelerate,
|
||||||
|
insetAnimationDuration: Durations.short1,
|
||||||
|
child: Container(
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
color: MzanziInnovationHub.of(context)!.theme.primaryColor(),
|
||||||
|
borderRadius: BorderRadius.circular(25.0),
|
||||||
|
border: Border.all(
|
||||||
|
color: MzanziInnovationHub.of(context)!.theme.secondaryColor(),
|
||||||
|
width: 5.0),
|
||||||
|
),
|
||||||
|
child: widget.fullscreen
|
||||||
|
? Column(
|
||||||
|
mainAxisSize: MainAxisSize.max,
|
||||||
|
children: [
|
||||||
|
getWindowHeader(),
|
||||||
|
Expanded(child: widget.windowBody),
|
||||||
|
],
|
||||||
|
)
|
||||||
|
: Column(
|
||||||
|
mainAxisSize: MainAxisSize.min,
|
||||||
|
children: [
|
||||||
|
getWindowHeader(),
|
||||||
|
Padding(
|
||||||
|
padding: const EdgeInsets.only(
|
||||||
|
left: 15,
|
||||||
|
right: 15,
|
||||||
|
bottom: 15,
|
||||||
|
),
|
||||||
|
child: widget.windowBody),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,11 +5,13 @@ import 'package:mzansi_innovation_hub/main.dart';
|
|||||||
class MihFloatingMenu extends StatefulWidget {
|
class MihFloatingMenu extends StatefulWidget {
|
||||||
final IconData? icon;
|
final IconData? icon;
|
||||||
final AnimatedIconData? animatedIcon;
|
final AnimatedIconData? animatedIcon;
|
||||||
|
final SpeedDialDirection? direction;
|
||||||
final List<SpeedDialChild> children;
|
final List<SpeedDialChild> children;
|
||||||
const MihFloatingMenu({
|
const MihFloatingMenu({
|
||||||
super.key,
|
super.key,
|
||||||
this.icon,
|
this.icon,
|
||||||
this.animatedIcon,
|
this.animatedIcon,
|
||||||
|
this.direction,
|
||||||
required this.children,
|
required this.children,
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -28,6 +30,7 @@ class _MihFloatingMenuState extends State<MihFloatingMenu> {
|
|||||||
child: SpeedDial(
|
child: SpeedDial(
|
||||||
icon: widget.icon,
|
icon: widget.icon,
|
||||||
animatedIcon: widget.animatedIcon,
|
animatedIcon: widget.animatedIcon,
|
||||||
|
direction: widget.direction ?? SpeedDialDirection.up,
|
||||||
activeIcon: Icons.close,
|
activeIcon: Icons.close,
|
||||||
backgroundColor:
|
backgroundColor:
|
||||||
MzanziInnovationHub.of(context)!.theme.secondaryColor(),
|
MzanziInnovationHub.of(context)!.theme.secondaryColor(),
|
||||||
|
|||||||
@@ -1,14 +1,10 @@
|
|||||||
import 'package:flutter_speed_dial/flutter_speed_dial.dart';
|
|
||||||
import 'package:mzansi_innovation_hub/main.dart';
|
import 'package:mzansi_innovation_hub/main.dart';
|
||||||
import 'package:mzansi_innovation_hub/mih_components/mih_layout/mih_single_child_scroll.dart';
|
|
||||||
import 'package:mzansi_innovation_hub/mih_components/mih_package_components/mih_app.dart';
|
import 'package:mzansi_innovation_hub/mih_components/mih_package_components/mih_app.dart';
|
||||||
import 'package:mzansi_innovation_hub/mih_components/mih_package_components/mih_app_action.dart';
|
import 'package:mzansi_innovation_hub/mih_components/mih_package_components/mih_app_action.dart';
|
||||||
import 'package:mzansi_innovation_hub/mih_components/mih_package_components/mih_app_alert.dart';
|
import 'package:mzansi_innovation_hub/mih_components/mih_package_components/mih_app_alert.dart';
|
||||||
import 'package:mzansi_innovation_hub/mih_components/mih_package_components/mih_app_tools.dart';
|
import 'package:mzansi_innovation_hub/mih_components/mih_package_components/mih_app_tools.dart';
|
||||||
import 'package:mzansi_innovation_hub/mih_components/mih_package_components/mih_app_window.dart';
|
import 'package:mzansi_innovation_hub/mih_components/mih_package_components/test/package_tools/package_tool_one.dart';
|
||||||
import 'package:mzansi_innovation_hub/mih_components/mih_package_components/mih-app_tool_body.dart';
|
import 'package:mzansi_innovation_hub/mih_components/mih_package_components/test/package_tools/package_tool_two.dart';
|
||||||
import 'package:mzansi_innovation_hub/mih_components/mih_package_components/mih_floating_menu.dart';
|
|
||||||
import 'package:mzansi_innovation_hub/mih_components/mih_package_components/mih_icons.dart';
|
|
||||||
import 'package:mzansi_innovation_hub/mih_objects/arguments.dart';
|
import 'package:mzansi_innovation_hub/mih_objects/arguments.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
@@ -38,12 +34,12 @@ class _PackageTestState extends State<PackageTest> {
|
|||||||
|
|
||||||
MihAppTools getTools() {
|
MihAppTools getTools() {
|
||||||
Map<Widget, void Function()?> temp = Map();
|
Map<Widget, void Function()?> temp = Map();
|
||||||
temp[const Icon(Icons.arrow_back)] = () {
|
temp[const Icon(Icons.inbox)] = () {
|
||||||
setState(() {
|
setState(() {
|
||||||
_selcetedIndex = 0;
|
_selcetedIndex = 0;
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
temp[const Icon(Icons.arrow_forward)] = () {
|
temp[const Icon(Icons.outbond)] = () {
|
||||||
setState(() {
|
setState(() {
|
||||||
_selcetedIndex = 1;
|
_selcetedIndex = 1;
|
||||||
});
|
});
|
||||||
@@ -113,134 +109,10 @@ class _PackageTestState extends State<PackageTest> {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
void showFullScreenWindow() {
|
List<Widget> getToolBody() {
|
||||||
showDialog(
|
List<Widget> toolBodies = [
|
||||||
context: context,
|
const PackageToolOne(),
|
||||||
builder: (context) {
|
const PackageToolTwo(),
|
||||||
return MihAppWindow(
|
|
||||||
fullscreen: true,
|
|
||||||
windowTitle: "Test",
|
|
||||||
windowTools: const [],
|
|
||||||
onWindowTapClose: () {
|
|
||||||
Navigator.pop(context);
|
|
||||||
},
|
|
||||||
windowBody: [
|
|
||||||
Text(
|
|
||||||
"Window test",
|
|
||||||
style: TextStyle(
|
|
||||||
color: MzanziInnovationHub.of(context)!.theme.secondaryColor(),
|
|
||||||
fontSize: 15,
|
|
||||||
fontWeight: FontWeight.bold,
|
|
||||||
),
|
|
||||||
)
|
|
||||||
],
|
|
||||||
);
|
|
||||||
},
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
void showNormalWindow() {
|
|
||||||
showDialog(
|
|
||||||
context: context,
|
|
||||||
builder: (context) {
|
|
||||||
return MihAppWindow(
|
|
||||||
fullscreen: false,
|
|
||||||
windowTitle: "Test",
|
|
||||||
windowTools: const [],
|
|
||||||
onWindowTapClose: () {
|
|
||||||
Navigator.pop(context);
|
|
||||||
},
|
|
||||||
windowBody: [
|
|
||||||
Text(
|
|
||||||
"Window test",
|
|
||||||
style: TextStyle(
|
|
||||||
color: MzanziInnovationHub.of(context)!.theme.secondaryColor(),
|
|
||||||
fontSize: 15,
|
|
||||||
fontWeight: FontWeight.bold,
|
|
||||||
),
|
|
||||||
)
|
|
||||||
],
|
|
||||||
);
|
|
||||||
},
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
List<MihAppToolBody> getToolBody() {
|
|
||||||
List<MihAppToolBody> toolBodies = [
|
|
||||||
MihAppToolBody(
|
|
||||||
borderOn: true,
|
|
||||||
bodyItem: MihSingleChildScroll(
|
|
||||||
child: Column(
|
|
||||||
mainAxisAlignment: MainAxisAlignment.start,
|
|
||||||
mainAxisSize: MainAxisSize.max,
|
|
||||||
children: [
|
|
||||||
Text(
|
|
||||||
"Hello",
|
|
||||||
textAlign: TextAlign.center,
|
|
||||||
style: TextStyle(
|
|
||||||
fontSize: 25,
|
|
||||||
fontWeight: FontWeight.bold,
|
|
||||||
color:
|
|
||||||
MzanziInnovationHub.of(context)!.theme.secondaryColor(),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
const SizedBox(height: 10),
|
|
||||||
MihFloatingMenu(children: [
|
|
||||||
SpeedDialChild(
|
|
||||||
child: Icon(
|
|
||||||
Icons.add,
|
|
||||||
color:
|
|
||||||
MzanziInnovationHub.of(context)!.theme.primaryColor(),
|
|
||||||
),
|
|
||||||
label: "Add",
|
|
||||||
labelBackgroundColor:
|
|
||||||
MzanziInnovationHub.of(context)!.theme.secondaryColor(),
|
|
||||||
labelStyle: TextStyle(
|
|
||||||
color:
|
|
||||||
MzanziInnovationHub.of(context)!.theme.primaryColor(),
|
|
||||||
),
|
|
||||||
backgroundColor:
|
|
||||||
MzanziInnovationHub.of(context)!.theme.secondaryColor(),
|
|
||||||
onTap: () {},
|
|
||||||
)
|
|
||||||
]),
|
|
||||||
Container(
|
|
||||||
color: Colors.black,
|
|
||||||
width: 200,
|
|
||||||
height: 200,
|
|
||||||
padding: EdgeInsets.zero,
|
|
||||||
alignment: Alignment.center,
|
|
||||||
child: IconButton.filled(
|
|
||||||
onPressed: () {},
|
|
||||||
icon: Icon(
|
|
||||||
MihIcons.mihLogo,
|
|
||||||
color:
|
|
||||||
MzanziInnovationHub.of(context)!.theme.primaryColor(),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
)
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
MihAppToolBody(
|
|
||||||
borderOn: false,
|
|
||||||
bodyItem: Column(
|
|
||||||
mainAxisAlignment: MainAxisAlignment.start,
|
|
||||||
mainAxisSize: MainAxisSize.max,
|
|
||||||
children: [
|
|
||||||
Text(
|
|
||||||
"World!!!",
|
|
||||||
textAlign: TextAlign.center,
|
|
||||||
style: TextStyle(
|
|
||||||
fontSize: 25,
|
|
||||||
fontWeight: FontWeight.bold,
|
|
||||||
color: MzanziInnovationHub.of(context)!.theme.secondaryColor(),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
];
|
];
|
||||||
return toolBodies;
|
return toolBodies;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,10 @@
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:flutter_speed_dial/flutter_speed_dial.dart';
|
||||||
import 'package:mzansi_innovation_hub/main.dart';
|
import 'package:mzansi_innovation_hub/main.dart';
|
||||||
import 'package:mzansi_innovation_hub/mih_components/mih_layout/mih_single_child_scroll.dart';
|
import 'package:mzansi_innovation_hub/mih_components/mih_layout/mih_single_child_scroll.dart';
|
||||||
import 'package:mzansi_innovation_hub/mih_components/mih_package_components/mih-app_tool_body.dart';
|
import 'package:mzansi_innovation_hub/mih_components/mih_package_components/mih-app_tool_body.dart';
|
||||||
|
import 'package:mzansi_innovation_hub/mih_components/mih_package_components/mih_app_window.dart';
|
||||||
|
import 'package:mzansi_innovation_hub/mih_components/mih_package_components/mih_floating_menu.dart';
|
||||||
import 'package:mzansi_innovation_hub/mih_components/mih_package_components/mih_icons.dart';
|
import 'package:mzansi_innovation_hub/mih_components/mih_package_components/mih_icons.dart';
|
||||||
|
|
||||||
class PackageToolOne extends StatefulWidget {
|
class PackageToolOne extends StatefulWidget {
|
||||||
@@ -12,6 +15,40 @@ class PackageToolOne extends StatefulWidget {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class _PackageToolOneState extends State<PackageToolOne> {
|
class _PackageToolOneState extends State<PackageToolOne> {
|
||||||
|
void showTestFullWindow() {
|
||||||
|
showDialog(
|
||||||
|
context: context,
|
||||||
|
barrierDismissible: false,
|
||||||
|
builder: (context) {
|
||||||
|
return MihAppWindow(
|
||||||
|
fullscreen: true,
|
||||||
|
windowTitle: "Test Full",
|
||||||
|
onWindowTapClose: () {
|
||||||
|
Navigator.of(context).pop();
|
||||||
|
},
|
||||||
|
windowBody: Text("Testing Window Body"),
|
||||||
|
);
|
||||||
|
},
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
void showTestWindow() {
|
||||||
|
showDialog(
|
||||||
|
context: context,
|
||||||
|
barrierDismissible: false,
|
||||||
|
builder: (context) {
|
||||||
|
return MihAppWindow(
|
||||||
|
fullscreen: false,
|
||||||
|
windowTitle: "Test No Full",
|
||||||
|
onWindowTapClose: () {
|
||||||
|
Navigator.of(context).pop();
|
||||||
|
},
|
||||||
|
windowBody: Text("Testing Window Body"),
|
||||||
|
);
|
||||||
|
},
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return MihAppToolBody(
|
return MihAppToolBody(
|
||||||
@@ -21,12 +58,16 @@ class _PackageToolOneState extends State<PackageToolOne> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Widget getBody() {
|
Widget getBody() {
|
||||||
return MihAppToolBody(
|
return Stack(
|
||||||
borderOn: true,
|
children: [
|
||||||
bodyItem: MihSingleChildScroll(
|
MihSingleChildScroll(
|
||||||
child: Column(
|
child: Column(
|
||||||
mainAxisAlignment: MainAxisAlignment.start,
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.center,
|
||||||
mainAxisSize: MainAxisSize.max,
|
mainAxisSize: MainAxisSize.max,
|
||||||
|
children: [
|
||||||
|
Row(
|
||||||
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
children: [
|
children: [
|
||||||
Text(
|
Text(
|
||||||
"Hello",
|
"Hello",
|
||||||
@@ -34,9 +75,13 @@ class _PackageToolOneState extends State<PackageToolOne> {
|
|||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
fontSize: 25,
|
fontSize: 25,
|
||||||
fontWeight: FontWeight.bold,
|
fontWeight: FontWeight.bold,
|
||||||
color: MzanziInnovationHub.of(context)!.theme.secondaryColor(),
|
color: MzanziInnovationHub.of(context)!
|
||||||
|
.theme
|
||||||
|
.secondaryColor(),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
const SizedBox(height: 10),
|
const SizedBox(height: 10),
|
||||||
Container(
|
Container(
|
||||||
color: Colors.black,
|
color: Colors.black,
|
||||||
@@ -48,13 +93,63 @@ class _PackageToolOneState extends State<PackageToolOne> {
|
|||||||
onPressed: () {},
|
onPressed: () {},
|
||||||
icon: Icon(
|
icon: Icon(
|
||||||
MihIcons.mihLogo,
|
MihIcons.mihLogo,
|
||||||
color: MzanziInnovationHub.of(context)!.theme.primaryColor(),
|
color:
|
||||||
|
MzanziInnovationHub.of(context)!.theme.primaryColor(),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
Positioned(
|
||||||
|
right: 0,
|
||||||
|
bottom: 0,
|
||||||
|
child: MihFloatingMenu(
|
||||||
|
animatedIcon: AnimatedIcons.menu_close,
|
||||||
|
children: [
|
||||||
|
SpeedDialChild(
|
||||||
|
child: Icon(
|
||||||
|
Icons.add,
|
||||||
|
color:
|
||||||
|
MzanziInnovationHub.of(context)!.theme.primaryColor(),
|
||||||
|
),
|
||||||
|
label: "Show New Window",
|
||||||
|
labelBackgroundColor:
|
||||||
|
MzanziInnovationHub.of(context)!.theme.successColor(),
|
||||||
|
labelStyle: TextStyle(
|
||||||
|
color:
|
||||||
|
MzanziInnovationHub.of(context)!.theme.primaryColor(),
|
||||||
|
fontWeight: FontWeight.bold,
|
||||||
|
),
|
||||||
|
backgroundColor:
|
||||||
|
MzanziInnovationHub.of(context)!.theme.successColor(),
|
||||||
|
onTap: () {
|
||||||
|
showTestWindow();
|
||||||
|
},
|
||||||
|
),
|
||||||
|
SpeedDialChild(
|
||||||
|
child: Icon(
|
||||||
|
Icons.add,
|
||||||
|
color:
|
||||||
|
MzanziInnovationHub.of(context)!.theme.primaryColor(),
|
||||||
|
),
|
||||||
|
label: "Show New Full Window",
|
||||||
|
labelBackgroundColor:
|
||||||
|
MzanziInnovationHub.of(context)!.theme.successColor(),
|
||||||
|
labelStyle: TextStyle(
|
||||||
|
color:
|
||||||
|
MzanziInnovationHub.of(context)!.theme.primaryColor(),
|
||||||
|
fontWeight: FontWeight.bold,
|
||||||
|
),
|
||||||
|
backgroundColor:
|
||||||
|
MzanziInnovationHub.of(context)!.theme.successColor(),
|
||||||
|
onTap: () {
|
||||||
|
showTestFullWindow();
|
||||||
|
},
|
||||||
|
),
|
||||||
|
]),
|
||||||
|
)
|
||||||
|
],
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,57 @@
|
|||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:mzansi_innovation_hub/main.dart';
|
||||||
|
import 'package:mzansi_innovation_hub/mih_components/mih_layout/mih_single_child_scroll.dart';
|
||||||
|
import 'package:mzansi_innovation_hub/mih_components/mih_package_components/mih-app_tool_body.dart';
|
||||||
|
import 'package:mzansi_innovation_hub/mih_components/mih_package_components/mih_icons.dart';
|
||||||
|
|
||||||
|
class PackageToolTwo extends StatefulWidget {
|
||||||
|
const PackageToolTwo({super.key});
|
||||||
|
|
||||||
|
@override
|
||||||
|
State<PackageToolTwo> createState() => _PackageToolTwoState();
|
||||||
|
}
|
||||||
|
|
||||||
|
class _PackageToolTwoState extends State<PackageToolTwo> {
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return MihAppToolBody(
|
||||||
|
borderOn: false,
|
||||||
|
bodyItem: getBody(),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
Widget getBody() {
|
||||||
|
return MihSingleChildScroll(
|
||||||
|
child: Column(
|
||||||
|
mainAxisAlignment: MainAxisAlignment.start,
|
||||||
|
mainAxisSize: MainAxisSize.max,
|
||||||
|
children: [
|
||||||
|
Text(
|
||||||
|
"World",
|
||||||
|
textAlign: TextAlign.center,
|
||||||
|
style: TextStyle(
|
||||||
|
fontSize: 25,
|
||||||
|
fontWeight: FontWeight.bold,
|
||||||
|
color: MzanziInnovationHub.of(context)!.theme.secondaryColor(),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
const SizedBox(height: 10),
|
||||||
|
Container(
|
||||||
|
color: Colors.black,
|
||||||
|
width: 200,
|
||||||
|
height: 200,
|
||||||
|
padding: EdgeInsets.zero,
|
||||||
|
alignment: Alignment.center,
|
||||||
|
child: IconButton.filled(
|
||||||
|
onPressed: () {},
|
||||||
|
icon: Icon(
|
||||||
|
MihIcons.mihLogo,
|
||||||
|
color: MzanziInnovationHub.of(context)!.theme.primaryColor(),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
)
|
||||||
|
],
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -197,3 +197,13 @@ class PatManagerArguments {
|
|||||||
this.businessUser,
|
this.businessUser,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
class WalletArguments {
|
||||||
|
final AppUser signedInUser;
|
||||||
|
final int index;
|
||||||
|
|
||||||
|
WalletArguments(
|
||||||
|
this.signedInUser,
|
||||||
|
this.index,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|||||||
@@ -3,12 +3,16 @@ class MIHLoyaltyCard {
|
|||||||
final String app_id;
|
final String app_id;
|
||||||
final String shop_name;
|
final String shop_name;
|
||||||
final String card_number;
|
final String card_number;
|
||||||
|
final String favourite;
|
||||||
|
final int priority_index;
|
||||||
|
|
||||||
const MIHLoyaltyCard({
|
const MIHLoyaltyCard({
|
||||||
required this.idloyalty_cards,
|
required this.idloyalty_cards,
|
||||||
required this.app_id,
|
required this.app_id,
|
||||||
required this.shop_name,
|
required this.shop_name,
|
||||||
required this.card_number,
|
required this.card_number,
|
||||||
|
required this.favourite,
|
||||||
|
required this.priority_index,
|
||||||
});
|
});
|
||||||
|
|
||||||
factory MIHLoyaltyCard.fromJson(Map<String, dynamic> json) {
|
factory MIHLoyaltyCard.fromJson(Map<String, dynamic> json) {
|
||||||
@@ -18,12 +22,16 @@ class MIHLoyaltyCard {
|
|||||||
"app_id": String app_id,
|
"app_id": String app_id,
|
||||||
"shop_name": String shop_name,
|
"shop_name": String shop_name,
|
||||||
"card_number": String card_number,
|
"card_number": String card_number,
|
||||||
|
"favourite": String favourite,
|
||||||
|
"priority_index": int priority_index,
|
||||||
} =>
|
} =>
|
||||||
MIHLoyaltyCard(
|
MIHLoyaltyCard(
|
||||||
idloyalty_cards: idloyalty_cards,
|
idloyalty_cards: idloyalty_cards,
|
||||||
app_id: app_id,
|
app_id: app_id,
|
||||||
shop_name: shop_name,
|
shop_name: shop_name,
|
||||||
card_number: card_number,
|
card_number: card_number,
|
||||||
|
favourite: favourite,
|
||||||
|
priority_index: priority_index,
|
||||||
),
|
),
|
||||||
_ => throw const FormatException('Failed to load loyalty card objects'),
|
_ => throw const FormatException('Failed to load loyalty card objects'),
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -126,7 +126,8 @@ class _AiChatState extends State<AiChat> {
|
|||||||
return MihAppWindow(
|
return MihAppWindow(
|
||||||
fullscreen: false,
|
fullscreen: false,
|
||||||
windowTitle: 'Mzansi AI Thoughts',
|
windowTitle: 'Mzansi AI Thoughts',
|
||||||
windowTools: [
|
windowTools: Row(
|
||||||
|
children: [
|
||||||
Visibility(
|
Visibility(
|
||||||
visible: _aiThinking == false,
|
visible: _aiThinking == false,
|
||||||
child: Padding(
|
child: Padding(
|
||||||
@@ -134,15 +135,17 @@ class _AiChatState extends State<AiChat> {
|
|||||||
child: Container(
|
child: Container(
|
||||||
//color: MzanziInnovationHub.of(context)!.theme.successColor(),
|
//color: MzanziInnovationHub.of(context)!.theme.successColor(),
|
||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
color:
|
color: MzanziInnovationHub.of(context)!
|
||||||
MzanziInnovationHub.of(context)!.theme.successColor(),
|
.theme
|
||||||
|
.successColor(),
|
||||||
borderRadius: const BorderRadius.all(
|
borderRadius: const BorderRadius.all(
|
||||||
Radius.circular(100),
|
Radius.circular(100),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
child: IconButton(
|
child: IconButton(
|
||||||
color:
|
color: MzanziInnovationHub.of(context)!
|
||||||
MzanziInnovationHub.of(context)!.theme.primaryColor(),
|
.theme
|
||||||
|
.primaryColor(),
|
||||||
onPressed: () async {
|
onPressed: () async {
|
||||||
print("Start TTS now");
|
print("Start TTS now");
|
||||||
|
|
||||||
@@ -167,8 +170,9 @@ class _AiChatState extends State<AiChat> {
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
child: IconButton(
|
child: IconButton(
|
||||||
color:
|
color: MzanziInnovationHub.of(context)!
|
||||||
MzanziInnovationHub.of(context)!.theme.primaryColor(),
|
.theme
|
||||||
|
.primaryColor(),
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
//print("Start TTS now");
|
//print("Start TTS now");
|
||||||
_flutterTts.stop();
|
_flutterTts.stop();
|
||||||
@@ -179,13 +183,17 @@ class _AiChatState extends State<AiChat> {
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
|
),
|
||||||
onWindowTapClose: () {
|
onWindowTapClose: () {
|
||||||
_captureAIResponse(snapshot.requireData);
|
_captureAIResponse(snapshot.requireData);
|
||||||
_flutterTts.stop();
|
_flutterTts.stop();
|
||||||
Navigator.of(context).pop();
|
Navigator.of(context).pop();
|
||||||
},
|
},
|
||||||
windowBody: [
|
windowBody: Column(
|
||||||
|
children: [
|
||||||
Stack(
|
Stack(
|
||||||
|
children: [
|
||||||
|
Column(
|
||||||
children: [
|
children: [
|
||||||
Text(
|
Text(
|
||||||
snapshot.requireData,
|
snapshot.requireData,
|
||||||
@@ -198,6 +206,8 @@ class _AiChatState extends State<AiChat> {
|
|||||||
fontWeight: FontWeight.bold,
|
fontWeight: FontWeight.bold,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
Positioned(
|
Positioned(
|
||||||
bottom: 0,
|
bottom: 0,
|
||||||
right: 0,
|
right: 0,
|
||||||
@@ -240,18 +250,17 @@ class _AiChatState extends State<AiChat> {
|
|||||||
],
|
],
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
|
),
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
return MihAppWindow(
|
return MihAppWindow(
|
||||||
fullscreen: false,
|
fullscreen: false,
|
||||||
windowTitle: 'Mzansi AI Thoughts',
|
windowTitle: 'Mzansi AI Thoughts',
|
||||||
windowTools: [],
|
// windowTools: [],
|
||||||
onWindowTapClose: () {
|
onWindowTapClose: () {
|
||||||
Navigator.of(context).pop();
|
Navigator.of(context).pop();
|
||||||
},
|
},
|
||||||
windowBody: const [
|
windowBody: Mihloadingcircle(),
|
||||||
Mihloadingcircle(),
|
|
||||||
],
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -1,6 +1,8 @@
|
|||||||
import 'package:mzansi_innovation_hub/main.dart';
|
import 'package:mzansi_innovation_hub/main.dart';
|
||||||
import 'package:mzansi_innovation_hub/mih_apis/mih_mzansi_wallet_apis.dart';
|
import 'package:mzansi_innovation_hub/mih_apis/mih_mzansi_wallet_apis.dart';
|
||||||
import 'package:mzansi_innovation_hub/mih_components/mih_layout/mih_window.dart';
|
import 'package:mzansi_innovation_hub/mih_components/mih_inputs_and_buttons/mih_button.dart';
|
||||||
|
import 'package:mzansi_innovation_hub/mih_components/mih_package_components/mih_app_alert.dart';
|
||||||
|
import 'package:mzansi_innovation_hub/mih_components/mih_package_components/mih_app_window.dart';
|
||||||
import 'package:mzansi_innovation_hub/mih_components/mih_pop_up_messages/mih_delete_message.dart';
|
import 'package:mzansi_innovation_hub/mih_components/mih_pop_up_messages/mih_delete_message.dart';
|
||||||
import 'package:mzansi_innovation_hub/mih_objects/app_user.dart';
|
import 'package:mzansi_innovation_hub/mih_objects/app_user.dart';
|
||||||
import 'package:mzansi_innovation_hub/mih_objects/loyalty_card.dart';
|
import 'package:mzansi_innovation_hub/mih_objects/loyalty_card.dart';
|
||||||
@@ -13,10 +15,13 @@ import 'package:barcode_widget/barcode_widget.dart';
|
|||||||
class BuildLoyaltyCardList extends StatefulWidget {
|
class BuildLoyaltyCardList extends StatefulWidget {
|
||||||
final AppUser signedInUser;
|
final AppUser signedInUser;
|
||||||
final List<MIHLoyaltyCard> cardList;
|
final List<MIHLoyaltyCard> cardList;
|
||||||
|
final int navIndex;
|
||||||
|
|
||||||
const BuildLoyaltyCardList({
|
const BuildLoyaltyCardList({
|
||||||
super.key,
|
super.key,
|
||||||
required this.signedInUser,
|
required this.signedInUser,
|
||||||
required this.cardList,
|
required this.cardList,
|
||||||
|
required this.navIndex,
|
||||||
});
|
});
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@@ -24,6 +29,8 @@ class BuildLoyaltyCardList extends StatefulWidget {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class _BuildLoyaltyCardListState extends State<BuildLoyaltyCardList> {
|
class _BuildLoyaltyCardListState extends State<BuildLoyaltyCardList> {
|
||||||
|
late int _noFavourites;
|
||||||
|
|
||||||
void deleteCardWindow(BuildContext ctxt, int index) {
|
void deleteCardWindow(BuildContext ctxt, int index) {
|
||||||
showDialog(
|
showDialog(
|
||||||
context: context,
|
context: context,
|
||||||
@@ -35,6 +42,7 @@ class _BuildLoyaltyCardListState extends State<BuildLoyaltyCardList> {
|
|||||||
MIHMzansiWalletApis.deleteLoyaltyCardAPICall(
|
MIHMzansiWalletApis.deleteLoyaltyCardAPICall(
|
||||||
widget.signedInUser,
|
widget.signedInUser,
|
||||||
widget.cardList[index].idloyalty_cards,
|
widget.cardList[index].idloyalty_cards,
|
||||||
|
widget.navIndex,
|
||||||
context,
|
context,
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
@@ -42,6 +50,114 @@ class _BuildLoyaltyCardListState extends State<BuildLoyaltyCardList> {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void addToFavCardWindow(BuildContext ctxt, int index) {
|
||||||
|
showDialog(
|
||||||
|
context: context,
|
||||||
|
barrierDismissible: false,
|
||||||
|
builder: (context) {
|
||||||
|
return MihAppAlert(
|
||||||
|
alertIcon: Icon(
|
||||||
|
Icons.favorite,
|
||||||
|
color: MzanziInnovationHub.of(context)!.theme.secondaryColor(),
|
||||||
|
size: 100,
|
||||||
|
),
|
||||||
|
alertTitle: "Add to Favourites",
|
||||||
|
alertBody: Column(
|
||||||
|
children: [
|
||||||
|
Text(
|
||||||
|
"Are you sure you want to add this card to your favourites?",
|
||||||
|
style: TextStyle(
|
||||||
|
fontSize: 20,
|
||||||
|
color:
|
||||||
|
MzanziInnovationHub.of(context)!.theme.secondaryColor(),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
const SizedBox(
|
||||||
|
height: 15,
|
||||||
|
),
|
||||||
|
SizedBox(
|
||||||
|
width: 300,
|
||||||
|
height: 50,
|
||||||
|
child: MIHButton(
|
||||||
|
onTap: () {
|
||||||
|
MIHMzansiWalletApis.updateLoyaltyCardAPICall(
|
||||||
|
widget.signedInUser,
|
||||||
|
widget.cardList[index].idloyalty_cards,
|
||||||
|
"Yes",
|
||||||
|
_noFavourites,
|
||||||
|
0,
|
||||||
|
ctxt,
|
||||||
|
);
|
||||||
|
},
|
||||||
|
buttonText: "Add",
|
||||||
|
buttonColor:
|
||||||
|
MzanziInnovationHub.of(context)!.theme.secondaryColor(),
|
||||||
|
textColor:
|
||||||
|
MzanziInnovationHub.of(context)!.theme.primaryColor(),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
alertColour: MzanziInnovationHub.of(context)!.theme.secondaryColor(),
|
||||||
|
);
|
||||||
|
},
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
void removeFromFavCardWindow(BuildContext ctxt, int index) {
|
||||||
|
showDialog(
|
||||||
|
context: context,
|
||||||
|
barrierDismissible: false,
|
||||||
|
builder: (context) {
|
||||||
|
return MihAppAlert(
|
||||||
|
alertIcon: Icon(
|
||||||
|
Icons.favorite_border,
|
||||||
|
color: MzanziInnovationHub.of(context)!.theme.secondaryColor(),
|
||||||
|
size: 100,
|
||||||
|
),
|
||||||
|
alertTitle: "Remove From Favourites",
|
||||||
|
alertBody: Column(
|
||||||
|
children: [
|
||||||
|
Text(
|
||||||
|
"Are you sure you want to remove this card from your favourites?",
|
||||||
|
style: TextStyle(
|
||||||
|
fontSize: 20,
|
||||||
|
color:
|
||||||
|
MzanziInnovationHub.of(context)!.theme.secondaryColor(),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
const SizedBox(
|
||||||
|
height: 15,
|
||||||
|
),
|
||||||
|
SizedBox(
|
||||||
|
width: 300,
|
||||||
|
height: 50,
|
||||||
|
child: MIHButton(
|
||||||
|
onTap: () {
|
||||||
|
MIHMzansiWalletApis.updateLoyaltyCardAPICall(
|
||||||
|
widget.signedInUser,
|
||||||
|
widget.cardList[index].idloyalty_cards,
|
||||||
|
"",
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
ctxt,
|
||||||
|
);
|
||||||
|
},
|
||||||
|
buttonText: "Remove",
|
||||||
|
buttonColor:
|
||||||
|
MzanziInnovationHub.of(context)!.theme.secondaryColor(),
|
||||||
|
textColor:
|
||||||
|
MzanziInnovationHub.of(context)!.theme.primaryColor(),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
alertColour: MzanziInnovationHub.of(context)!.theme.secondaryColor(),
|
||||||
|
);
|
||||||
|
},
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
void viewCardWindow(int index) {
|
void viewCardWindow(int index) {
|
||||||
//print(widget.cardList[index].card_number);
|
//print(widget.cardList[index].card_number);
|
||||||
String formattedCardNumber = "";
|
String formattedCardNumber = "";
|
||||||
@@ -54,10 +170,11 @@ class _BuildLoyaltyCardListState extends State<BuildLoyaltyCardList> {
|
|||||||
showDialog(
|
showDialog(
|
||||||
context: context,
|
context: context,
|
||||||
barrierDismissible: false,
|
barrierDismissible: false,
|
||||||
builder: (context) => MIHWindow(
|
builder: (context) => MihAppWindow(
|
||||||
fullscreen: false,
|
fullscreen: false,
|
||||||
windowTitle: widget.cardList[index].shop_name.toUpperCase(),
|
windowTitle: widget.cardList[index].shop_name.toUpperCase(),
|
||||||
windowTools: [
|
windowTools: Row(
|
||||||
|
children: [
|
||||||
IconButton(
|
IconButton(
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
deleteCardWindow(context, index);
|
deleteCardWindow(context, index);
|
||||||
@@ -67,11 +184,39 @@ class _BuildLoyaltyCardListState extends State<BuildLoyaltyCardList> {
|
|||||||
color: MzanziInnovationHub.of(context)!.theme.secondaryColor(),
|
color: MzanziInnovationHub.of(context)!.theme.secondaryColor(),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
Visibility(
|
||||||
|
visible: widget.cardList[index].favourite == "",
|
||||||
|
child: IconButton(
|
||||||
|
onPressed: () {
|
||||||
|
addToFavCardWindow(context, index);
|
||||||
|
},
|
||||||
|
icon: Icon(
|
||||||
|
Icons.favorite,
|
||||||
|
color:
|
||||||
|
MzanziInnovationHub.of(context)!.theme.secondaryColor(),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
Visibility(
|
||||||
|
visible: widget.cardList[index].favourite != "",
|
||||||
|
child: IconButton(
|
||||||
|
onPressed: () {
|
||||||
|
removeFromFavCardWindow(context, index);
|
||||||
|
},
|
||||||
|
icon: Icon(
|
||||||
|
Icons.favorite_border,
|
||||||
|
color:
|
||||||
|
MzanziInnovationHub.of(context)!.theme.secondaryColor(),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
],
|
],
|
||||||
|
),
|
||||||
onWindowTapClose: () {
|
onWindowTapClose: () {
|
||||||
Navigator.pop(context);
|
Navigator.pop(context);
|
||||||
},
|
},
|
||||||
windowBody: [
|
windowBody: Column(
|
||||||
|
children: [
|
||||||
Container(
|
Container(
|
||||||
child: MihCardDisplay(
|
child: MihCardDisplay(
|
||||||
shopName: widget.cardList[index].shop_name, height: 250),
|
shopName: widget.cardList[index].shop_name, height: 250),
|
||||||
@@ -123,6 +268,7 @@ class _BuildLoyaltyCardListState extends State<BuildLoyaltyCardList> {
|
|||||||
)
|
)
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -134,6 +280,24 @@ class _BuildLoyaltyCardListState extends State<BuildLoyaltyCardList> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int countFavourites() {
|
||||||
|
int count = 0;
|
||||||
|
for (var card in widget.cardList) {
|
||||||
|
if (card.favourite != "") {
|
||||||
|
count++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return count;
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
void initState() {
|
||||||
|
super.initState();
|
||||||
|
setState(() {
|
||||||
|
_noFavourites = countFavourites();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
final Size size = MediaQuery.sizeOf(context);
|
final Size size = MediaQuery.sizeOf(context);
|
||||||
|
|||||||
@@ -1,15 +1,18 @@
|
|||||||
import 'package:mzansi_innovation_hub/mih_components/mih_package_components/mih_app.dart';
|
import 'package:mzansi_innovation_hub/mih_components/mih_package_components/mih_app.dart';
|
||||||
import 'package:mzansi_innovation_hub/mih_components/mih_package_components/mih_app_action.dart';
|
import 'package:mzansi_innovation_hub/mih_components/mih_package_components/mih_app_action.dart';
|
||||||
import 'package:mzansi_innovation_hub/mih_components/mih_package_components/mih_app_tools.dart';
|
import 'package:mzansi_innovation_hub/mih_components/mih_package_components/mih_app_tools.dart';
|
||||||
import 'package:mzansi_innovation_hub/mih_objects/app_user.dart';
|
import 'package:mzansi_innovation_hub/mih_objects/arguments.dart';
|
||||||
|
import 'package:mzansi_innovation_hub/mih_packages/mzansi_wallet/package_tools/mih_card_favourites.dart';
|
||||||
import 'package:mzansi_innovation_hub/mih_packages/mzansi_wallet/package_tools/mih_cards.dart';
|
import 'package:mzansi_innovation_hub/mih_packages/mzansi_wallet/package_tools/mih_cards.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
class MihWallet extends StatefulWidget {
|
class MihWallet extends StatefulWidget {
|
||||||
final AppUser signedInUser;
|
final WalletArguments arguments;
|
||||||
|
// final AppUser signedInUser;
|
||||||
const MihWallet({
|
const MihWallet({
|
||||||
super.key,
|
super.key,
|
||||||
required this.signedInUser,
|
required this.arguments,
|
||||||
|
// required this.signedInUser,
|
||||||
});
|
});
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@@ -23,7 +26,7 @@ class _MihWalletState extends State<MihWallet> {
|
|||||||
void initState() {
|
void initState() {
|
||||||
super.initState();
|
super.initState();
|
||||||
setState(() {
|
setState(() {
|
||||||
_selcetedIndex = 0;
|
_selcetedIndex = widget.arguments.index;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -56,11 +59,16 @@ class _MihWalletState extends State<MihWallet> {
|
|||||||
|
|
||||||
MihAppTools getTools() {
|
MihAppTools getTools() {
|
||||||
Map<Widget, void Function()?> temp = {};
|
Map<Widget, void Function()?> temp = {};
|
||||||
temp[const Icon(Icons.card_membership)] = () {
|
temp[const Icon(Icons.favorite)] = () {
|
||||||
setState(() {
|
setState(() {
|
||||||
_selcetedIndex = 0;
|
_selcetedIndex = 0;
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
temp[const Icon(Icons.card_membership)] = () {
|
||||||
|
setState(() {
|
||||||
|
_selcetedIndex = 1;
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
return MihAppTools(
|
return MihAppTools(
|
||||||
tools: temp,
|
tools: temp,
|
||||||
@@ -70,8 +78,11 @@ class _MihWalletState extends State<MihWallet> {
|
|||||||
|
|
||||||
List<Widget> getToolBody() {
|
List<Widget> getToolBody() {
|
||||||
List<Widget> toolBodies = [
|
List<Widget> toolBodies = [
|
||||||
|
MihCardFavourites(
|
||||||
|
signedInUser: widget.arguments.signedInUser,
|
||||||
|
),
|
||||||
MihCards(
|
MihCards(
|
||||||
signedInUser: widget.signedInUser,
|
signedInUser: widget.arguments.signedInUser,
|
||||||
),
|
),
|
||||||
];
|
];
|
||||||
return toolBodies;
|
return toolBodies;
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ import 'package:mzansi_innovation_hub/mih_components/mih_package_components/mih_
|
|||||||
import 'package:mzansi_innovation_hub/mih_objects/app_user.dart';
|
import 'package:mzansi_innovation_hub/mih_objects/app_user.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:font_awesome_flutter/font_awesome_flutter.dart';
|
import 'package:font_awesome_flutter/font_awesome_flutter.dart';
|
||||||
|
import 'package:mzansi_innovation_hub/mih_objects/arguments.dart';
|
||||||
|
|
||||||
class MihWalletTile extends StatefulWidget {
|
class MihWalletTile extends StatefulWidget {
|
||||||
final AppUser signedInUser;
|
final AppUser signedInUser;
|
||||||
@@ -25,7 +26,7 @@ class _MihWalletTileState extends State<MihWalletTile> {
|
|||||||
onTap: () {
|
onTap: () {
|
||||||
Navigator.of(context).pushNamed(
|
Navigator.of(context).pushNamed(
|
||||||
'/mzansi-wallet',
|
'/mzansi-wallet',
|
||||||
arguments: widget.signedInUser,
|
arguments: WalletArguments(widget.signedInUser, 0),
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
appName: "Mzansi Wallet",
|
appName: "Mzansi Wallet",
|
||||||
|
|||||||
@@ -0,0 +1,124 @@
|
|||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:mzansi_innovation_hub/main.dart';
|
||||||
|
import 'package:mzansi_innovation_hub/mih_apis/mih_mzansi_wallet_apis.dart';
|
||||||
|
import 'package:mzansi_innovation_hub/mih_components/mih_layout/mih_single_child_scroll.dart';
|
||||||
|
import 'package:mzansi_innovation_hub/mih_components/mih_package_components/mih-app_tool_body.dart';
|
||||||
|
import 'package:mzansi_innovation_hub/mih_components/mih_pop_up_messages/mih_loading_circle.dart';
|
||||||
|
import 'package:mzansi_innovation_hub/mih_objects/app_user.dart';
|
||||||
|
import 'package:mzansi_innovation_hub/mih_objects/loyalty_card.dart';
|
||||||
|
import 'package:mzansi_innovation_hub/mih_packages/mzansi_wallet/builder/build_loyalty_card_list.dart';
|
||||||
|
|
||||||
|
class MihCardFavourites extends StatefulWidget {
|
||||||
|
final AppUser signedInUser;
|
||||||
|
const MihCardFavourites({
|
||||||
|
super.key,
|
||||||
|
required this.signedInUser,
|
||||||
|
});
|
||||||
|
|
||||||
|
@override
|
||||||
|
State<MihCardFavourites> createState() => _MihCardFavouritesState();
|
||||||
|
}
|
||||||
|
|
||||||
|
class _MihCardFavouritesState extends State<MihCardFavourites> {
|
||||||
|
late Future<List<MIHLoyaltyCard>> cardList;
|
||||||
|
List<MIHLoyaltyCard> listOfCards = [];
|
||||||
|
|
||||||
|
@override
|
||||||
|
void initState() {
|
||||||
|
super.initState();
|
||||||
|
cardList = MIHMzansiWalletApis.getFavouriteLoyaltyCards(
|
||||||
|
widget.signedInUser.app_id,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return MihAppToolBody(
|
||||||
|
borderOn: true,
|
||||||
|
bodyItem: getBody(),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
Widget getBody() {
|
||||||
|
return Stack(
|
||||||
|
children: [
|
||||||
|
MihSingleChildScroll(
|
||||||
|
child: Column(
|
||||||
|
children: [
|
||||||
|
Row(
|
||||||
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
|
children: [
|
||||||
|
Text(
|
||||||
|
"Favourites",
|
||||||
|
textAlign: TextAlign.center,
|
||||||
|
style: TextStyle(
|
||||||
|
fontSize: 25,
|
||||||
|
fontWeight: FontWeight.bold,
|
||||||
|
color: MzanziInnovationHub.of(context)!
|
||||||
|
.theme
|
||||||
|
.secondaryColor(),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
Divider(
|
||||||
|
color: MzanziInnovationHub.of(context)!.theme.secondaryColor(),
|
||||||
|
),
|
||||||
|
FutureBuilder(
|
||||||
|
future: cardList,
|
||||||
|
builder: (context, snapshot) {
|
||||||
|
if (snapshot.connectionState == ConnectionState.waiting) {
|
||||||
|
return const Center(
|
||||||
|
child: Mihloadingcircle(),
|
||||||
|
);
|
||||||
|
} else if (snapshot.connectionState == ConnectionState.done &&
|
||||||
|
snapshot.hasData) {
|
||||||
|
listOfCards = snapshot.data!;
|
||||||
|
// searchShop();
|
||||||
|
return BuildLoyaltyCardList(
|
||||||
|
cardList: listOfCards,
|
||||||
|
signedInUser: widget.signedInUser,
|
||||||
|
navIndex: 0,
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
return const Center(
|
||||||
|
child: Text("Error Loading Loyalty Cards"),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
// Positioned(
|
||||||
|
// right: 0,
|
||||||
|
// bottom: 0,
|
||||||
|
// child: MihFloatingMenu(
|
||||||
|
// animatedIcon: AnimatedIcons.menu_close,
|
||||||
|
// children: [
|
||||||
|
// SpeedDialChild(
|
||||||
|
// child: Icon(
|
||||||
|
// Icons.add,
|
||||||
|
// color:
|
||||||
|
// MzanziInnovationHub.of(context)!.theme.primaryColor(),
|
||||||
|
// ),
|
||||||
|
// label: "Add Loyalty Card",
|
||||||
|
// labelBackgroundColor:
|
||||||
|
// MzanziInnovationHub.of(context)!.theme.successColor(),
|
||||||
|
// labelStyle: TextStyle(
|
||||||
|
// color:
|
||||||
|
// MzanziInnovationHub.of(context)!.theme.primaryColor(),
|
||||||
|
// fontWeight: FontWeight.bold,
|
||||||
|
// ),
|
||||||
|
// backgroundColor:
|
||||||
|
// MzanziInnovationHub.of(context)!.theme.successColor(),
|
||||||
|
// onTap: () {
|
||||||
|
// // addCardWindow(context);
|
||||||
|
// },
|
||||||
|
// )
|
||||||
|
// ]),
|
||||||
|
// )
|
||||||
|
],
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -201,6 +201,9 @@ class _MihCardsState extends State<MihCards> {
|
|||||||
widget.signedInUser.app_id,
|
widget.signedInUser.app_id,
|
||||||
shopController.text,
|
shopController.text,
|
||||||
cardNumberController.text,
|
cardNumberController.text,
|
||||||
|
"",
|
||||||
|
0,
|
||||||
|
1,
|
||||||
context,
|
context,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -314,6 +317,7 @@ class _MihCardsState extends State<MihCards> {
|
|||||||
return BuildLoyaltyCardList(
|
return BuildLoyaltyCardList(
|
||||||
cardList: searchShopName.value,
|
cardList: searchShopName.value,
|
||||||
signedInUser: widget.signedInUser,
|
signedInUser: widget.signedInUser,
|
||||||
|
navIndex: 1,
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -188,12 +188,12 @@ class RouteGenerator {
|
|||||||
|
|
||||||
// /mzansi wallet
|
// /mzansi wallet
|
||||||
case '/mzansi-wallet':
|
case '/mzansi-wallet':
|
||||||
if (args is AppUser) {
|
if (args is WalletArguments) {
|
||||||
//print("route generator: $args");
|
//print("route generator: $args");
|
||||||
return MaterialPageRoute(
|
return MaterialPageRoute(
|
||||||
settings: settings,
|
settings: settings,
|
||||||
builder: (_) => MihWallet(
|
builder: (_) => MihWallet(
|
||||||
signedInUser: args,
|
arguments: args,
|
||||||
),
|
),
|
||||||
// MzansiWallet(
|
// MzansiWallet(
|
||||||
// signedInUser: args,
|
// signedInUser: args,
|
||||||
|
|||||||
@@ -17,7 +17,13 @@ class MzansiWalletInsertRequest(BaseModel):
|
|||||||
app_id: str
|
app_id: str
|
||||||
shop_name: str
|
shop_name: str
|
||||||
card_number: str
|
card_number: str
|
||||||
|
favourite: str
|
||||||
|
priority_index: int
|
||||||
|
|
||||||
|
class MzansiWalletUpdateRequest(BaseModel):
|
||||||
|
idloyalty_cards: int
|
||||||
|
favourite: str
|
||||||
|
priority_index: int
|
||||||
# class patientNoteUpdateRequest(BaseModel):
|
# class patientNoteUpdateRequest(BaseModel):
|
||||||
# idpatient_notes: int
|
# idpatient_notes: int
|
||||||
# note_name: str
|
# note_name: str
|
||||||
@@ -39,6 +45,30 @@ async def read_all_loyalty_cards_by_app_id(app_id: str, session: SessionContaine
|
|||||||
"app_id": item[1],
|
"app_id": item[1],
|
||||||
"shop_name": item[2],
|
"shop_name": item[2],
|
||||||
"card_number": item[3],
|
"card_number": item[3],
|
||||||
|
"favourite": item[4],
|
||||||
|
"priority_index": item[5],
|
||||||
|
}
|
||||||
|
for item in cursor.fetchall()
|
||||||
|
]
|
||||||
|
cursor.close()
|
||||||
|
db.close()
|
||||||
|
return items
|
||||||
|
|
||||||
|
# Get List of favourite loyalty cards by user
|
||||||
|
@router.get("/mzasni-wallet/loyalty-cards/favourites/{app_id}", tags=["Mzansi Wallet"])
|
||||||
|
async def read_favourite_loyalty_cards_by_app_id(app_id: str, session: SessionContainer = Depends(verify_session())): # , session: SessionContainer = Depends(verify_session())
|
||||||
|
db = database.dbConnection.dbMzansiWalletConnect()
|
||||||
|
cursor = db.cursor()
|
||||||
|
query = "SELECT * FROM loyalty_cards where app_id = %s and favourite != '' ORDER BY priority_index Asc"
|
||||||
|
cursor.execute(query, (app_id,))
|
||||||
|
items = [
|
||||||
|
{
|
||||||
|
"idloyalty_cards": item[0],
|
||||||
|
"app_id": item[1],
|
||||||
|
"shop_name": item[2],
|
||||||
|
"card_number": item[3],
|
||||||
|
"favourite": item[4],
|
||||||
|
"priority_index": item[5],
|
||||||
}
|
}
|
||||||
for item in cursor.fetchall()
|
for item in cursor.fetchall()
|
||||||
]
|
]
|
||||||
@@ -76,11 +106,13 @@ async def insert_loyalty_card(itemRequest : MzansiWalletInsertRequest): #, sessi
|
|||||||
db = database.dbConnection.dbMzansiWalletConnect()
|
db = database.dbConnection.dbMzansiWalletConnect()
|
||||||
cursor = db.cursor()
|
cursor = db.cursor()
|
||||||
query = "insert into loyalty_cards "
|
query = "insert into loyalty_cards "
|
||||||
query += "(app_id, shop_name, card_number) "
|
query += "(app_id, shop_name, card_number, favourite, priority_index) "
|
||||||
query += "values (%s, %s, %s)"
|
query += "values (%s, %s, %s, %s, %s)"
|
||||||
notetData = (itemRequest.app_id,
|
notetData = (itemRequest.app_id,
|
||||||
itemRequest.shop_name,
|
itemRequest.shop_name,
|
||||||
itemRequest.card_number,
|
itemRequest.card_number,
|
||||||
|
itemRequest.favourite,
|
||||||
|
itemRequest.priority_index,
|
||||||
)
|
)
|
||||||
try:
|
try:
|
||||||
cursor.execute(query, notetData)
|
cursor.execute(query, notetData)
|
||||||
@@ -113,26 +145,25 @@ async def Delete_loyalty_card(itemRequest : LoyaltyCardDeleteRequest, session: S
|
|||||||
db.close()
|
db.close()
|
||||||
return {"message": "Successfully deleted Record"}
|
return {"message": "Successfully deleted Record"}
|
||||||
|
|
||||||
# Update Patient note on table
|
# Update on table
|
||||||
# @router.put("/notes/update/", tags="patients_notes")
|
@router.put("/mzasni-wallet/loyalty-cards/update/", tags=["Mzansi Wallet"])
|
||||||
# async def UpdatePatient(itemRequest : patientNoteUpdateRequest, session: SessionContainer = Depends(verify_session())):
|
async def UpdatePatient(itemRequest : MzansiWalletUpdateRequest, session: SessionContainer = Depends(verify_session())):
|
||||||
# today = date.today()
|
today = date.today()
|
||||||
# db = database.dbConnection.dbPatientManagerConnect()
|
db = database.dbConnection.dbMzansiWalletConnect()
|
||||||
# cursor = db.cursor()
|
cursor = db.cursor()
|
||||||
# query = "update patient_notes "
|
query = "update loyalty_cards "
|
||||||
# query += "set note_name=%s, note_text=%s, patient_id=%s, insert_date=%s "
|
query += "set favourite=%s, priority_index=%s "
|
||||||
# query += "where idpatient_notes=%s"
|
query += "where idloyalty_cards=%s"
|
||||||
# notetData = (itemRequest.note_name,
|
notetData = (itemRequest.favourite,
|
||||||
# itemRequest.note_text,
|
itemRequest.priority_index,
|
||||||
# itemRequest.patient_id,
|
itemRequest.idloyalty_cards,
|
||||||
# today,
|
)
|
||||||
# itemRequest.idpatient_notes)
|
try:
|
||||||
# try:
|
cursor.execute(query, notetData)
|
||||||
# cursor.execute(query, notetData)
|
except Exception as error:
|
||||||
# except Exception as error:
|
raise HTTPException(status_code=404, detail="Failed to Update Record")
|
||||||
# raise HTTPException(status_code=404, detail="Failed to Update Record")
|
#return {"query": query, "message": error}
|
||||||
# #return {"query": query, "message": error}
|
db.commit()
|
||||||
# db.commit()
|
cursor.close()
|
||||||
# cursor.close()
|
db.close()
|
||||||
# db.close()
|
return {"message": "Successfully Updated Record"}
|
||||||
# return {"message": "Successfully Updated Record"}
|
|
||||||
Reference in New Issue
Block a user