pull rate on revierw
This commit is contained in:
@@ -2,14 +2,18 @@ import 'package:custom_rating_bar/custom_rating_bar.dart';
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_speed_dial/flutter_speed_dial.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_objects/business_review.dart';
|
||||||
import 'package:mzansi_innovation_hub/mih_components/mih_package_components/mih_button.dart';
|
import 'package:mzansi_innovation_hub/mih_components/mih_package_components/mih_button.dart';
|
||||||
import 'package:mzansi_innovation_hub/mih_components/mih_package_components/mih_form.dart';
|
import 'package:mzansi_innovation_hub/mih_components/mih_package_components/mih_form.dart';
|
||||||
import 'package:mzansi_innovation_hub/mih_components/mih_package_components/mih_package_alert.dart';
|
import 'package:mzansi_innovation_hub/mih_components/mih_package_components/mih_package_alert.dart';
|
||||||
import 'package:mzansi_innovation_hub/mih_components/mih_package_components/mih_package_window.dart';
|
import 'package:mzansi_innovation_hub/mih_components/mih_package_components/mih_package_window.dart';
|
||||||
import 'package:mzansi_innovation_hub/mih_components/mih_package_components/mih_single_child_scroll.dart';
|
import 'package:mzansi_innovation_hub/mih_components/mih_package_components/mih_single_child_scroll.dart';
|
||||||
import 'package:mzansi_innovation_hub/mih_components/mih_package_components/mih_text_form_field.dart';
|
import 'package:mzansi_innovation_hub/mih_components/mih_package_components/mih_text_form_field.dart';
|
||||||
|
import 'package:mzansi_innovation_hub/mih_components/mih_pop_up_messages/mih_loading_circle.dart';
|
||||||
import 'package:mzansi_innovation_hub/mih_services/mih_alert_services.dart';
|
import 'package:mzansi_innovation_hub/mih_services/mih_alert_services.dart';
|
||||||
|
import 'package:mzansi_innovation_hub/mih_services/mih_mzansi_directory_services.dart';
|
||||||
import 'package:mzansi_innovation_hub/mih_services/mih_validation_services.dart';
|
import 'package:mzansi_innovation_hub/mih_services/mih_validation_services.dart';
|
||||||
|
import 'package:supertokens_flutter/supertokens.dart';
|
||||||
import 'package:url_launcher/url_launcher.dart';
|
import 'package:url_launcher/url_launcher.dart';
|
||||||
|
|
||||||
class MihBusinessCard extends StatefulWidget {
|
class MihBusinessCard extends StatefulWidget {
|
||||||
@@ -40,6 +44,7 @@ class MihBusinessCard extends StatefulWidget {
|
|||||||
class _MihBusinessCardState extends State<MihBusinessCard> {
|
class _MihBusinessCardState extends State<MihBusinessCard> {
|
||||||
final _formKey = GlobalKey<FormState>();
|
final _formKey = GlobalKey<FormState>();
|
||||||
final TextEditingController _reviewTitleController = TextEditingController();
|
final TextEditingController _reviewTitleController = TextEditingController();
|
||||||
|
final TextEditingController _reviewScoreController = TextEditingController();
|
||||||
final TextEditingController _reviewDescriptionController =
|
final TextEditingController _reviewDescriptionController =
|
||||||
TextEditingController();
|
TextEditingController();
|
||||||
late final VoidCallback _reviewDescriptionListener;
|
late final VoidCallback _reviewDescriptionListener;
|
||||||
@@ -341,6 +346,14 @@ class _MihBusinessCardState extends State<MihBusinessCard> {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Future<BusinessReview?> getUserReview() async {
|
||||||
|
String user_id = await SuperTokens.getUserId();
|
||||||
|
return await MihMzansiDirectoryServices().getUserReviewOfBusiness(
|
||||||
|
user_id,
|
||||||
|
widget.businessid,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void dispose() {
|
void dispose() {
|
||||||
super.dispose();
|
super.dispose();
|
||||||
@@ -520,33 +533,54 @@ class _MihBusinessCardState extends State<MihBusinessCard> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void businessReviewRatingWindow(bool previouslyRated, double width) {
|
Future<void> businessReviewRatingWindow(
|
||||||
|
bool previouslyRated, double width) async {
|
||||||
showDialog(
|
showDialog(
|
||||||
context: context,
|
context: context,
|
||||||
builder: (context) => MihPackageWindow(
|
builder: (context) => FutureBuilder(
|
||||||
|
future: getUserReview(),
|
||||||
|
builder: (context, asyncSnapshot) {
|
||||||
|
if (asyncSnapshot.connectionState == ConnectionState.waiting) {
|
||||||
|
return const Mihloadingcircle(
|
||||||
|
message: "Checking for previous reviews...",
|
||||||
|
);
|
||||||
|
} else if (asyncSnapshot.connectionState == ConnectionState.done &&
|
||||||
|
asyncSnapshot.hasData) {
|
||||||
|
_reviewTitleController.text =
|
||||||
|
asyncSnapshot.requireData!.rating_title;
|
||||||
|
_reviewDescriptionController.text =
|
||||||
|
asyncSnapshot.requireData!.rating_description;
|
||||||
|
_reviewScoreController.text =
|
||||||
|
asyncSnapshot.requireData!.rating_score;
|
||||||
|
return MihPackageWindow(
|
||||||
fullscreen: false,
|
fullscreen: false,
|
||||||
windowTitle: previouslyRated ? "Edit Review" : "Add Review",
|
windowTitle:
|
||||||
|
asyncSnapshot.hasData ? "Edit Review" : "Add Review",
|
||||||
onWindowTapClose: () {
|
onWindowTapClose: () {
|
||||||
Navigator.of(context).pop();
|
Navigator.of(context).pop();
|
||||||
},
|
},
|
||||||
menuOptions: previouslyRated
|
menuOptions: asyncSnapshot.hasData
|
||||||
? [
|
? [
|
||||||
SpeedDialChild(
|
SpeedDialChild(
|
||||||
child: Icon(
|
child: Icon(
|
||||||
Icons.delete,
|
Icons.delete,
|
||||||
color:
|
color: MzansiInnovationHub.of(context)!
|
||||||
MzansiInnovationHub.of(context)!.theme.primaryColor(),
|
.theme
|
||||||
|
.primaryColor(),
|
||||||
),
|
),
|
||||||
label: "Delete Review",
|
label: "Delete Review",
|
||||||
labelBackgroundColor:
|
labelBackgroundColor: MzansiInnovationHub.of(context)!
|
||||||
MzansiInnovationHub.of(context)!.theme.successColor(),
|
.theme
|
||||||
|
.successColor(),
|
||||||
labelStyle: TextStyle(
|
labelStyle: TextStyle(
|
||||||
color:
|
color: MzansiInnovationHub.of(context)!
|
||||||
MzansiInnovationHub.of(context)!.theme.primaryColor(),
|
.theme
|
||||||
|
.primaryColor(),
|
||||||
fontWeight: FontWeight.bold,
|
fontWeight: FontWeight.bold,
|
||||||
),
|
),
|
||||||
backgroundColor:
|
backgroundColor: MzansiInnovationHub.of(context)!
|
||||||
MzansiInnovationHub.of(context)!.theme.successColor(),
|
.theme
|
||||||
|
.successColor(),
|
||||||
onTap: () {
|
onTap: () {
|
||||||
// showTestWindow();
|
// showTestWindow();
|
||||||
showDeleteReviewAlert();
|
showDeleteReviewAlert();
|
||||||
@@ -557,7 +591,8 @@ class _MihBusinessCardState extends State<MihBusinessCard> {
|
|||||||
windowBody: MihSingleChildScroll(
|
windowBody: MihSingleChildScroll(
|
||||||
child: Padding(
|
child: Padding(
|
||||||
padding:
|
padding:
|
||||||
MzansiInnovationHub.of(context)!.theme.screenType == "desktop"
|
MzansiInnovationHub.of(context)!.theme.screenType ==
|
||||||
|
"desktop"
|
||||||
? EdgeInsets.symmetric(horizontal: width * 0.05)
|
? EdgeInsets.symmetric(horizontal: width * 0.05)
|
||||||
: EdgeInsets.symmetric(horizontal: width * 0),
|
: EdgeInsets.symmetric(horizontal: width * 0),
|
||||||
child: Column(
|
child: Column(
|
||||||
@@ -601,9 +636,17 @@ class _MihBusinessCardState extends State<MihBusinessCard> {
|
|||||||
.theme
|
.theme
|
||||||
.secondaryColor(),
|
.secondaryColor(),
|
||||||
isHalfAllowed: true,
|
isHalfAllowed: true,
|
||||||
initialRating: 1,
|
initialRating: asyncSnapshot.hasData
|
||||||
|
? double.parse(_reviewScoreController.text)
|
||||||
|
: 1,
|
||||||
maxRating: 5,
|
maxRating: 5,
|
||||||
onRatingChanged: (double) {},
|
onRatingChanged: (double) {
|
||||||
|
setState(() {
|
||||||
|
_reviewScoreController.text =
|
||||||
|
double.toStringAsFixed(1);
|
||||||
|
});
|
||||||
|
print(_reviewScoreController.text);
|
||||||
|
},
|
||||||
),
|
),
|
||||||
const SizedBox(height: 10),
|
const SizedBox(height: 10),
|
||||||
MihTextFormField(
|
MihTextFormField(
|
||||||
@@ -611,8 +654,9 @@ class _MihBusinessCardState extends State<MihBusinessCard> {
|
|||||||
fillColor: MzansiInnovationHub.of(context)!
|
fillColor: MzansiInnovationHub.of(context)!
|
||||||
.theme
|
.theme
|
||||||
.secondaryColor(),
|
.secondaryColor(),
|
||||||
inputColor:
|
inputColor: MzansiInnovationHub.of(context)!
|
||||||
MzansiInnovationHub.of(context)!.theme.primaryColor(),
|
.theme
|
||||||
|
.primaryColor(),
|
||||||
controller: _reviewTitleController,
|
controller: _reviewTitleController,
|
||||||
multiLineInput: false,
|
multiLineInput: false,
|
||||||
requiredText: true,
|
requiredText: true,
|
||||||
@@ -628,8 +672,9 @@ class _MihBusinessCardState extends State<MihBusinessCard> {
|
|||||||
fillColor: MzansiInnovationHub.of(context)!
|
fillColor: MzansiInnovationHub.of(context)!
|
||||||
.theme
|
.theme
|
||||||
.secondaryColor(),
|
.secondaryColor(),
|
||||||
inputColor:
|
inputColor: MzansiInnovationHub.of(context)!
|
||||||
MzansiInnovationHub.of(context)!.theme.primaryColor(),
|
.theme
|
||||||
|
.primaryColor(),
|
||||||
controller: _reviewDescriptionController,
|
controller: _reviewDescriptionController,
|
||||||
multiLineInput: true,
|
multiLineInput: true,
|
||||||
requiredText: false,
|
requiredText: false,
|
||||||
@@ -647,8 +692,8 @@ class _MihBusinessCardState extends State<MihBusinessCard> {
|
|||||||
height: 15,
|
height: 15,
|
||||||
child: ValueListenableBuilder(
|
child: ValueListenableBuilder(
|
||||||
valueListenable: _counter,
|
valueListenable: _counter,
|
||||||
builder:
|
builder: (BuildContext context, int value,
|
||||||
(BuildContext context, int value, Widget? child) {
|
Widget? child) {
|
||||||
return Row(
|
return Row(
|
||||||
mainAxisSize: MainAxisSize.max,
|
mainAxisSize: MainAxisSize.max,
|
||||||
mainAxisAlignment: MainAxisAlignment.end,
|
mainAxisAlignment: MainAxisAlignment.end,
|
||||||
@@ -656,7 +701,8 @@ class _MihBusinessCardState extends State<MihBusinessCard> {
|
|||||||
Text(
|
Text(
|
||||||
"$value",
|
"$value",
|
||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
color: getMissionVisionLimitColor(256),
|
color:
|
||||||
|
getMissionVisionLimitColor(256),
|
||||||
fontWeight: FontWeight.bold,
|
fontWeight: FontWeight.bold,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
@@ -664,7 +710,8 @@ class _MihBusinessCardState extends State<MihBusinessCard> {
|
|||||||
Text(
|
Text(
|
||||||
"/256",
|
"/256",
|
||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
color: getMissionVisionLimitColor(256),
|
color:
|
||||||
|
getMissionVisionLimitColor(256),
|
||||||
fontWeight: FontWeight.bold,
|
fontWeight: FontWeight.bold,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
@@ -680,7 +727,8 @@ class _MihBusinessCardState extends State<MihBusinessCard> {
|
|||||||
if (_formKey.currentState!.validate()) {
|
if (_formKey.currentState!.validate()) {
|
||||||
// submitForm();
|
// submitForm();
|
||||||
} else {
|
} else {
|
||||||
MihAlertServices().formNotFilledCompletely(context);
|
MihAlertServices()
|
||||||
|
.formNotFilledCompletely(context);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
buttonColor: MzansiInnovationHub.of(context)!
|
buttonColor: MzansiInnovationHub.of(context)!
|
||||||
@@ -688,7 +736,9 @@ class _MihBusinessCardState extends State<MihBusinessCard> {
|
|||||||
.successColor(),
|
.successColor(),
|
||||||
width: 300,
|
width: 300,
|
||||||
child: Text(
|
child: Text(
|
||||||
"Add Review",
|
asyncSnapshot.hasData
|
||||||
|
? "Edit Review"
|
||||||
|
: "Add Review",
|
||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
color: MzansiInnovationHub.of(context)!
|
color: MzansiInnovationHub.of(context)!
|
||||||
.theme
|
.theme
|
||||||
@@ -705,7 +755,33 @@ class _MihBusinessCardState extends State<MihBusinessCard> {
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
return MihPackageAlert(
|
||||||
|
alertColour:
|
||||||
|
MzansiInnovationHub.of(context)!.theme.errorColor(),
|
||||||
|
alertIcon: Icon(
|
||||||
|
Icons.warning_rounded,
|
||||||
|
size: 100,
|
||||||
|
color: MzansiInnovationHub.of(context)!.theme.errorColor(),
|
||||||
),
|
),
|
||||||
|
alertTitle: "Error Pulling Data",
|
||||||
|
alertBody: Column(
|
||||||
|
children: [
|
||||||
|
Text(
|
||||||
|
"Please ensure you are connectede top the internet and you are running the latest version of MIH then try again.",
|
||||||
|
style: TextStyle(
|
||||||
|
color: MzansiInnovationHub.of(context)!
|
||||||
|
.theme
|
||||||
|
.secondaryColor(),
|
||||||
|
fontSize: 15,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -733,12 +809,27 @@ class _MihBusinessCardState extends State<MihBusinessCard> {
|
|||||||
),
|
),
|
||||||
const SizedBox(height: 25),
|
const SizedBox(height: 25),
|
||||||
Wrap(
|
Wrap(
|
||||||
runAlignment: WrapAlignment.center,
|
|
||||||
spacing: 10,
|
spacing: 10,
|
||||||
runSpacing: 10,
|
runSpacing: 10,
|
||||||
alignment: WrapAlignment.center,
|
|
||||||
crossAxisAlignment: WrapCrossAlignment.center,
|
|
||||||
children: [
|
children: [
|
||||||
|
MihButton(
|
||||||
|
width: 300,
|
||||||
|
onPressed: () {
|
||||||
|
Navigator.of(context).pop();
|
||||||
|
},
|
||||||
|
buttonColor:
|
||||||
|
MzansiInnovationHub.of(context)!.theme.errorColor(),
|
||||||
|
child: Text(
|
||||||
|
"Delete",
|
||||||
|
style: TextStyle(
|
||||||
|
color: MzansiInnovationHub.of(context)!
|
||||||
|
.theme
|
||||||
|
.primaryColor(),
|
||||||
|
fontSize: 20,
|
||||||
|
fontWeight: FontWeight.bold,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
MihButton(
|
MihButton(
|
||||||
width: 300,
|
width: 300,
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
@@ -753,30 +844,13 @@ class _MihBusinessCardState extends State<MihBusinessCard> {
|
|||||||
color: MzansiInnovationHub.of(context)!
|
color: MzansiInnovationHub.of(context)!
|
||||||
.theme
|
.theme
|
||||||
.primaryColor(),
|
.primaryColor(),
|
||||||
fontSize: 18,
|
fontSize: 20,
|
||||||
|
fontWeight: FontWeight.bold,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
MihButton(
|
|
||||||
width: 300,
|
|
||||||
onPressed: () {
|
|
||||||
// Delete review logic here
|
|
||||||
Navigator.of(context).pop();
|
|
||||||
},
|
|
||||||
buttonColor:
|
|
||||||
MzansiInnovationHub.of(context)!.theme.errorColor(),
|
|
||||||
child: Text(
|
|
||||||
"Delete",
|
|
||||||
style: TextStyle(
|
|
||||||
color: MzansiInnovationHub.of(context)!
|
|
||||||
.theme
|
|
||||||
.primaryColor(),
|
|
||||||
fontSize: 18,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
));
|
));
|
||||||
|
|||||||
Reference in New Issue
Block a user