종료방 버그 해결, 진행중 이미지 버그 해결
This commit is contained in:
parent
e7f95cacf2
commit
1a46c4c085
@ -14,7 +14,7 @@ void showSettingsDialog(BuildContext context) {
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Container(
|
||||
width: MediaQuery.of(context).size.width * 0.2,
|
||||
width: MediaQuery.of(context).size.width * 0.1,
|
||||
child: const Text(
|
||||
'',
|
||||
// 공백 (디자인용)
|
||||
@ -26,7 +26,7 @@ void showSettingsDialog(BuildContext context) {
|
||||
),
|
||||
),
|
||||
Container(
|
||||
width: MediaQuery.of(context).size.width * 0.2,
|
||||
width: MediaQuery.of(context).size.width * 0.3,
|
||||
child: const Text(
|
||||
'Settings',
|
||||
// '설정'
|
||||
|
@ -56,10 +56,13 @@ class _FinishPrivatePageState extends State<FinishPrivatePage> {
|
||||
if (response['result'] == 'OK') {
|
||||
final resp = response['response'] ?? {};
|
||||
if (resp['result'] == 'OK') {
|
||||
final data = resp['data'] ?? {};
|
||||
final data = resp['data'] ?? {};
|
||||
|
||||
// (1) room_info
|
||||
final rInfo = data['room_info'] ?? {};
|
||||
final uInfo = data['user_info'] ?? {};
|
||||
|
||||
// (2) user_info는 List 형태로 받아오기
|
||||
final List<dynamic> uInfoList = data['user_info'] ?? [];
|
||||
|
||||
final rTitle = (rInfo['room_title'] ?? '') as String;
|
||||
final mSeq = (rInfo['master_user_seq'] ?? 0) as int;
|
||||
@ -68,9 +71,7 @@ class _FinishPrivatePageState extends State<FinishPrivatePage> {
|
||||
|
||||
setState(() {
|
||||
_roomInfo = rInfo;
|
||||
_userMap = uInfo;
|
||||
_roomTitle = rTitle.isNotEmpty ? rTitle : 'Finished Room (Solo)';
|
||||
// '종료된 방(개인전)'
|
||||
_masterUserSeq = mSeq.toString();
|
||||
|
||||
if (sdt != null && sdt is String && sdt.contains('T')) {
|
||||
@ -81,39 +82,35 @@ class _FinishPrivatePageState extends State<FinishPrivatePage> {
|
||||
}
|
||||
});
|
||||
|
||||
// Convert userInfo → list (userInfo -> List 변환)
|
||||
// (3) List로 변환
|
||||
final List<Map<String, dynamic>> tempList = [];
|
||||
uInfo.forEach((_, val) {
|
||||
// val: { user_seq, participant_type, nickname, score, ... }
|
||||
tempList.add(Map<String, dynamic>.from(val));
|
||||
});
|
||||
for (var item in uInfoList) {
|
||||
tempList.add(Map<String, dynamic>.from(item));
|
||||
}
|
||||
|
||||
final playerList = tempList.toList();
|
||||
|
||||
// Sort by score descending (점수 내림차순 정렬)
|
||||
playerList.sort((a, b) {
|
||||
// (4) 점수 내림차순 정렬
|
||||
tempList.sort((a, b) {
|
||||
final sa = (a['score'] ?? 0) as int;
|
||||
final sb = (b['score'] ?? 0) as int;
|
||||
return sb.compareTo(sa);
|
||||
});
|
||||
|
||||
// (5) 상태 갱신
|
||||
setState(() {
|
||||
_playerList = playerList;
|
||||
_isLoading = false;
|
||||
_playerList = tempList;
|
||||
_isLoading = false;
|
||||
});
|
||||
|
||||
} else {
|
||||
final msgTitle = resp['response_info']?['msg_title'] ?? 'Error'; // '오류'
|
||||
final msgContent = resp['response_info']?['msg_content'] ?? 'Failed to fetch data';
|
||||
// '데이터 조회 실패'
|
||||
final msgTitle = resp['response_info']?['msg_title'] ?? 'Error';
|
||||
final msgContent = resp['response_info']?['msg_content'] ?? 'Failed to fetch data';
|
||||
showResponseDialog(context, msgTitle, msgContent);
|
||||
}
|
||||
} else {
|
||||
showResponseDialog(context, 'Failed', 'Server communication error.');
|
||||
// '실패', '서버 통신 오류'
|
||||
showResponseDialog(context, 'Failed', 'Server communication error.');
|
||||
}
|
||||
} catch (e) {
|
||||
showResponseDialog(context, 'Error', '$e');
|
||||
// '오류'
|
||||
showResponseDialog(context, 'Error', '$e');
|
||||
} finally {
|
||||
setState(() => _isLoading = false);
|
||||
}
|
||||
|
@ -58,7 +58,7 @@ class _FinishTeamPageState extends State<FinishTeamPage> {
|
||||
if (resp['result'] == 'OK') {
|
||||
final data = resp['data'] ?? {};
|
||||
final rInfo = data['room_info'] ?? {};
|
||||
final uInfo = data['user_info'] ?? {};
|
||||
final List<dynamic> uInfoList = data['user_info'] ?? [];
|
||||
|
||||
final rTitle = (rInfo['room_title'] ?? '') as String;
|
||||
final mSeq = (rInfo['master_user_seq'] ?? 0) as int;
|
||||
@ -67,9 +67,7 @@ class _FinishTeamPageState extends State<FinishTeamPage> {
|
||||
|
||||
setState(() {
|
||||
_roomInfo = rInfo;
|
||||
_userMap = uInfo;
|
||||
_roomTitle = rTitle.isNotEmpty ? rTitle : 'Finished Team Game';
|
||||
// '종료된 팀전'
|
||||
_roomTitle = rTitle.isNotEmpty ? rTitle : 'Finished Team Game';
|
||||
_masterUserSeq = mSeq.toString();
|
||||
|
||||
if (sdt != null && sdt is String && sdt.contains('T')) {
|
||||
@ -80,12 +78,13 @@ class _FinishTeamPageState extends State<FinishTeamPage> {
|
||||
}
|
||||
});
|
||||
|
||||
// userList
|
||||
// user_info 처리 (List)
|
||||
final List<Map<String, dynamic>> tempList = [];
|
||||
uInfo.forEach((_, val) {
|
||||
tempList.add(Map<String, dynamic>.from(val));
|
||||
});
|
||||
for (var u in uInfoList) {
|
||||
tempList.add(Map<String, dynamic>.from(u));
|
||||
}
|
||||
|
||||
// 전체 플레이어
|
||||
final players = tempList.toList();
|
||||
|
||||
// (3) Separate by team + sum scores (팀명별 분류 + 점수 합)
|
||||
@ -99,10 +98,10 @@ class _FinishTeamPageState extends State<FinishTeamPage> {
|
||||
tMap[tName]!.add(user);
|
||||
}
|
||||
|
||||
// Calculate team scores (팀별 점수)
|
||||
// 팀별 점수 계산
|
||||
tMap.forEach((team, mems) {
|
||||
int sumScore = 0;
|
||||
// Sort each team's members by descending score (팀 멤버 점수 내림차순)
|
||||
// 팀 멤버를 점수 내림차순 정렬
|
||||
mems.sort((a, b) {
|
||||
final sa = (a['score'] ?? 0) as int;
|
||||
final sb = (b['score'] ?? 0) as int;
|
||||
@ -114,11 +113,10 @@ class _FinishTeamPageState extends State<FinishTeamPage> {
|
||||
tScoreMap[team] = sumScore;
|
||||
});
|
||||
|
||||
// (4) Sort teams by score (팀들을 점수순으로 정렬)
|
||||
// (4) 팀들을 점수 순으로 정렬
|
||||
final sortedTeams = tScoreMap.keys.toList();
|
||||
sortedTeams.sort((a, b) => tScoreMap[b]!.compareTo(tScoreMap[a]!));
|
||||
|
||||
// Put sorted results into a new map (정렬된 결과를 새 맵에)
|
||||
final Map<String, List<Map<String, dynamic>>> finalTeamMap = {};
|
||||
final Map<String, int> finalScoreMap = {};
|
||||
|
||||
@ -128,24 +126,21 @@ class _FinishTeamPageState extends State<FinishTeamPage> {
|
||||
}
|
||||
|
||||
setState(() {
|
||||
_userList = tempList; // Keep the entire list if needed
|
||||
_userList = tempList; // 전체 유저 리스트
|
||||
_teamMap = finalTeamMap;
|
||||
_teamScoreMap = finalScoreMap;
|
||||
_isLoading = false;
|
||||
});
|
||||
} else {
|
||||
final msgTitle = resp['response_info']?['msg_title'] ?? 'Error'; // '오류'
|
||||
final msgContent = resp['response_info']?['msg_content'] ?? 'Failed to fetch data';
|
||||
// '데이터 조회 실패'
|
||||
final msgTitle = resp['response_info']?['msg_title'] ?? 'Error';
|
||||
final msgContent = resp['response_info']?['msg_content'] ?? 'Failed to fetch data';
|
||||
showResponseDialog(context, msgTitle, msgContent);
|
||||
}
|
||||
} else {
|
||||
showResponseDialog(context, 'Failed', 'Server communication error.');
|
||||
// '실패', '서버 통신 오류'
|
||||
showResponseDialog(context, 'Failed', 'Server communication error.');
|
||||
}
|
||||
} catch (e) {
|
||||
showResponseDialog(context, 'Error', '$e');
|
||||
// '오류'
|
||||
showResponseDialog(context, 'Error', '$e');
|
||||
} finally {
|
||||
setState(() => _isLoading = false);
|
||||
}
|
||||
|
@ -41,6 +41,8 @@ class _MainPageState extends State<MainPage> {
|
||||
// e.g., if a second back press occurs within 2 seconds, exit the app (2초 이내로 두 번 누르면 종료)
|
||||
static const _exitDuration = Duration(seconds: 2);
|
||||
|
||||
double scaleFactor = 1.0;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
@ -60,6 +62,21 @@ class _MainPageState extends State<MainPage> {
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
@override
|
||||
void didChangeDependencies() {
|
||||
super.didChangeDependencies();
|
||||
_updateScaleFactor();
|
||||
}
|
||||
|
||||
// Adjust font size by screen width (화면 크기에 따라 폰트 크기 조절)
|
||||
void _updateScaleFactor() {
|
||||
final screenWidth = MediaQuery.of(context).size.width;
|
||||
const baseWidth = 400.0;
|
||||
setState(() {
|
||||
scaleFactor = (screenWidth / baseWidth).clamp(0.8, 1.4);
|
||||
});
|
||||
}
|
||||
|
||||
// On back press callback (뒤로가기 콜백)
|
||||
Future<bool> _onWillPop() async {
|
||||
final now = DateTime.now();
|
||||
@ -247,16 +264,23 @@ class _MainPageState extends State<MainPage> {
|
||||
required String label,
|
||||
required VoidCallback onTap,
|
||||
}) {
|
||||
return ElevatedButton(
|
||||
onPressed: onTap,
|
||||
style: ElevatedButton.styleFrom(
|
||||
backgroundColor: Colors.white, // 버튼 배경색
|
||||
foregroundColor: Colors.black, // 버튼 텍스트 색
|
||||
side: const BorderSide(color: Colors.black, width: 1),
|
||||
padding: const EdgeInsets.symmetric(vertical: 36, horizontal: 32),
|
||||
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(20)),
|
||||
return SizedBox(
|
||||
width: 100 * scaleFactor,
|
||||
height: 100 * scaleFactor,
|
||||
child: ElevatedButton(
|
||||
onPressed: onTap,
|
||||
style: ElevatedButton.styleFrom(
|
||||
backgroundColor: Colors.white,
|
||||
foregroundColor: Colors.black,
|
||||
side: const BorderSide(color: Colors.black, width: 1),
|
||||
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(20)),
|
||||
),
|
||||
child: Text(
|
||||
label,
|
||||
style: const TextStyle(color: Colors.black),
|
||||
textAlign: TextAlign.center,
|
||||
),
|
||||
),
|
||||
child: Text(label, style: const TextStyle(color: Colors.black)),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -165,6 +165,7 @@ class _PlayingTeamPageState extends State<PlayingTeamPage> {
|
||||
'nickname': uData['nickname'] ?? 'User', // '유저'
|
||||
'team_name': (uData['team_name'] ?? '').toString().toUpperCase(),
|
||||
'score': uData['score'] ?? 0,
|
||||
'profile_img': uData['profile_img'] ?? '',
|
||||
});
|
||||
if (uSeq.toString() == mySeq) {
|
||||
myParticipantType = (uData['participant_type'] ?? '').toString().toUpperCase();
|
||||
@ -566,6 +567,8 @@ class _PlayingTeamPageState extends State<PlayingTeamPage> {
|
||||
final tempScore = userData['score'] ?? 0;
|
||||
final score = (scoreOpenRange == 'ALL') ? tempScore : '-';
|
||||
final nickname = userData['nickname'] ?? 'User'; // '유저'
|
||||
final profileImg = userData['profile_img'] ?? '';
|
||||
print('profileImg: $profileImg');
|
||||
|
||||
final bool isActive = _userListMap[userSeq] ?? true;
|
||||
final hasExited = !isActive;
|
||||
@ -605,7 +608,7 @@ class _PlayingTeamPageState extends State<PlayingTeamPage> {
|
||||
)
|
||||
: ClipOval(
|
||||
child: Image.network(
|
||||
'https://eldsoft.com:8097/images${userData['profile_img']}',
|
||||
profileImg.isNotEmpty ? 'https://eldsoft.com:8097/images$profileImg' : '',
|
||||
fit: BoxFit.cover,
|
||||
errorBuilder: (ctx, err, st) => const Center(
|
||||
child: Text(
|
||||
|
Loading…
Reference in New Issue
Block a user