feat(main): 생성 메뉴를 홈에 추가한다

This commit is contained in:
Yu Sung
2026-07-20 19:14:02 +09:00
parent 9a0e75a391
commit 70af4923c6
6 changed files with 213 additions and 12 deletions

View File

@@ -1,11 +1,26 @@
import SwiftUI
struct CreatorChannelFloatingActionMenu: View {
struct CreatorContentCreationFloatingActionMenu: View {
@Binding var isPresented: Bool
let bottomPadding: CGFloat
let onTapCommunityPost: () -> Void
let onTapAudioContent: () -> Void
let onTapCreateLive: () -> Void
init(
isPresented: Binding<Bool>,
bottomPadding: CGFloat = 0,
onTapCommunityPost: @escaping () -> Void,
onTapAudioContent: @escaping () -> Void,
onTapCreateLive: @escaping () -> Void
) {
_isPresented = isPresented
self.bottomPadding = bottomPadding
self.onTapCommunityPost = onTapCommunityPost
self.onTapAudioContent = onTapAudioContent
self.onTapCreateLive = onTapCreateLive
}
private let animation = Animation.interpolatingSpring(mass: 1, stiffness: 256, damping: 24, initialVelocity: 0)
var body: some View {
@@ -66,6 +81,7 @@ struct CreatorChannelFloatingActionMenu: View {
}
}
.padding(.trailing, SodaSpacing.s14)
.padding(.bottom, bottomPadding)
.animation(animation, value: isPresented)
}
.frame(maxWidth: .infinity, maxHeight: .infinity, alignment: .bottomTrailing)
@@ -73,11 +89,11 @@ struct CreatorChannelFloatingActionMenu: View {
}
struct CreatorChannelFloatingActionMenu_Previews: PreviewProvider {
struct CreatorContentCreationFloatingActionMenu_Previews: PreviewProvider {
static var previews: some View {
ZStack {
Color.black.ignoresSafeArea()
CreatorChannelFloatingActionMenu(
CreatorContentCreationFloatingActionMenu(
isPresented: .constant(false),
onTapCommunityPost: {},
onTapAudioContent: {},

View File

@@ -90,7 +90,7 @@ struct CreatorChannelView: View {
}
if isOwnCreatorChannel && viewModel.selectedTab == .home && !viewModel.isLoading {
CreatorChannelFloatingActionMenu(
CreatorContentCreationFloatingActionMenu(
isPresented: $isCreatorActionMenuPresented,
onTapCommunityPost: showCommunityWrite,
onTapAudioContent: showAudioContentUpload,

View File

@@ -24,10 +24,14 @@ struct MainView: View {
@State private var isShowPlayer = false
@State private var isShowAuthView = false
@State private var isShowAuthConfirmView = false
@State private var isCreatorActionMenuPresented = false
@State private var pendingAction: (() -> Void)? = nil
@State private var payload = Payload()
@State private var hasLoadedMainData = false
private let mainTabBarHeight: CGFloat = 66
private let miniPlayerHeight: CGFloat = 58.1
var body: some View {
GeometryReader { proxy in
ZStack(alignment: .bottom) {
@@ -104,6 +108,16 @@ struct MainView: View {
}
}
if shouldShowCreatorActionMenu {
CreatorContentCreationFloatingActionMenu(
isPresented: $isCreatorActionMenuPresented,
bottomPadding: creatorActionMenuBottomPadding,
onTapCommunityPost: showMainCommunityWrite,
onTapAudioContent: showMainAudioContentUpload,
onTapCreateLive: showMainCreateLive
)
}
if isShowPlayer {
ContentPlayerView(isShowing: $isShowPlayer, playlist: [])
}
@@ -117,6 +131,11 @@ struct MainView: View {
.valueChanged(value: appState.pushAudioContentId) { handlePushAudioContentId($0) }
.valueChanged(value: appState.pushSeriesId) { handlePushSeriesId($0) }
.valueChanged(value: appState.pendingMainChatFilter) { handlePendingMainChatFilter($0) }
.onChange(of: viewModel.currentTab) { currentTab in
if currentTab != .home {
isCreatorActionMenuPresented = false
}
}
.onAppear {
if appState.pushMessageId > 0 {
DispatchQueue.main.asyncAfter(deadline: .now() + 0.5) {
@@ -132,6 +151,21 @@ struct MainView: View {
}
}
private var shouldShowCreatorActionMenu: Bool {
UserDefaults.string(forKey: .role) == MemberRole.CREATOR.rawValue && viewModel.currentTab == .home
}
private var creatorActionMenuBottomPadding: CGFloat {
var bottomPadding = mainTabBarHeight + SodaSpacing.s14
if contentPlayerPlayManager.isShowingMiniPlayer {
bottomPadding += miniPlayerHeight
}
if contentPlayManager.isShowingMiniPlayer {
bottomPadding += miniPlayerHeight
}
return bottomPadding
}
@ViewBuilder
private var contentView: some View {
switch viewModel.currentTab {
@@ -584,6 +618,28 @@ struct MainView: View {
}
}
private func showMainCommunityWrite() {
isCreatorActionMenuPresented = false
appState.setAppStep(step: .creatorCommunityWrite(onSuccess: {}))
}
private func showMainAudioContentUpload() {
isCreatorActionMenuPresented = false
appState.setAppStep(step: .createContent(onSuccess: {}))
}
private func showMainCreateLive() {
isCreatorActionMenuPresented = false
appState.setAppStep(step: .createLive(timeSettingMode: .NOW, onSuccess: handleMainCreateLiveSuccess))
}
private func handleMainCreateLiveSuccess(response: CreateLiveRoomResponse) {
liveViewModel.getLiveMain()
if let _ = response.channelName {
liveViewModel.enterRoom(roomId: response.id!)
}
}
private func openRecommendationBannerLink(_ link: String?) {
guard let link = link?.trimmingCharacters(in: .whitespacesAndNewlines),
!link.isEmpty else {