2025-01-17 08:47:15 +00:00
|
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
|
import 'package:shared_preferences/shared_preferences.dart';
|
2025-01-18 09:28:24 +00:00
|
|
|
|
import '../survey/survey_page.dart';
|
2025-01-17 08:47:15 +00:00
|
|
|
|
|
2025-01-25 08:19:02 +00:00
|
|
|
|
/// Shows the survey modal (팝업(모달) 자체를 보여주는 함수)
|
2025-01-18 09:28:24 +00:00
|
|
|
|
Future<void> showSurveyDialog(BuildContext context, String nickname) async {
|
2025-01-17 08:47:15 +00:00
|
|
|
|
showDialog(
|
|
|
|
|
context: context,
|
|
|
|
|
barrierDismissible: false, // 바깥 영역 터치로 닫기 방지
|
2025-01-18 09:28:24 +00:00
|
|
|
|
builder: (_) => SurveyDialog(nickname: nickname),
|
2025-01-17 08:47:15 +00:00
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
2025-01-25 08:19:02 +00:00
|
|
|
|
/// The actual AlertDialog widget (실제 AlertDialog 형태의 위젯)
|
2025-01-17 08:47:15 +00:00
|
|
|
|
class SurveyDialog extends StatefulWidget {
|
2025-01-18 09:28:24 +00:00
|
|
|
|
final String nickname;
|
2025-01-25 08:19:02 +00:00
|
|
|
|
|
|
|
|
|
const SurveyDialog({
|
|
|
|
|
Key? key,
|
|
|
|
|
required this.nickname,
|
|
|
|
|
}) : super(key: key);
|
2025-01-17 08:47:15 +00:00
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
State<SurveyDialog> createState() => _SurveyDialogState();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
class _SurveyDialogState extends State<SurveyDialog> {
|
2025-01-25 08:19:02 +00:00
|
|
|
|
bool _todayNotSee = false;
|
|
|
|
|
// "오늘 하루 보지 않기" 체크 여부
|
2025-01-17 08:47:15 +00:00
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
|
return AlertDialog(
|
2025-01-25 08:19:02 +00:00
|
|
|
|
title: const Text('Survey Participation Notice'),
|
|
|
|
|
// '설문 참여 안내'
|
2025-01-17 08:47:15 +00:00
|
|
|
|
content: SingleChildScrollView(
|
|
|
|
|
child: Column(
|
|
|
|
|
mainAxisSize: MainAxisSize.min,
|
|
|
|
|
children: [
|
|
|
|
|
const Text(
|
2025-01-25 08:19:02 +00:00
|
|
|
|
'Hello, thank you for using the "ALLSCORE" app.\n\n'
|
|
|
|
|
'We have prepared a simple survey to provide better service.\n'
|
|
|
|
|
'Your participation will greatly help the app’s improvement!\n'
|
|
|
|
|
'(It takes about 1 minute.)'
|
|
|
|
|
// '안녕하세요, "올스코어" 앱을 이용해주셔서 감사합니다.\n\n'
|
|
|
|
|
// '더 나은 서비스 제공을 위해 간단한 설문조사를 준비했습니다.\n'
|
|
|
|
|
// '설문조사에 참여해주시면 앱 발전에 큰 도움이 됩니다!\n'
|
|
|
|
|
// '(약 1분 소요)'
|
2025-01-17 08:47:15 +00:00
|
|
|
|
),
|
|
|
|
|
const SizedBox(height: 16),
|
2025-01-25 08:19:02 +00:00
|
|
|
|
// "Today do not see again" checkbox ("오늘 하루 보지 않기" 체크박스)
|
2025-01-17 08:47:15 +00:00
|
|
|
|
Row(
|
|
|
|
|
children: [
|
|
|
|
|
Checkbox(
|
|
|
|
|
value: _todayNotSee,
|
|
|
|
|
onChanged: (val) {
|
|
|
|
|
setState(() {
|
|
|
|
|
_todayNotSee = val ?? false;
|
|
|
|
|
});
|
|
|
|
|
},
|
|
|
|
|
),
|
2025-01-25 08:19:02 +00:00
|
|
|
|
const Text('Do not show again today'),
|
|
|
|
|
// '오늘 하루 보지 않기'
|
2025-01-17 08:47:15 +00:00
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
actions: [
|
2025-01-25 08:19:02 +00:00
|
|
|
|
// "Close" button ("닫기" 버튼)
|
2025-01-17 08:47:15 +00:00
|
|
|
|
TextButton(
|
|
|
|
|
onPressed: () async {
|
2025-01-25 08:19:02 +00:00
|
|
|
|
// If "Do not show again today" is checked, store in SharedPreferences
|
|
|
|
|
// (오늘 하루 보지 않기를 체크했다면, SharedPreferences 저장)
|
2025-01-17 08:47:15 +00:00
|
|
|
|
if (_todayNotSee) {
|
|
|
|
|
final prefs = await SharedPreferences.getInstance();
|
2025-01-25 08:19:02 +00:00
|
|
|
|
// e.g. survey_popup_today = 'Y'
|
2025-01-17 08:47:15 +00:00
|
|
|
|
await prefs.setString('survey_popup_today', 'Y');
|
|
|
|
|
}
|
2025-01-25 08:19:02 +00:00
|
|
|
|
Navigator.pop(context); // close popup (팝업 닫기)
|
2025-01-17 08:47:15 +00:00
|
|
|
|
},
|
|
|
|
|
style: TextButton.styleFrom(backgroundColor: Colors.grey),
|
2025-01-25 08:19:02 +00:00
|
|
|
|
child: const Text(
|
|
|
|
|
'Close',
|
|
|
|
|
// '닫기'
|
|
|
|
|
style: TextStyle(color: Colors.white),
|
|
|
|
|
),
|
2025-01-17 08:47:15 +00:00
|
|
|
|
),
|
2025-01-25 08:19:02 +00:00
|
|
|
|
// "Participate in Survey" button ("설문 참여" 버튼)
|
2025-01-17 08:47:15 +00:00
|
|
|
|
TextButton(
|
|
|
|
|
onPressed: () async {
|
2025-01-25 08:19:02 +00:00
|
|
|
|
// If "Do not show again today" is checked, store in SharedPreferences
|
|
|
|
|
// (오늘 하루 보지 않기를 체크했다면, SharedPreferences 저장)
|
2025-01-17 08:47:15 +00:00
|
|
|
|
if (_todayNotSee) {
|
|
|
|
|
final prefs = await SharedPreferences.getInstance();
|
|
|
|
|
await prefs.setString('survey_popup_today', 'Y');
|
|
|
|
|
}
|
2025-01-25 08:19:02 +00:00
|
|
|
|
Navigator.pop(context); // close popup (팝업 닫고)
|
|
|
|
|
// Navigate to the temporary survey page (임시 설문 페이지로 이동)
|
2025-01-17 08:47:15 +00:00
|
|
|
|
Navigator.push(
|
|
|
|
|
context,
|
2025-01-18 09:28:24 +00:00
|
|
|
|
MaterialPageRoute(builder: (_) => SurveyPage(nickname: widget.nickname)),
|
2025-01-17 08:47:15 +00:00
|
|
|
|
);
|
|
|
|
|
},
|
|
|
|
|
style: TextButton.styleFrom(backgroundColor: Colors.black),
|
2025-01-25 08:19:02 +00:00
|
|
|
|
child: const Text(
|
|
|
|
|
'Participate in Survey',
|
|
|
|
|
// '설문 참여'
|
|
|
|
|
style: TextStyle(color: Colors.white),
|
|
|
|
|
),
|
2025-01-17 08:47:15 +00:00
|
|
|
|
),
|
|
|
|
|
],
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
}
|