60 lines
		
	
	
		
			2.0 KiB
		
	
	
	
		
			Swift
		
	
	
	
	
	
			
		
		
	
	
			60 lines
		
	
	
		
			2.0 KiB
		
	
	
	
		
			Swift
		
	
	
	
	
	
//
 | 
						|
//  TalkView.swift
 | 
						|
//  SodaLive
 | 
						|
//
 | 
						|
//  Created by klaus on 8/29/25.
 | 
						|
//
 | 
						|
 | 
						|
import SwiftUI
 | 
						|
 | 
						|
struct TalkView: View {
 | 
						|
    
 | 
						|
    @StateObject var viewModel = TalkViewModel()
 | 
						|
    
 | 
						|
    var body: some View {
 | 
						|
        BaseView(isLoading: $viewModel.isLoading) {
 | 
						|
            if viewModel.talkRooms.isEmpty {
 | 
						|
                Text("대화 중인 톡이 없습니다")
 | 
						|
                    .font(.custom(Font.preRegular.rawValue, size: 20))
 | 
						|
                    .foregroundColor(.white)
 | 
						|
            } else {
 | 
						|
                ScrollView(.vertical, showsIndicators: false) {
 | 
						|
                    LazyVStack(spacing: 24) {
 | 
						|
                        ForEach(0..<viewModel.talkRooms.count, id: \.self) { index in
 | 
						|
                            let item = viewModel.talkRooms[index]
 | 
						|
                            TalkItemView(item: item)
 | 
						|
                                .padding(.horizontal, 24)
 | 
						|
                                .contentShape(Rectangle())
 | 
						|
                                .onTapGesture {
 | 
						|
                                    AppState.shared
 | 
						|
                                        .setAppStep(
 | 
						|
                                            step: .chatRoom(id: item.chatRoomId)
 | 
						|
                                        )
 | 
						|
                                }
 | 
						|
                                .onAppear {
 | 
						|
                                    // 마지막 셀 등장 시 다음 페이지 로드
 | 
						|
                                    if index == viewModel.talkRooms.count - 1 {
 | 
						|
                                        viewModel.loadNextPage()
 | 
						|
                                    }
 | 
						|
                                }
 | 
						|
                        }
 | 
						|
                        if viewModel.isLoadingMore {
 | 
						|
                            ProgressView()
 | 
						|
                                .progressViewStyle(CircularProgressViewStyle(tint: .white))
 | 
						|
                                .padding(.vertical, 12)
 | 
						|
                        }
 | 
						|
                    }
 | 
						|
                    .padding(.vertical, 24)
 | 
						|
                }
 | 
						|
            }
 | 
						|
        }
 | 
						|
        .onAppear {
 | 
						|
            viewModel.getTalkRooms()
 | 
						|
        }
 | 
						|
    }
 | 
						|
}
 | 
						|
 | 
						|
#Preview {
 | 
						|
    TalkView()
 | 
						|
}
 |