종료방 버그 해결, 진행중 이미지 버그 해결

This commit is contained in:
eld_master 2025-01-28 00:19:21 +09:00
parent e7f95cacf2
commit 1a46c4c085
5 changed files with 73 additions and 54 deletions

View File

@ -14,7 +14,7 @@ void showSettingsDialog(BuildContext context) {
mainAxisAlignment: MainAxisAlignment.spaceBetween, mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [ children: [
Container( Container(
width: MediaQuery.of(context).size.width * 0.2, width: MediaQuery.of(context).size.width * 0.1,
child: const Text( child: const Text(
'', '',
// () // ()
@ -26,7 +26,7 @@ void showSettingsDialog(BuildContext context) {
), ),
), ),
Container( Container(
width: MediaQuery.of(context).size.width * 0.2, width: MediaQuery.of(context).size.width * 0.3,
child: const Text( child: const Text(
'Settings', 'Settings',
// '설정' // '설정'

View File

@ -56,10 +56,13 @@ class _FinishPrivatePageState extends State<FinishPrivatePage> {
if (response['result'] == 'OK') { if (response['result'] == 'OK') {
final resp = response['response'] ?? {}; final resp = response['response'] ?? {};
if (resp['result'] == 'OK') { if (resp['result'] == 'OK') {
final data = resp['data'] ?? {}; final data = resp['data'] ?? {};
// (1) room_info
final rInfo = data['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 rTitle = (rInfo['room_title'] ?? '') as String;
final mSeq = (rInfo['master_user_seq'] ?? 0) as int; final mSeq = (rInfo['master_user_seq'] ?? 0) as int;
@ -68,9 +71,7 @@ class _FinishPrivatePageState extends State<FinishPrivatePage> {
setState(() { setState(() {
_roomInfo = rInfo; _roomInfo = rInfo;
_userMap = uInfo;
_roomTitle = rTitle.isNotEmpty ? rTitle : 'Finished Room (Solo)'; _roomTitle = rTitle.isNotEmpty ? rTitle : 'Finished Room (Solo)';
// '종료된 방(개인전)'
_masterUserSeq = mSeq.toString(); _masterUserSeq = mSeq.toString();
if (sdt != null && sdt is String && sdt.contains('T')) { 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 = []; final List<Map<String, dynamic>> tempList = [];
uInfo.forEach((_, val) { for (var item in uInfoList) {
// val: { user_seq, participant_type, nickname, score, ... } tempList.add(Map<String, dynamic>.from(item));
tempList.add(Map<String, dynamic>.from(val)); }
});
final playerList = tempList.toList(); // (4)
tempList.sort((a, b) {
// Sort by score descending ( )
playerList.sort((a, b) {
final sa = (a['score'] ?? 0) as int; final sa = (a['score'] ?? 0) as int;
final sb = (b['score'] ?? 0) as int; final sb = (b['score'] ?? 0) as int;
return sb.compareTo(sa); return sb.compareTo(sa);
}); });
// (5)
setState(() { setState(() {
_playerList = playerList; _playerList = tempList;
_isLoading = false; _isLoading = false;
}); });
} else { } else {
final msgTitle = resp['response_info']?['msg_title'] ?? 'Error'; // '오류' final msgTitle = resp['response_info']?['msg_title'] ?? 'Error';
final msgContent = resp['response_info']?['msg_content'] ?? 'Failed to fetch data'; final msgContent = resp['response_info']?['msg_content'] ?? 'Failed to fetch data';
// '데이터 조회 실패'
showResponseDialog(context, msgTitle, msgContent); showResponseDialog(context, msgTitle, msgContent);
} }
} else { } else {
showResponseDialog(context, 'Failed', 'Server communication error.'); showResponseDialog(context, 'Failed', 'Server communication error.');
// '실패', '서버 통신 오류'
} }
} catch (e) { } catch (e) {
showResponseDialog(context, 'Error', '$e'); showResponseDialog(context, 'Error', '$e');
// '오류'
} finally { } finally {
setState(() => _isLoading = false); setState(() => _isLoading = false);
} }

View File

@ -58,7 +58,7 @@ class _FinishTeamPageState extends State<FinishTeamPage> {
if (resp['result'] == 'OK') { if (resp['result'] == 'OK') {
final data = resp['data'] ?? {}; final data = resp['data'] ?? {};
final rInfo = data['room_info'] ?? {}; 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 rTitle = (rInfo['room_title'] ?? '') as String;
final mSeq = (rInfo['master_user_seq'] ?? 0) as int; final mSeq = (rInfo['master_user_seq'] ?? 0) as int;
@ -67,9 +67,7 @@ class _FinishTeamPageState extends State<FinishTeamPage> {
setState(() { setState(() {
_roomInfo = rInfo; _roomInfo = rInfo;
_userMap = uInfo;
_roomTitle = rTitle.isNotEmpty ? rTitle : 'Finished Team Game'; _roomTitle = rTitle.isNotEmpty ? rTitle : 'Finished Team Game';
// '종료된 팀전'
_masterUserSeq = mSeq.toString(); _masterUserSeq = mSeq.toString();
if (sdt != null && sdt is String && sdt.contains('T')) { 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 = []; final List<Map<String, dynamic>> tempList = [];
uInfo.forEach((_, val) { for (var u in uInfoList) {
tempList.add(Map<String, dynamic>.from(val)); tempList.add(Map<String, dynamic>.from(u));
}); }
//
final players = tempList.toList(); final players = tempList.toList();
// (3) Separate by team + sum scores ( + ) // (3) Separate by team + sum scores ( + )
@ -99,10 +98,10 @@ class _FinishTeamPageState extends State<FinishTeamPage> {
tMap[tName]!.add(user); tMap[tName]!.add(user);
} }
// Calculate team scores ( ) //
tMap.forEach((team, mems) { tMap.forEach((team, mems) {
int sumScore = 0; int sumScore = 0;
// Sort each team's members by descending score (팀 멤버 점수 내림차순) //
mems.sort((a, b) { mems.sort((a, b) {
final sa = (a['score'] ?? 0) as int; final sa = (a['score'] ?? 0) as int;
final sb = (b['score'] ?? 0) as int; final sb = (b['score'] ?? 0) as int;
@ -114,11 +113,10 @@ class _FinishTeamPageState extends State<FinishTeamPage> {
tScoreMap[team] = sumScore; tScoreMap[team] = sumScore;
}); });
// (4) Sort teams by score ( ) // (4)
final sortedTeams = tScoreMap.keys.toList(); final sortedTeams = tScoreMap.keys.toList();
sortedTeams.sort((a, b) => tScoreMap[b]!.compareTo(tScoreMap[a]!)); 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, List<Map<String, dynamic>>> finalTeamMap = {};
final Map<String, int> finalScoreMap = {}; final Map<String, int> finalScoreMap = {};
@ -128,24 +126,21 @@ class _FinishTeamPageState extends State<FinishTeamPage> {
} }
setState(() { setState(() {
_userList = tempList; // Keep the entire list if needed _userList = tempList; //
_teamMap = finalTeamMap; _teamMap = finalTeamMap;
_teamScoreMap = finalScoreMap; _teamScoreMap = finalScoreMap;
_isLoading = false; _isLoading = false;
}); });
} else { } else {
final msgTitle = resp['response_info']?['msg_title'] ?? 'Error'; // '오류' final msgTitle = resp['response_info']?['msg_title'] ?? 'Error';
final msgContent = resp['response_info']?['msg_content'] ?? 'Failed to fetch data'; final msgContent = resp['response_info']?['msg_content'] ?? 'Failed to fetch data';
// '데이터 조회 실패'
showResponseDialog(context, msgTitle, msgContent); showResponseDialog(context, msgTitle, msgContent);
} }
} else { } else {
showResponseDialog(context, 'Failed', 'Server communication error.'); showResponseDialog(context, 'Failed', 'Server communication error.');
// '실패', '서버 통신 오류'
} }
} catch (e) { } catch (e) {
showResponseDialog(context, 'Error', '$e'); showResponseDialog(context, 'Error', '$e');
// '오류'
} finally { } finally {
setState(() => _isLoading = false); setState(() => _isLoading = false);
} }

View File

@ -41,6 +41,8 @@ class _MainPageState extends State<MainPage> {
// e.g., if a second back press occurs within 2 seconds, exit the app (2 ) // e.g., if a second back press occurs within 2 seconds, exit the app (2 )
static const _exitDuration = Duration(seconds: 2); static const _exitDuration = Duration(seconds: 2);
double scaleFactor = 1.0;
@override @override
void initState() { void initState() {
super.initState(); super.initState();
@ -60,6 +62,21 @@ class _MainPageState extends State<MainPage> {
super.dispose(); 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 ( ) // On back press callback ( )
Future<bool> _onWillPop() async { Future<bool> _onWillPop() async {
final now = DateTime.now(); final now = DateTime.now();
@ -247,16 +264,23 @@ class _MainPageState extends State<MainPage> {
required String label, required String label,
required VoidCallback onTap, required VoidCallback onTap,
}) { }) {
return ElevatedButton( return SizedBox(
onPressed: onTap, width: 100 * scaleFactor,
style: ElevatedButton.styleFrom( height: 100 * scaleFactor,
backgroundColor: Colors.white, // child: ElevatedButton(
foregroundColor: Colors.black, // onPressed: onTap,
side: const BorderSide(color: Colors.black, width: 1), style: ElevatedButton.styleFrom(
padding: const EdgeInsets.symmetric(vertical: 36, horizontal: 32), backgroundColor: Colors.white,
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(20)), 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)),
); );
} }
} }

View File

@ -165,6 +165,7 @@ class _PlayingTeamPageState extends State<PlayingTeamPage> {
'nickname': uData['nickname'] ?? 'User', // '유저' 'nickname': uData['nickname'] ?? 'User', // '유저'
'team_name': (uData['team_name'] ?? '').toString().toUpperCase(), 'team_name': (uData['team_name'] ?? '').toString().toUpperCase(),
'score': uData['score'] ?? 0, 'score': uData['score'] ?? 0,
'profile_img': uData['profile_img'] ?? '',
}); });
if (uSeq.toString() == mySeq) { if (uSeq.toString() == mySeq) {
myParticipantType = (uData['participant_type'] ?? '').toString().toUpperCase(); myParticipantType = (uData['participant_type'] ?? '').toString().toUpperCase();
@ -566,6 +567,8 @@ class _PlayingTeamPageState extends State<PlayingTeamPage> {
final tempScore = userData['score'] ?? 0; final tempScore = userData['score'] ?? 0;
final score = (scoreOpenRange == 'ALL') ? tempScore : '-'; final score = (scoreOpenRange == 'ALL') ? tempScore : '-';
final nickname = userData['nickname'] ?? 'User'; // '유저' final nickname = userData['nickname'] ?? 'User'; // '유저'
final profileImg = userData['profile_img'] ?? '';
print('profileImg: $profileImg');
final bool isActive = _userListMap[userSeq] ?? true; final bool isActive = _userListMap[userSeq] ?? true;
final hasExited = !isActive; final hasExited = !isActive;
@ -605,7 +608,7 @@ class _PlayingTeamPageState extends State<PlayingTeamPage> {
) )
: ClipOval( : ClipOval(
child: Image.network( child: Image.network(
'https://eldsoft.com:8097/images${userData['profile_img']}', profileImg.isNotEmpty ? 'https://eldsoft.com:8097/images$profileImg' : '',
fit: BoxFit.cover, fit: BoxFit.cover,
errorBuilder: (ctx, err, st) => const Center( errorBuilder: (ctx, err, st) => const Center(
child: Text( child: Text(