팬톡 TextField가 Focus 되었을 때 자판이 해당 영역을 가리는 버그 수정

This commit is contained in:
Yu Sung
2026-02-04 16:12:37 +09:00
parent 8d3aed41c2
commit 3456510eec
2 changed files with 319 additions and 304 deletions

View File

@@ -18,6 +18,7 @@ struct UserProfileFanTalkView: View {
let reportPopup: (Int) -> Void let reportPopup: (Int) -> Void
let deletePopup: (Int) -> Void let deletePopup: (Int) -> Void
let profilePopup: (Int) -> Void let profilePopup: (Int) -> Void
let fanTalkInputId: String
@Binding var isLoading: Bool @Binding var isLoading: Bool
@State private var cheersContent: String = "" @State private var cheersContent: String = ""
@@ -73,6 +74,7 @@ struct UserProfileFanTalkView: View {
cheersContent = "" cheersContent = ""
} }
} }
.id(fanTalkInputId)
.background(Color.gray23) .background(Color.gray23)
.cornerRadius(10) .cornerRadius(10)
.overlay( .overlay(

View File

@@ -14,6 +14,7 @@ struct UserProfileView: View {
@Environment(\.presentationMode) var presentationMode: Binding<PresentationMode> @Environment(\.presentationMode) var presentationMode: Binding<PresentationMode>
@StateObject var viewModel = UserProfileViewModel() @StateObject var viewModel = UserProfileViewModel()
@StateObject private var keyboardHandler = KeyboardHandler()
@State private var memberId: Int = 0 @State private var memberId: Int = 0
@State private var isShowMemberProfilePopup: Bool = false @State private var isShowMemberProfilePopup: Bool = false
@@ -23,342 +24,354 @@ struct UserProfileView: View {
@State private var maxCommunityPostHeight: CGFloat? = nil @State private var maxCommunityPostHeight: CGFloat? = nil
private let fanTalkInputId = "fanTalkInput"
var body: some View { var body: some View {
GeometryReader { proxy in GeometryReader { proxy in
BaseView(isLoading: $viewModel.isLoading) { BaseView(isLoading: $viewModel.isLoading) {
ZStack(alignment: .top) { ZStack(alignment: .top) {
ScrollView(.vertical, showsIndicators: false) { ScrollViewReader { scrollProxy in
LazyVStack(spacing: 48) { ScrollView(.vertical, showsIndicators: false) {
if let creatorProfile = viewModel.creatorProfile { LazyVStack(spacing: 48) {
ZStack(alignment: .bottomLeading) { if let creatorProfile = viewModel.creatorProfile {
KFImage(URL(string: creatorProfile.creator.profileUrl)) ZStack(alignment: .bottomLeading) {
.cancelOnDisappear(true) KFImage(URL(string: creatorProfile.creator.profileUrl))
.downsampling(size: CGSize(width: screenSize().width, height: screenSize().width))
.resizable()
.scaledToFill()
.aspectRatio(1, contentMode: .fill)
.frame(width: screenSize().width, height: screenSize().width)
.clipped()
VStack(alignment: .leading, spacing: 8) {
HStack(spacing: 8) {
Text(creatorProfile.creator.nickname)
.appFont(size: 32, weight: .bold)
.foregroundColor(.white)
if creatorProfile.creator.creatorId != UserDefaults.int(forKey: .userId) {
let asset = FollowButtonImageAsset(
type: creatorProfile.creator.isFollow
? (creatorProfile.creator.isNotify ? .following : .followingNoAlarm)
: .follow
)
asset.imageView(defaultSize: CGSize(width: 83.3, height: 26.7))
.onTapGesture {
if creatorProfile.creator.isFollow {
isShowFollowNotifyDialog = true
} else {
viewModel.creatorFollow()
}
}
}
}
if creatorProfile.creator.creatorId == UserDefaults.int(forKey: .userId) {
Text(I18n.MemberChannel.followersList)
.appFont(size: 16, weight: .bold)
.foregroundColor(Color.black)
.padding(.vertical, 8)
.frame(maxWidth: .infinity)
.background(Color.white)
.cornerRadius(999)
.onTapGesture {
AppState.shared.setAppStep(step: .followerList(userId: creatorProfile.creator.creatorId))
}
} else {
VStack(alignment: .leading, spacing: 9.3) {
Text(I18n.MemberChannel.followerCount(creatorProfile.creator.notificationRecipientCount.comma()))
.appFont(size: 16, weight: .medium)
.foregroundColor(Color.white)
}
}
}
.padding(24)
}
if let item = creatorProfile.latestContent {
HStack(spacing: 16) {
KFImage(URL(string: item.coverImageUrl))
.cancelOnDisappear(true) .cancelOnDisappear(true)
.downsampling(size: CGSize(width: 133, height: 133)) .downsampling(size: CGSize(width: screenSize().width, height: screenSize().width))
.resizable() .resizable()
.scaledToFill() .scaledToFill()
.frame(width: 133, height: 133, alignment: .top) .aspectRatio(1, contentMode: .fill)
.frame(width: screenSize().width, height: screenSize().width)
.clipped() .clipped()
.cornerRadius(12)
VStack(alignment: .leading, spacing: 8) { VStack(alignment: .leading, spacing: 8) {
Text(I18n.Common.latestContent)
.appFont(size: 12, weight: .medium)
.foregroundColor(.button)
.padding(.horizontal, 7)
.padding(.vertical, 4)
.background(Color(hex: "263238"))
.cornerRadius(4)
.overlay {
RoundedRectangle(cornerRadius: 4)
.strokeBorder(lineWidth: 1)
.foregroundColor(.button)
}
HStack(spacing: 8) { HStack(spacing: 8) {
if item.isScheduledToOpen { Text(creatorProfile.creator.nickname)
Text(I18n.Common.openScheduled) .appFont(size: 32, weight: .bold)
.appFont(size: 12, weight: .medium) .foregroundColor(.white)
.foregroundColor(Color(hex: "3bb9f1"))
.padding(2.6)
.background(Color(hex: "003851"))
.cornerRadius(2.6)
}
Text(item.themeStr) if creatorProfile.creator.creatorId != UserDefaults.int(forKey: .userId) {
.appFont(size: 12, weight: .medium) let asset = FollowButtonImageAsset(
.foregroundColor(Color(hex: "3bac6a")) type: creatorProfile.creator.isFollow
.padding(2.6) ? (creatorProfile.creator.isNotify ? .following : .followingNoAlarm)
.background(Color(hex: "28312b")) : .follow
.cornerRadius(2.6) )
asset.imageView(defaultSize: CGSize(width: 83.3, height: 26.7))
Text(item.duration!) .onTapGesture {
.appFont(size: 12, weight: .medium) if creatorProfile.creator.isFollow {
.foregroundColor(Color(hex: "777777")) isShowFollowNotifyDialog = true
.padding(2.6) } else {
.background(Color(hex: "222222")) viewModel.creatorFollow()
.cornerRadius(2.6) }
}
if item.isPointAvailable {
Text(I18n.Common.points)
.appFont(size: 12, weight: .medium)
.foregroundColor(.white)
.padding(2.6)
.background(Color(hex: "7849bc"))
.cornerRadius(2.6)
} }
} }
Text(item.title) if creatorProfile.creator.creatorId == UserDefaults.int(forKey: .userId) {
.appFont(size: 18, weight: .medium) Text(I18n.MemberChannel.followersList)
.foregroundColor(Color.white) .appFont(size: 16, weight: .bold)
.multilineTextAlignment(.leading) .foregroundColor(Color.black)
.lineLimit(2) .padding(.vertical, 8)
.truncationMode(.tail) .frame(maxWidth: .infinity)
.background(Color.white)
HStack(spacing: 14) { .cornerRadius(999)
HStack(spacing: 6) { .onTapGesture {
Image("ic_heart_777") AppState.shared.setAppStep(step: .followerList(userId: creatorProfile.creator.creatorId))
.resizable() }
.frame(width: 18, height: 18) } else {
VStack(alignment: .leading, spacing: 9.3) {
Text("\(item.likeCount)") Text(I18n.MemberChannel.followerCount(creatorProfile.creator.notificationRecipientCount.comma()))
.appFont(size: 18, weight: .medium) .appFont(size: 16, weight: .medium)
.foregroundColor(Color(hex: "777777")) .foregroundColor(Color.white)
}
HStack(spacing: 6) {
Image("ic_message_square_777")
.resizable()
.frame(width: 18, height: 18)
Text("\(item.commentCount)")
.appFont(size: 18, weight: .medium)
.foregroundColor(Color(hex: "777777"))
} }
} }
} }
.padding(24)
Spacer()
} }
.frame(maxWidth: .infinity)
.frame(alignment: .leading)
.padding(.horizontal, 24)
.onTapGesture {
AppState.shared
.setAppStep(step: .contentDetail(contentId: item.contentId))
}
}
if creatorProfile.creator.creatorId == UserDefaults.int(forKey: .userId) || creatorProfile.liveRoomList.count > 0 { if let item = creatorProfile.latestContent {
VStack(alignment: .leading, spacing: 14) { HStack(spacing: 16) {
HStack(spacing: 0) { KFImage(URL(string: item.coverImageUrl))
Text(I18n.MemberChannel.liveHeader) .cancelOnDisappear(true)
.appFont(size: 26, weight: .bold) .downsampling(size: CGSize(width: 133, height: 133))
.foregroundColor(Color.white) .resizable()
.scaledToFill()
.frame(width: 133, height: 133, alignment: .top)
.clipped()
.cornerRadius(12)
VStack(alignment: .leading, spacing: 8) {
Text(I18n.Common.latestContent)
.appFont(size: 12, weight: .medium)
.foregroundColor(.button)
.padding(.horizontal, 7)
.padding(.vertical, 4)
.background(Color(hex: "263238"))
.cornerRadius(4)
.overlay {
RoundedRectangle(cornerRadius: 4)
.strokeBorder(lineWidth: 1)
.foregroundColor(.button)
}
HStack(spacing: 8) {
if item.isScheduledToOpen {
Text(I18n.Common.openScheduled)
.appFont(size: 12, weight: .medium)
.foregroundColor(Color(hex: "3bb9f1"))
.padding(2.6)
.background(Color(hex: "003851"))
.cornerRadius(2.6)
}
Text(item.themeStr)
.appFont(size: 12, weight: .medium)
.foregroundColor(Color(hex: "3bac6a"))
.padding(2.6)
.background(Color(hex: "28312b"))
.cornerRadius(2.6)
Text(item.duration!)
.appFont(size: 12, weight: .medium)
.foregroundColor(Color(hex: "777777"))
.padding(2.6)
.background(Color(hex: "222222"))
.cornerRadius(2.6)
if item.isPointAvailable {
Text(I18n.Common.points)
.appFont(size: 12, weight: .medium)
.foregroundColor(.white)
.padding(2.6)
.background(Color(hex: "7849bc"))
.cornerRadius(2.6)
}
}
Text(item.title)
.appFont(size: 18, weight: .medium)
.foregroundColor(Color.white)
.multilineTextAlignment(.leading)
.lineLimit(2)
.truncationMode(.tail)
HStack(spacing: 14) {
HStack(spacing: 6) {
Image("ic_heart_777")
.resizable()
.frame(width: 18, height: 18)
Text("\(item.likeCount)")
.appFont(size: 18, weight: .medium)
.foregroundColor(Color(hex: "777777"))
}
HStack(spacing: 6) {
Image("ic_message_square_777")
.resizable()
.frame(width: 18, height: 18)
Text("\(item.commentCount)")
.appFont(size: 18, weight: .medium)
.foregroundColor(Color(hex: "777777"))
}
}
}
Spacer() Spacer()
} }
.frame(maxWidth: .infinity)
if creatorProfile.creator.creatorId == UserDefaults.int(forKey: .userId) { .frame(alignment: .leading)
HStack(spacing: 8) { .padding(.horizontal, 24)
Text(I18n.MemberChannel.rouletteSettings) .onTapGesture {
.appFont(size: 16, weight: .bold) AppState.shared
.foregroundColor(Color.grayee) .setAppStep(step: .contentDetail(contentId: item.contentId))
.padding(.vertical, 12)
.frame(maxWidth: .infinity)
.background(Color.button)
.cornerRadius(12)
.onTapGesture { isShowRouletteSettings = true }
Text(I18n.MemberChannel.menuSettings)
.appFont(size: 16, weight: .bold)
.foregroundColor(Color.grayee)
.padding(.vertical, 12)
.frame(maxWidth: .infinity)
.background(Color.button)
.cornerRadius(12)
.onTapGesture { isShowMenuSettings = true }
}
} }
}
if creatorProfile.liveRoomList.count > 0 { if creatorProfile.creator.creatorId == UserDefaults.int(forKey: .userId) || creatorProfile.liveRoomList.count > 0 {
UserProfileLiveView( VStack(alignment: .leading, spacing: 14) {
userId: userId, HStack(spacing: 0) {
liveRoomList: creatorProfile.liveRoomList, Text(I18n.MemberChannel.liveHeader)
onClickParticipant: { liveRoom in .appFont(size: 26, weight: .bold)
if creatorProfile.creator.creatorId == UserDefaults.int(forKey: .userId) { .foregroundColor(Color.white)
viewModel.errorMessage = I18n.MemberChannel.liveOnNow
viewModel.isShowPopup = true Spacer()
} else { }
AppState.shared.isShowPlayer = false
DispatchQueue.main.asyncAfter(deadline: .now() + 0.2) { if creatorProfile.creator.creatorId == UserDefaults.int(forKey: .userId) {
viewModel.enterLiveRoom(roomId: liveRoom.roomId) HStack(spacing: 8) {
Text(I18n.MemberChannel.rouletteSettings)
.appFont(size: 16, weight: .bold)
.foregroundColor(Color.grayee)
.padding(.vertical, 12)
.frame(maxWidth: .infinity)
.background(Color.button)
.cornerRadius(12)
.onTapGesture { isShowRouletteSettings = true }
Text(I18n.MemberChannel.menuSettings)
.appFont(size: 16, weight: .bold)
.foregroundColor(Color.grayee)
.padding(.vertical, 12)
.frame(maxWidth: .infinity)
.background(Color.button)
.cornerRadius(12)
.onTapGesture { isShowMenuSettings = true }
}
}
if creatorProfile.liveRoomList.count > 0 {
UserProfileLiveView(
userId: userId,
liveRoomList: creatorProfile.liveRoomList,
onClickParticipant: { liveRoom in
if creatorProfile.creator.creatorId == UserDefaults.int(forKey: .userId) {
viewModel.errorMessage = I18n.MemberChannel.liveOnNow
viewModel.isShowPopup = true
} else {
AppState.shared.isShowPlayer = false
DispatchQueue.main.asyncAfter(deadline: .now() + 0.2) {
viewModel.enterLiveRoom(roomId: liveRoom.roomId)
}
}
},
onClickReservation: { liveRoom in
if creatorProfile.creator.creatorId == UserDefaults.int(forKey: .userId) {
viewModel.errorMessage = I18n.MemberChannel.cannotReserveOwnLive
viewModel.isShowPopup = true
} else {
viewModel.reservationLiveRoom(roomId: liveRoom.roomId)
} }
} }
},
onClickReservation: { liveRoom in
if creatorProfile.creator.creatorId == UserDefaults.int(forKey: .userId) {
viewModel.errorMessage = I18n.MemberChannel.cannotReserveOwnLive
viewModel.isShowPopup = true
} else {
viewModel.reservationLiveRoom(roomId: liveRoom.roomId)
}
}
)
}
}
.padding(.horizontal, 24)
}
if creatorProfile.creator.creatorId == UserDefaults.int(forKey: .userId) || creatorProfile.contentList.count > 0 {
UserProfileContentView(
userId: userId,
items: creatorProfile.contentList,
totalContentCount: creatorProfile.totalContentCount,
ownedContentCount: creatorProfile.ownedContentCount
)
.padding(.horizontal, 24)
}
if creatorProfile.creator.creatorId == UserDefaults.int(forKey: .userId) || viewModel.communityPostList.count > 0 {
VStack(alignment: .leading, spacing: 14) {
HStack(spacing: 0) {
Text(I18n.MemberChannel.communityHeader)
.appFont(size: 26, weight: .bold)
.foregroundColor(Color.white)
.padding(.horizontal, 24)
Spacer()
}
if viewModel.communityPostList.count > 0 {
ScrollView(.horizontal, showsIndicators: false) {
LazyHStack(spacing: 14) {
if UserDefaults.int(forKey: .userId) == creatorProfile.creator.creatorId {
CreatorCommunityWriteItemView()
.onTapGesture {
AppState.shared.setAppStep(
step: .creatorCommunityWrite(
onSuccess: creatorCommunityWriteSuccess
)
)
}
}
ForEach(0..<viewModel.communityPostList.count, id: \.self) { index in
let item = viewModel.communityPostList[index]
CreatorCommunityItemView(item: item)
.frame(width: 320)
.onTapGesture {
AppState.shared
.setAppStep(
step: .creatorCommunityAll(creatorId: userId)
)
}
.background(
GeometryReader { geo in
Color.clear
.preference(key: HeightPreferenceKey.self, value: geo.size.height)
}
)
}
CreatorCommunityMoreItemView {
AppState.shared
.setAppStep(
step: .creatorCommunityAll(creatorId: userId)
)
}
}
.padding(.horizontal, 24)
.frame(height: maxCommunityPostHeight)
.onPreferenceChange(HeightPreferenceKey.self) { value in
if let current = maxCommunityPostHeight {
maxCommunityPostHeight = max(current, value)
} else {
maxCommunityPostHeight = value
}
}
}
} else {
if creatorProfile.creator.creatorId == UserDefaults.int(forKey: .userId) {
CreatorCommunityNoPostsItemView(
onSuccess: creatorCommunityWriteSuccess
) )
.padding(.horizontal, 24) }
}
.padding(.horizontal, 24)
}
if creatorProfile.creator.creatorId == UserDefaults.int(forKey: .userId) || creatorProfile.contentList.count > 0 {
UserProfileContentView(
userId: userId,
items: creatorProfile.contentList,
totalContentCount: creatorProfile.totalContentCount,
ownedContentCount: creatorProfile.ownedContentCount
)
.padding(.horizontal, 24)
}
if creatorProfile.creator.creatorId == UserDefaults.int(forKey: .userId) || viewModel.communityPostList.count > 0 {
VStack(alignment: .leading, spacing: 14) {
HStack(spacing: 0) {
Text(I18n.MemberChannel.communityHeader)
.appFont(size: 26, weight: .bold)
.foregroundColor(Color.white)
.padding(.horizontal, 24)
Spacer()
}
if viewModel.communityPostList.count > 0 {
ScrollView(.horizontal, showsIndicators: false) {
LazyHStack(spacing: 14) {
if UserDefaults.int(forKey: .userId) == creatorProfile.creator.creatorId {
CreatorCommunityWriteItemView()
.onTapGesture {
AppState.shared.setAppStep(
step: .creatorCommunityWrite(
onSuccess: creatorCommunityWriteSuccess
)
)
}
}
ForEach(0..<viewModel.communityPostList.count, id: \.self) { index in
let item = viewModel.communityPostList[index]
CreatorCommunityItemView(item: item)
.frame(width: 320)
.onTapGesture {
AppState.shared
.setAppStep(
step: .creatorCommunityAll(creatorId: userId)
)
}
.background(
GeometryReader { geo in
Color.clear
.preference(key: HeightPreferenceKey.self, value: geo.size.height)
}
)
}
CreatorCommunityMoreItemView {
AppState.shared
.setAppStep(
step: .creatorCommunityAll(creatorId: userId)
)
}
}
.padding(.horizontal, 24)
.frame(height: maxCommunityPostHeight)
.onPreferenceChange(HeightPreferenceKey.self) { value in
if let current = maxCommunityPostHeight {
maxCommunityPostHeight = max(current, value)
} else {
maxCommunityPostHeight = value
}
}
}
} else {
if creatorProfile.creator.creatorId == UserDefaults.int(forKey: .userId) {
CreatorCommunityNoPostsItemView(
onSuccess: creatorCommunityWriteSuccess
)
.padding(.horizontal, 24)
}
} }
} }
} }
}
if !creatorProfile.seriesList.isEmpty { if !creatorProfile.seriesList.isEmpty {
UserProfileSeriesView( UserProfileSeriesView(
creatorId: creatorProfile.creator.creatorId, creatorId: creatorProfile.creator.creatorId,
creatorNickname: creatorProfile.creator.nickname, creatorNickname: creatorProfile.creator.nickname,
items: creatorProfile.seriesList items: creatorProfile.seriesList
)
}
if creatorProfile.creator.creatorId == UserDefaults.int(forKey: .userId) || creatorProfile.userDonationRanking.count > 0 {
UserProfileDonationView(userId: userId, donationRankingResponse: creatorProfile.userDonationRanking)
}
UserProfileFanTalkView(
userId: userId,
cheers: creatorProfile.cheers,
errorPopup: { message in
viewModel.errorMessage = message
viewModel.isShowPopup = true
},
reportPopup: { cheerId in
viewModel.cheersId = cheerId
viewModel.isShowCheersReportView = true
},
deletePopup: { cheerId in
viewModel.cheersId = cheerId
viewModel.isShowCheersDeleteView = true
},
profilePopup: {
self.memberId = $0
self.isShowMemberProfilePopup = true
},
fanTalkInputId: fanTalkInputId,
isLoading: $viewModel.isLoading
) )
} }
}
if creatorProfile.creator.creatorId == UserDefaults.int(forKey: .userId) || creatorProfile.userDonationRanking.count > 0 { .onChange(of: keyboardHandler.keyboardHeight) { height in
UserProfileDonationView(userId: userId, donationRankingResponse: creatorProfile.userDonationRanking) if height > 0 {
withAnimation(.easeOut(duration: 0.25)) {
scrollProxy.scrollTo(fanTalkInputId, anchor: .bottom)
}
} }
UserProfileFanTalkView(
userId: userId,
cheers: creatorProfile.cheers,
errorPopup: { message in
viewModel.errorMessage = message
viewModel.isShowPopup = true
},
reportPopup: { cheerId in
viewModel.cheersId = cheerId
viewModel.isShowCheersReportView = true
},
deletePopup: { cheerId in
viewModel.cheersId = cheerId
viewModel.isShowCheersDeleteView = true
},
profilePopup: {
self.memberId = $0
self.isShowMemberProfilePopup = true
},
isLoading: $viewModel.isLoading
)
} }
} }
} }
@@ -556,7 +569,7 @@ struct UserProfileView: View {
Spacer() Spacer()
} }
} }
.ignoresSafeArea() .ignoresSafeArea(.container, edges: .all)
.sheet( .sheet(
isPresented: $viewModel.isShowShareView, isPresented: $viewModel.isShowShareView,
onDismiss: { viewModel.shareMessage = "" }, onDismiss: { viewModel.shareMessage = "" },