You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
151 lines
6.3 KiB
Dart
151 lines
6.3 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:flutter/rendering.dart';
|
|
import 'package:provider/provider.dart';
|
|
import 'package:test_sa/extensions/context_extension.dart';
|
|
import 'package:test_sa/extensions/int_extensions.dart';
|
|
import 'package:test_sa/extensions/string_extensions.dart';
|
|
import 'package:test_sa/extensions/text_extensions.dart';
|
|
import 'package:test_sa/extensions/widget_extensions.dart';
|
|
import 'package:test_sa/modules/cm_module/views/components/action_button/footer_action_button.dart';
|
|
import 'package:test_sa/modules/cx_module/chat/chat_rooms_page.dart';
|
|
import 'package:test_sa/new_views/app_style/app_color.dart';
|
|
import 'package:test_sa/new_views/common_widgets/app_filled_button.dart';
|
|
import 'package:test_sa/new_views/common_widgets/app_text_form_field.dart';
|
|
import 'package:test_sa/new_views/common_widgets/default_app_bar.dart';
|
|
|
|
import 'survey_provider.dart';
|
|
|
|
class SurveyPage extends StatefulWidget {
|
|
int moduleId;
|
|
int requestId;
|
|
int surveyId;
|
|
|
|
SurveyPage({Key? key, required this.moduleId, required this.requestId, required this.surveyId}) : super(key: key);
|
|
|
|
@override
|
|
_SurveyPageState createState() {
|
|
return _SurveyPageState();
|
|
}
|
|
}
|
|
|
|
class _SurveyPageState extends State<SurveyPage> {
|
|
int serviceSatisfiedRating = -1;
|
|
int serviceProvidedRating = -1;
|
|
String comments = "";
|
|
|
|
@override
|
|
void initState() {
|
|
super.initState();
|
|
getSurveyQuestion();
|
|
}
|
|
|
|
void getSurveyQuestion() {
|
|
Provider.of<SurveyProvider>(context, listen: false).getQuestionnaire(widget.surveyId);
|
|
}
|
|
|
|
@override
|
|
void dispose() {
|
|
super.dispose();
|
|
}
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return Scaffold(
|
|
backgroundColor: AppColor.neutral100,
|
|
appBar: const DefaultAppBar(title: "Survey"),
|
|
body: Column(
|
|
children: [
|
|
SingleChildScrollView(
|
|
padding: const EdgeInsets.all(16),
|
|
child: Column(
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
children: [
|
|
Text(
|
|
"How satisfied are you with our services?",
|
|
style: AppTextStyles.bodyText.copyWith(color: context.isDark ? AppColor.neutral10 : AppColor.neutral50),
|
|
),
|
|
12.height,
|
|
SizedBox(
|
|
height: 32,
|
|
child: ListView.separated(
|
|
itemBuilder: (cxt, index) => (serviceSatisfiedRating >= index ? 'star_filled'.toSvgAsset() : 'star_empty'.toSvgAsset()).onPress(() {
|
|
setState(() {
|
|
serviceSatisfiedRating = index;
|
|
});
|
|
}),
|
|
shrinkWrap: true,
|
|
physics: const NeverScrollableScrollPhysics(),
|
|
separatorBuilder: (cxt, index) => 8.width,
|
|
itemCount: 5,
|
|
scrollDirection: Axis.horizontal,
|
|
),
|
|
),
|
|
16.height,
|
|
Text(
|
|
"Was the service provided promptly by our engineer?",
|
|
style: AppTextStyles.bodyText.copyWith(color: context.isDark ? AppColor.neutral10 : AppColor.neutral50),
|
|
),
|
|
12.height,
|
|
SizedBox(
|
|
height: 32,
|
|
child: ListView.separated(
|
|
itemBuilder: (cxt, index) => (serviceProvidedRating >= index ? 'star_filled'.toSvgAsset() : 'star_empty'.toSvgAsset()).onPress(() {
|
|
setState(() {
|
|
serviceProvidedRating = index;
|
|
});
|
|
}),
|
|
shrinkWrap: true,
|
|
physics: const NeverScrollableScrollPhysics(),
|
|
separatorBuilder: (cxt, index) => 8.width,
|
|
itemCount: 5,
|
|
scrollDirection: Axis.horizontal,
|
|
),
|
|
),
|
|
16.height,
|
|
Text(
|
|
"Request Type",
|
|
style: AppTextStyles.bodyText.copyWith(color: context.isDark ? AppColor.neutral10 : AppColor.neutral50),
|
|
),
|
|
16.height,
|
|
AppTextFormField(
|
|
initialValue: "",
|
|
textInputType: TextInputType.multiline,
|
|
alignLabelWithHint: true,
|
|
labelText: "Additional Comments",
|
|
backgroundColor: AppColor.fieldBgColor(context),
|
|
style: TextStyle(fontWeight: FontWeight.w500, fontSize: context.isTablet() ? 16 : 12, color: context.isDark ? Colors.white : const Color(0xff3B3D4A)),
|
|
labelStyle: TextStyle(fontWeight: FontWeight.w500, fontSize: context.isTablet() ? 16 : 12, color: context.isDark ? Colors.white : const Color(0xff767676)),
|
|
floatingLabelStyle: TextStyle(fontWeight: FontWeight.w500, fontSize: context.isTablet() ? 16 : 12, color: context.isDark ? Colors.white : const Color(0xff3B3D4A)),
|
|
showShadow: false,
|
|
onChange: (value) {
|
|
comments = value;
|
|
},
|
|
),
|
|
],
|
|
).toShadowContainer(context, borderRadius: 20, showShadow: false))
|
|
.expanded,
|
|
FooterActionButton.footerContainer(
|
|
context: context,
|
|
child: AppFilledButton(
|
|
label: context.translation.submit,
|
|
buttonColor: AppColor.primary10,
|
|
onPressed: () {
|
|
if (serviceSatisfiedRating < 0) {
|
|
"Provide rate services satisfaction".showToast;
|
|
return;
|
|
}
|
|
if (serviceProvidedRating < 0) {
|
|
"Provide rate services provided by engineer".showToast;
|
|
return;
|
|
}
|
|
Navigator.push(context, MaterialPageRoute(builder: (context) => ChatRoomsPage()));
|
|
return;
|
|
},
|
|
),
|
|
),
|
|
],
|
|
),
|
|
);
|
|
}
|
|
}
|