2025-01-18 09:28:24 +00:00
|
|
|
import 'package:flutter/material.dart';
|
2025-01-25 08:19:02 +00:00
|
|
|
import 'package:flutter/services.dart'; // /* 숫자만 입력 위해 */
|
2025-01-18 09:28:24 +00:00
|
|
|
import 'package:http/http.dart' as http;
|
|
|
|
import 'dart:convert';
|
|
|
|
|
2025-01-25 08:19:02 +00:00
|
|
|
// Server API (서버 API)
|
2025-01-18 09:28:24 +00:00
|
|
|
import '../plugins/api.dart';
|
|
|
|
|
2025-01-25 08:19:02 +00:00
|
|
|
// Main Page (메인 페이지)
|
2025-01-18 09:28:24 +00:00
|
|
|
import '../views/room/main_page.dart';
|
|
|
|
|
2025-01-25 08:19:02 +00:00
|
|
|
// Alert modal dialog (알람 모달창)
|
2025-01-18 09:28:24 +00:00
|
|
|
import '../dialogs/response_dialog.dart';
|
|
|
|
|
|
|
|
class SurveyPage extends StatefulWidget {
|
|
|
|
final String nickname;
|
|
|
|
|
|
|
|
const SurveyPage({
|
|
|
|
Key? key,
|
|
|
|
required this.nickname,
|
|
|
|
}) : super(key: key);
|
|
|
|
|
|
|
|
@override
|
|
|
|
State<SurveyPage> createState() => _SurveyPageState();
|
|
|
|
}
|
|
|
|
|
|
|
|
class _SurveyPageState extends State<SurveyPage> {
|
2025-01-25 08:19:02 +00:00
|
|
|
int _currentIndex = 0;
|
2025-01-28 14:11:27 +00:00
|
|
|
/* 현재 페이지 인덱스 (0~5) */
|
2025-01-18 09:28:24 +00:00
|
|
|
|
|
|
|
List<String> _questions = [];
|
2025-01-28 14:11:27 +00:00
|
|
|
/* 전체 질문 목록 (이제 6개) */
|
2025-01-18 09:28:24 +00:00
|
|
|
List<String> _questionsOriginal = [];
|
2025-01-28 14:11:27 +00:00
|
|
|
/* 질문의 한글 원본 목록 (6개) */
|
2025-01-18 09:28:24 +00:00
|
|
|
|
2025-01-28 14:11:27 +00:00
|
|
|
// 변경 포인트: 5 -> 6개
|
|
|
|
final List<String?> _answers = List.filled(6, null, growable: false);
|
|
|
|
/* 사용자가 입력한 답변(6개) */
|
2025-01-18 09:28:24 +00:00
|
|
|
|
|
|
|
final Map<int, String> _selectedRadioValue = {};
|
2025-01-25 08:19:02 +00:00
|
|
|
/* 각 페이지별 라디오 선택 값 */
|
2025-01-18 09:28:24 +00:00
|
|
|
final Map<int, TextEditingController> _textControllers = {};
|
2025-01-25 08:19:02 +00:00
|
|
|
/* 각 페이지별 텍스트필드 컨트롤러 */
|
2025-01-18 09:28:24 +00:00
|
|
|
|
|
|
|
@override
|
|
|
|
void initState() {
|
|
|
|
super.initState();
|
|
|
|
|
|
|
|
_questions = [
|
2025-01-28 14:11:27 +00:00
|
|
|
"Q1. Which country do you live in, ${widget.nickname}?",
|
|
|
|
"Q2. How old are you, ${widget.nickname}?",
|
|
|
|
"Q3. What is your occupation, ${widget.nickname}?",
|
|
|
|
"Q4. How did you hear about ALLSCORE, ${widget.nickname}?",
|
|
|
|
"Q5. Where have you experienced ALLSCORE, ${widget.nickname}?",
|
|
|
|
"Q6. Do you plan to keep using ALLSCORE?",
|
2025-01-18 09:28:24 +00:00
|
|
|
];
|
|
|
|
|
2025-01-28 14:11:27 +00:00
|
|
|
// 한글 원본 질문도 6개
|
2025-01-18 09:28:24 +00:00
|
|
|
_questionsOriginal = [
|
2025-01-28 14:11:27 +00:00
|
|
|
"당신이 거주하는 국가는 어디인가요?",
|
2025-01-18 09:28:24 +00:00
|
|
|
"나이는 어떻게 되나요?",
|
|
|
|
"직업이 무엇인가요?",
|
|
|
|
"올스코어 앱을 어떻게 알게 됐나요?",
|
|
|
|
"올스코어 앱을 어디서 경험하셨나요?",
|
|
|
|
"올스코어를 계속 사용할 의사가 있나요?",
|
|
|
|
];
|
|
|
|
|
2025-01-28 14:11:27 +00:00
|
|
|
// 페이지마다 TextEditingController 초기화
|
2025-01-18 09:28:24 +00:00
|
|
|
for (int i = 0; i < _questions.length; i++) {
|
|
|
|
_textControllers[i] = TextEditingController();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@override
|
|
|
|
void dispose() {
|
2025-01-25 08:19:02 +00:00
|
|
|
// Dispose text controllers (텍스트 컨트롤러 정리)
|
2025-01-18 09:28:24 +00:00
|
|
|
for (var ctrl in _textControllers.values) {
|
|
|
|
ctrl.dispose();
|
|
|
|
}
|
|
|
|
super.dispose();
|
|
|
|
}
|
|
|
|
|
2025-01-25 08:19:02 +00:00
|
|
|
/// Exit the survey (설문 그만하기)
|
2025-01-18 09:28:24 +00:00
|
|
|
Future<void> _onExitSurvey() async {
|
|
|
|
Navigator.pushAndRemoveUntil(
|
|
|
|
context,
|
|
|
|
MaterialPageRoute(builder: (_) => const MainPage()),
|
|
|
|
(route) => false,
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2025-01-25 08:19:02 +00:00
|
|
|
/// Next button (다음 버튼)
|
2025-01-18 09:28:24 +00:00
|
|
|
void _onNext() {
|
|
|
|
if (!_validateCurrentPage()) {
|
|
|
|
ScaffoldMessenger.of(context).showSnackBar(
|
2025-01-28 14:11:27 +00:00
|
|
|
const SnackBar(content: Text('Please fill in all required fields.')),
|
2025-01-18 09:28:24 +00:00
|
|
|
);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (_currentIndex < _questions.length - 1) {
|
|
|
|
setState(() {
|
|
|
|
_currentIndex++;
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2025-01-25 08:19:02 +00:00
|
|
|
/// Previous button (이전 버튼)
|
2025-01-18 09:28:24 +00:00
|
|
|
void _onPrev() {
|
|
|
|
if (_currentIndex > 0) {
|
|
|
|
setState(() {
|
|
|
|
_currentIndex--;
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2025-01-25 08:19:02 +00:00
|
|
|
/// Submit (제출하기)
|
2025-01-18 09:28:24 +00:00
|
|
|
Future<void> _onSubmit() async {
|
|
|
|
if (!_validateCurrentPage()) {
|
|
|
|
ScaffoldMessenger.of(context).showSnackBar(
|
2025-01-28 14:11:27 +00:00
|
|
|
const SnackBar(content: Text('Please fill in all required fields.')),
|
2025-01-18 09:28:24 +00:00
|
|
|
);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
// body: {"QNA": ["질문1","답변1","질문2","답변2", ... ]}
|
|
|
|
final List<String> qnaList = [];
|
|
|
|
for (int i = 0; i < _questionsOriginal.length; i++) {
|
2025-01-28 14:11:27 +00:00
|
|
|
qnaList.add(_questionsOriginal[i]); // 한글 질문
|
|
|
|
qnaList.add(_answers[i] ?? ''); // 사용자 답변
|
2025-01-18 09:28:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
final requestBody = {
|
2025-01-22 10:51:36 +00:00
|
|
|
"QNA": qnaList,
|
2025-01-18 09:28:24 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
try {
|
|
|
|
final response = await Api.serverRequest(uri: '/survey/collect', body: requestBody);
|
|
|
|
if (response['result'] == 'OK') {
|
|
|
|
final resp = response['response'] ?? {};
|
|
|
|
if (resp['result'] == 'OK') {
|
2025-01-28 14:11:27 +00:00
|
|
|
// Survey submitted
|
2025-01-18 09:28:24 +00:00
|
|
|
ScaffoldMessenger.of(context).showSnackBar(
|
2025-01-28 14:11:27 +00:00
|
|
|
const SnackBar(content: Text('Your survey has been submitted. Thank you!')),
|
2025-01-25 08:19:02 +00:00
|
|
|
);
|
|
|
|
Navigator.pushAndRemoveUntil(
|
|
|
|
context,
|
|
|
|
MaterialPageRoute(builder: (_) => const MainPage()),
|
|
|
|
(route) => false,
|
2025-01-18 09:28:24 +00:00
|
|
|
);
|
|
|
|
} else {
|
2025-01-28 14:11:27 +00:00
|
|
|
showResponseDialog(context, 'Error', 'Failed to submit the survey.');
|
2025-01-18 09:28:24 +00:00
|
|
|
}
|
|
|
|
} else {
|
2025-01-28 14:11:27 +00:00
|
|
|
showResponseDialog(context, 'Error', 'Failed to submit the survey.');
|
2025-01-18 09:28:24 +00:00
|
|
|
}
|
|
|
|
} catch (e) {
|
2025-01-28 14:11:27 +00:00
|
|
|
showResponseDialog(context, 'Error', 'Failed to submit the survey.');
|
2025-01-18 09:28:24 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2025-01-25 08:19:02 +00:00
|
|
|
/// Validate current page input (현재 페이지 입력값이 유효한지 체크)
|
2025-01-18 09:28:24 +00:00
|
|
|
bool _validateCurrentPage() {
|
|
|
|
final index = _currentIndex;
|
|
|
|
String? answer;
|
|
|
|
|
|
|
|
switch (index) {
|
|
|
|
case 0:
|
2025-01-28 14:11:27 +00:00
|
|
|
// [새 질문] 거주 국가
|
|
|
|
final txtCountry = _textControllers[index]?.text.trim() ?? '';
|
|
|
|
if (txtCountry.isEmpty) {
|
2025-01-18 09:28:24 +00:00
|
|
|
return false;
|
|
|
|
}
|
2025-01-28 14:11:27 +00:00
|
|
|
answer = txtCountry;
|
2025-01-18 09:28:24 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case 1:
|
2025-01-28 14:11:27 +00:00
|
|
|
// Age (나이)
|
|
|
|
final txtAge = _textControllers[index]?.text.trim() ?? '';
|
|
|
|
if (txtAge.isEmpty) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
answer = '$txtAge yrs old';
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 2:
|
2025-01-25 08:19:02 +00:00
|
|
|
// Occupation (직업)
|
2025-01-18 09:28:24 +00:00
|
|
|
final selected = _selectedRadioValue[index];
|
|
|
|
if (selected == null || selected.isEmpty) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
answer = selected;
|
|
|
|
break;
|
|
|
|
|
2025-01-28 14:11:27 +00:00
|
|
|
case 3:
|
2025-01-25 08:19:02 +00:00
|
|
|
// How did you hear about ALLSCORE? (앱 알게된 경로)
|
2025-01-18 09:28:24 +00:00
|
|
|
final selected2 = _selectedRadioValue[index];
|
|
|
|
if (selected2 == null || selected2.isEmpty) {
|
|
|
|
return false;
|
|
|
|
}
|
2025-01-28 14:11:27 +00:00
|
|
|
if (selected2 == 'Others') {
|
2025-01-18 09:28:24 +00:00
|
|
|
final etc = _textControllers[index]?.text.trim() ?? '';
|
|
|
|
if (etc.isEmpty) {
|
|
|
|
return false;
|
|
|
|
}
|
2025-01-28 14:11:27 +00:00
|
|
|
answer = "Others($etc)";
|
2025-01-18 09:28:24 +00:00
|
|
|
} else {
|
|
|
|
answer = selected2;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
2025-01-28 14:11:27 +00:00
|
|
|
case 4:
|
|
|
|
// Where have you experienced ALLSCORE? (어디서 경험?)
|
2025-01-18 09:28:24 +00:00
|
|
|
final sel3 = _selectedRadioValue[index];
|
|
|
|
if (sel3 == null || sel3.isEmpty) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
answer = sel3;
|
|
|
|
break;
|
|
|
|
|
2025-01-28 14:11:27 +00:00
|
|
|
case 5:
|
2025-01-25 08:19:02 +00:00
|
|
|
// Will you continue using ALLSCORE? (계속 사용할 의사?)
|
2025-01-18 09:28:24 +00:00
|
|
|
final sel4 = _selectedRadioValue[index];
|
|
|
|
if (sel4 == null || sel4.isEmpty) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
final comment = _textControllers[index]?.text.trim() ?? '';
|
2025-01-28 14:11:27 +00:00
|
|
|
answer = sel4 + (comment.isNotEmpty ? " / comment: $comment" : "");
|
2025-01-18 09:28:24 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
_answers[index] = answer;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
final questionText = _questions[_currentIndex];
|
|
|
|
final pageNumber = _currentIndex + 1;
|
|
|
|
final totalPage = _questions.length;
|
|
|
|
|
|
|
|
return WillPopScope(
|
|
|
|
onWillPop: () async {
|
|
|
|
_onExitSurvey();
|
|
|
|
return false;
|
|
|
|
},
|
|
|
|
child: Scaffold(
|
|
|
|
appBar: AppBar(
|
2025-01-25 08:19:02 +00:00
|
|
|
leadingWidth: 120,
|
2025-01-18 09:28:24 +00:00
|
|
|
leading: TextButton(
|
|
|
|
onPressed: _onExitSurvey,
|
|
|
|
child: const Text(
|
2025-01-28 14:11:27 +00:00
|
|
|
'Stop Survey',
|
2025-01-18 09:28:24 +00:00
|
|
|
style: TextStyle(color: Colors.white),
|
|
|
|
),
|
|
|
|
),
|
2025-01-28 14:11:27 +00:00
|
|
|
title: Text('Survey ($pageNumber/$totalPage)'),
|
2025-01-18 09:28:24 +00:00
|
|
|
backgroundColor: Colors.black,
|
|
|
|
),
|
|
|
|
body: SingleChildScrollView(
|
|
|
|
child: Container(
|
|
|
|
alignment: Alignment.center,
|
|
|
|
padding: const EdgeInsets.all(16),
|
|
|
|
child: Column(
|
|
|
|
children: [
|
2025-01-28 14:11:27 +00:00
|
|
|
// 현재 페이지의 질문
|
2025-01-18 09:28:24 +00:00
|
|
|
Text(
|
|
|
|
questionText,
|
|
|
|
style: const TextStyle(fontSize: 18, fontWeight: FontWeight.bold),
|
|
|
|
textAlign: TextAlign.center,
|
|
|
|
),
|
|
|
|
const SizedBox(height: 24),
|
2025-01-28 14:11:27 +00:00
|
|
|
// 페이지별 UI
|
2025-01-18 09:28:24 +00:00
|
|
|
_buildSurveyPage(_currentIndex),
|
|
|
|
],
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
bottomNavigationBar: Container(
|
|
|
|
color: Colors.white,
|
|
|
|
padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 8),
|
|
|
|
child: Row(
|
|
|
|
children: [
|
|
|
|
if (_currentIndex > 0)
|
|
|
|
Expanded(
|
|
|
|
child: ElevatedButton(
|
|
|
|
style: ElevatedButton.styleFrom(backgroundColor: Colors.grey),
|
|
|
|
onPressed: _onPrev,
|
2025-01-28 14:11:27 +00:00
|
|
|
child: const Text('Previous'),
|
2025-01-18 09:28:24 +00:00
|
|
|
),
|
|
|
|
),
|
|
|
|
if (_currentIndex > 0) const SizedBox(width: 8),
|
|
|
|
Expanded(
|
|
|
|
child: ElevatedButton(
|
|
|
|
style: ElevatedButton.styleFrom(backgroundColor: Colors.black),
|
|
|
|
onPressed: (_currentIndex < totalPage - 1) ? _onNext : _onSubmit,
|
|
|
|
child: Text(
|
2025-01-28 14:11:27 +00:00
|
|
|
(_currentIndex < totalPage - 1) ? 'Next' : 'Submit',
|
2025-01-18 09:28:24 +00:00
|
|
|
style: const TextStyle(color: Colors.white),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
],
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2025-01-25 08:19:02 +00:00
|
|
|
/// Build UI for each page (페이지별 UI)
|
2025-01-18 09:28:24 +00:00
|
|
|
Widget _buildSurveyPage(int index) {
|
|
|
|
switch (index) {
|
|
|
|
case 0:
|
2025-01-28 14:11:27 +00:00
|
|
|
// [새 질문] 거주 국가
|
2025-01-18 09:28:24 +00:00
|
|
|
return Column(
|
|
|
|
children: [
|
2025-01-25 08:19:02 +00:00
|
|
|
const Text(
|
2025-01-28 14:11:27 +00:00
|
|
|
'(Please enter the country you live in.)',
|
2025-01-25 08:19:02 +00:00
|
|
|
textAlign: TextAlign.center,
|
|
|
|
),
|
2025-01-18 09:28:24 +00:00
|
|
|
const SizedBox(height: 16),
|
|
|
|
TextField(
|
|
|
|
controller: _textControllers[index],
|
2025-01-25 08:19:02 +00:00
|
|
|
textAlign: TextAlign.center,
|
2025-01-18 09:28:24 +00:00
|
|
|
decoration: const InputDecoration(
|
2025-01-28 14:11:27 +00:00
|
|
|
labelText: 'Your country',
|
2025-01-18 09:28:24 +00:00
|
|
|
border: OutlineInputBorder(),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
],
|
|
|
|
);
|
|
|
|
|
|
|
|
case 1:
|
2025-01-28 14:11:27 +00:00
|
|
|
// [기존] 나이 입력
|
|
|
|
return Column(
|
|
|
|
children: [
|
|
|
|
const Text(
|
|
|
|
'(e.g. Please enter your age in digits.)',
|
|
|
|
textAlign: TextAlign.center,
|
|
|
|
),
|
|
|
|
const SizedBox(height: 16),
|
|
|
|
TextField(
|
|
|
|
controller: _textControllers[index],
|
|
|
|
keyboardType: TextInputType.number,
|
|
|
|
inputFormatters: [FilteringTextInputFormatter.digitsOnly],
|
|
|
|
textAlign: TextAlign.center,
|
|
|
|
decoration: const InputDecoration(
|
|
|
|
labelText: 'Age',
|
|
|
|
border: OutlineInputBorder(),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
],
|
|
|
|
);
|
|
|
|
|
|
|
|
case 2:
|
|
|
|
// [기존] 직업
|
2025-01-25 08:19:02 +00:00
|
|
|
final jobs = [
|
2025-01-28 14:11:27 +00:00
|
|
|
'Student',
|
|
|
|
'Office Worker',
|
|
|
|
'Professional',
|
|
|
|
'Professor/Teacher',
|
|
|
|
'Technical',
|
|
|
|
'Government Official',
|
|
|
|
'Art/Sports',
|
|
|
|
'Others',
|
2025-01-25 08:19:02 +00:00
|
|
|
];
|
2025-01-18 09:28:24 +00:00
|
|
|
return Column(
|
|
|
|
mainAxisSize: MainAxisSize.min,
|
|
|
|
children: jobs.map((job) {
|
|
|
|
return RadioListTile<String>(
|
|
|
|
title: Text(job, textAlign: TextAlign.center),
|
|
|
|
value: job,
|
|
|
|
groupValue: _selectedRadioValue[index],
|
|
|
|
onChanged: (val) {
|
|
|
|
setState(() {
|
|
|
|
_selectedRadioValue[index] = val!;
|
|
|
|
});
|
|
|
|
},
|
|
|
|
);
|
|
|
|
}).toList(),
|
|
|
|
);
|
|
|
|
|
2025-01-28 14:11:27 +00:00
|
|
|
case 3:
|
|
|
|
// [기존] 앱 알게된 경로
|
2025-01-25 08:19:02 +00:00
|
|
|
final paths = [
|
2025-01-28 14:11:27 +00:00
|
|
|
'Friend/Acquaintance',
|
|
|
|
'Social Media',
|
|
|
|
'Blog/Online Review',
|
|
|
|
'School/Workplace',
|
|
|
|
'Others',
|
2025-01-25 08:19:02 +00:00
|
|
|
];
|
2025-01-18 09:28:24 +00:00
|
|
|
return Column(
|
|
|
|
mainAxisSize: MainAxisSize.min,
|
|
|
|
children: [
|
|
|
|
...paths.map((p) {
|
|
|
|
return RadioListTile<String>(
|
|
|
|
title: Text(p, textAlign: TextAlign.center),
|
|
|
|
value: p,
|
|
|
|
groupValue: _selectedRadioValue[index],
|
|
|
|
onChanged: (val) {
|
|
|
|
setState(() {
|
|
|
|
_selectedRadioValue[index] = val!;
|
|
|
|
});
|
|
|
|
},
|
|
|
|
);
|
|
|
|
}).toList(),
|
2025-01-28 14:11:27 +00:00
|
|
|
if (_selectedRadioValue[index] == 'Others')
|
2025-01-18 09:28:24 +00:00
|
|
|
Padding(
|
|
|
|
padding: const EdgeInsets.only(top: 8.0),
|
|
|
|
child: TextField(
|
|
|
|
controller: _textControllers[index],
|
|
|
|
textAlign: TextAlign.center,
|
|
|
|
decoration: const InputDecoration(
|
2025-01-28 14:11:27 +00:00
|
|
|
labelText: 'Please specify.',
|
2025-01-18 09:28:24 +00:00
|
|
|
border: OutlineInputBorder(),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
],
|
|
|
|
);
|
|
|
|
|
2025-01-28 14:11:27 +00:00
|
|
|
case 4:
|
|
|
|
// [기존] 어디서 경험?
|
2025-01-25 08:19:02 +00:00
|
|
|
final places = [
|
2025-01-28 14:11:27 +00:00
|
|
|
'With Family',
|
|
|
|
'With Friends',
|
|
|
|
'School (for education)',
|
|
|
|
'Work Club',
|
|
|
|
'Cafe or Public Space',
|
|
|
|
'Travel',
|
|
|
|
'Others',
|
2025-01-25 08:19:02 +00:00
|
|
|
];
|
2025-01-18 09:28:24 +00:00
|
|
|
return Column(
|
|
|
|
mainAxisSize: MainAxisSize.min,
|
|
|
|
children: places.map((pl) {
|
|
|
|
return RadioListTile<String>(
|
|
|
|
title: Text(pl, textAlign: TextAlign.center),
|
|
|
|
value: pl,
|
|
|
|
groupValue: _selectedRadioValue[index],
|
|
|
|
onChanged: (val) {
|
|
|
|
setState(() {
|
|
|
|
_selectedRadioValue[index] = val!;
|
|
|
|
});
|
|
|
|
},
|
|
|
|
);
|
|
|
|
}).toList(),
|
|
|
|
);
|
|
|
|
|
2025-01-28 14:11:27 +00:00
|
|
|
case 5:
|
|
|
|
// [기존] 계속 사용할 의사?
|
2025-01-18 09:28:24 +00:00
|
|
|
return Column(
|
|
|
|
mainAxisSize: MainAxisSize.min,
|
|
|
|
children: [
|
|
|
|
RadioListTile<String>(
|
2025-01-28 14:11:27 +00:00
|
|
|
title: const Text('Yes', textAlign: TextAlign.center),
|
|
|
|
value: 'Yes',
|
2025-01-18 09:28:24 +00:00
|
|
|
groupValue: _selectedRadioValue[index],
|
|
|
|
onChanged: (val) {
|
|
|
|
setState(() {
|
|
|
|
_selectedRadioValue[index] = val!;
|
|
|
|
});
|
|
|
|
},
|
|
|
|
),
|
|
|
|
RadioListTile<String>(
|
2025-01-28 14:11:27 +00:00
|
|
|
title: const Text('No', textAlign: TextAlign.center),
|
|
|
|
value: 'No',
|
2025-01-18 09:28:24 +00:00
|
|
|
groupValue: _selectedRadioValue[index],
|
|
|
|
onChanged: (val) {
|
|
|
|
setState(() {
|
|
|
|
_selectedRadioValue[index] = val!;
|
|
|
|
});
|
|
|
|
},
|
|
|
|
),
|
|
|
|
const SizedBox(height: 16),
|
2025-01-25 08:19:02 +00:00
|
|
|
const Text(
|
2025-01-28 14:11:27 +00:00
|
|
|
'If you have any additional comments, feel free to write them here.',
|
2025-01-25 08:19:02 +00:00
|
|
|
textAlign: TextAlign.center,
|
|
|
|
),
|
2025-01-18 09:28:24 +00:00
|
|
|
const SizedBox(height: 8),
|
|
|
|
TextField(
|
|
|
|
controller: _textControllers[index],
|
|
|
|
maxLines: 3,
|
|
|
|
textAlign: TextAlign.center,
|
|
|
|
decoration: const InputDecoration(
|
2025-01-28 14:11:27 +00:00
|
|
|
hintText: 'e.g. inconveniences, improvement ideas, etc.',
|
2025-01-18 09:28:24 +00:00
|
|
|
border: OutlineInputBorder(),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
],
|
|
|
|
);
|
|
|
|
|
|
|
|
default:
|
2025-01-28 14:11:27 +00:00
|
|
|
return const Text('Survey question error', textAlign: TextAlign.center);
|
2025-01-18 09:28:24 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|