116 lines
4.2 KiB
Dart
116 lines
4.2 KiB
Dart
import 'package:flutter/material.dart';
|
||
import 'package:shared_preferences/shared_preferences.dart';
|
||
import '../survey/survey_page.dart';
|
||
|
||
/// Shows the survey modal (팝업(모달) 자체를 보여주는 함수)
|
||
Future<void> showSurveyDialog(BuildContext context, String nickname) async {
|
||
showDialog(
|
||
context: context,
|
||
barrierDismissible: false, // 바깥 영역 터치로 닫기 방지
|
||
builder: (_) => SurveyDialog(nickname: nickname),
|
||
);
|
||
}
|
||
|
||
/// The actual AlertDialog widget (실제 AlertDialog 형태의 위젯)
|
||
class SurveyDialog extends StatefulWidget {
|
||
final String nickname;
|
||
|
||
const SurveyDialog({
|
||
Key? key,
|
||
required this.nickname,
|
||
}) : super(key: key);
|
||
|
||
@override
|
||
State<SurveyDialog> createState() => _SurveyDialogState();
|
||
}
|
||
|
||
class _SurveyDialogState extends State<SurveyDialog> {
|
||
bool _todayNotSee = false;
|
||
// "오늘 하루 보지 않기" 체크 여부
|
||
|
||
@override
|
||
Widget build(BuildContext context) {
|
||
return AlertDialog(
|
||
title: const Text('Survey Participation Notice'),
|
||
// '설문 참여 안내'
|
||
content: SingleChildScrollView(
|
||
child: Column(
|
||
mainAxisSize: MainAxisSize.min,
|
||
children: [
|
||
const Text(
|
||
'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분 소요)'
|
||
),
|
||
const SizedBox(height: 16),
|
||
// "Today do not see again" checkbox ("오늘 하루 보지 않기" 체크박스)
|
||
Row(
|
||
children: [
|
||
Checkbox(
|
||
value: _todayNotSee,
|
||
onChanged: (val) {
|
||
setState(() {
|
||
_todayNotSee = val ?? false;
|
||
});
|
||
},
|
||
),
|
||
const Text('Do not show again today'),
|
||
// '오늘 하루 보지 않기'
|
||
],
|
||
),
|
||
],
|
||
),
|
||
),
|
||
actions: [
|
||
// "Close" button ("닫기" 버튼)
|
||
TextButton(
|
||
onPressed: () async {
|
||
// If "Do not show again today" is checked, store in SharedPreferences
|
||
// (오늘 하루 보지 않기를 체크했다면, SharedPreferences 저장)
|
||
if (_todayNotSee) {
|
||
final prefs = await SharedPreferences.getInstance();
|
||
// e.g. survey_popup_today = 'Y'
|
||
await prefs.setString('survey_popup_today', 'Y');
|
||
}
|
||
Navigator.pop(context); // close popup (팝업 닫기)
|
||
},
|
||
style: TextButton.styleFrom(backgroundColor: Colors.grey),
|
||
child: const Text(
|
||
'Close',
|
||
// '닫기'
|
||
style: TextStyle(color: Colors.white),
|
||
),
|
||
),
|
||
// "Participate in Survey" button ("설문 참여" 버튼)
|
||
TextButton(
|
||
onPressed: () async {
|
||
// If "Do not show again today" is checked, store in SharedPreferences
|
||
// (오늘 하루 보지 않기를 체크했다면, SharedPreferences 저장)
|
||
if (_todayNotSee) {
|
||
final prefs = await SharedPreferences.getInstance();
|
||
await prefs.setString('survey_popup_today', 'Y');
|
||
}
|
||
Navigator.pop(context); // close popup (팝업 닫고)
|
||
// Navigate to the temporary survey page (임시 설문 페이지로 이동)
|
||
Navigator.push(
|
||
context,
|
||
MaterialPageRoute(builder: (_) => SurveyPage(nickname: widget.nickname)),
|
||
);
|
||
},
|
||
style: TextButton.styleFrom(backgroundColor: Colors.black),
|
||
child: const Text(
|
||
'Participate in Survey',
|
||
// '설문 참여'
|
||
style: TextStyle(color: Colors.white),
|
||
),
|
||
),
|
||
],
|
||
);
|
||
}
|
||
}
|