Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 9 additions & 7 deletions MarketPlace/ContentView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@ import SwiftUI
struct ContentView: View {
@EnvironmentObject var loginVM: LoginViewModel
@StateObject var cheerViewModel = CheerViewModel()

init() {
setupTabBarAppearance()
setupNavigationBarAppearance()
}

var body: some View {
TabView {
MainView()
Expand All @@ -20,7 +20,7 @@ struct ContentView: View {
.multilineTextAlignment(.center)
}
}

MapView()
.tabItem {
VStack {
Expand All @@ -33,15 +33,16 @@ struct ContentView: View {
.multilineTextAlignment(.center)
}
}

Group {
if loginVM.isLoggedIn {
CheerView()
.environmentObject(cheerViewModel)
} else {
LoginRequiredView()
}
}.tabItem {
}
.tabItem {
VStack {
Image(systemName: "heart.fill")
.resizable()
Expand All @@ -52,14 +53,15 @@ struct ContentView: View {
.multilineTextAlignment(.center)
}
}

Group {
if loginVM.isLoggedIn {
MyPageView()
} else {
LoginRequiredView()
}
}.tabItem {
}
.tabItem {
VStack {
Image(uiImage: resizeImage(named: "userIcon", width: 24, height: 24))
Text("마이페이지")
Expand Down
2 changes: 1 addition & 1 deletion MarketPlace/MarketPlaceApp.swift
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ class AppDelegate: NSObject, UIApplicationDelegate {
} else {
fatalError("Kakao App Key is missing ")
}

return true
}
}
2 changes: 2 additions & 0 deletions MarketPlace/View/Cheer/View/CheerSearchfailedView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
import SwiftUI

struct CheerSearchfailedView: View {
@EnvironmentObject var cheerViewModel: CheerViewModel

var body: some View {
VStack{
VStack(alignment: .center) {
Expand Down
13 changes: 8 additions & 5 deletions MarketPlace/View/Cheer/View/CheerView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,19 +11,19 @@ struct CheerView: View {
@State private var hasData: Bool = true

var body: some View {
NavigationView {
NavigationStack(path: $viewModel.navigationPath) {
ScrollView {
CheerSearchView(searchText: $viewModel.searchText)

VStack(spacing:20) {
if viewModel.searchText.trimmingCharacters(in: .whitespacesAndNewlines).isEmpty {
HotCheerView(hotCheerMarkets: $viewModel.cheerMarket, cheerTicket: $viewModel.memberCheerTicket, lastIndex: $upcomingLastIndex)
.padding(.top, 10)

Rectangle()
.foregroundStyle(Color(hex: "#EEEEEE"))
.frame(height: 4)

CheerListView()
} else {
if hasData {
Expand All @@ -39,7 +39,7 @@ struct CheerView: View {
guard index == viewModel.cheerMarket.count - 1,
let lastId = viewModel.searchLastMarketId
else { return }

Task {
await viewModel.fetchSearchCheerMarket(lastPageIndex: lastId, name: viewModel.currentKeyword)
}
Expand All @@ -58,6 +58,9 @@ struct CheerView: View {
self.endTextEditing()
}
.onAppear{
viewModel.searchText = ""
viewModel.navigationPath = NavigationPath()

Task {
await viewModel.fetchMemberInfo()
await viewModel.fetchUpcomingMarket()
Expand Down
4 changes: 1 addition & 3 deletions MarketPlace/View/Request/RequestMainView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import SwiftUI

struct RequestMainView: View {
@Environment(\.presentationMode) var presentationMode
@EnvironmentObject var cheerViewModel: CheerViewModel

@State var marketName: String = ""
@StateObject private var viewModel = RequestMarketViewModel()
Expand Down Expand Up @@ -62,16 +63,13 @@ struct RequestMainView: View {
}

private func setupNavigationBarAppearance() {
/// UINavigationBar의 기본 설정을 수정합니다.
let appearance = UINavigationBarAppearance()
appearance.configureWithOpaqueBackground()
appearance.backgroundColor = UIColor.white
appearance.titleTextAttributes = [.foregroundColor: UIColor.black]

/// 기본 back indicator를 숨깁니다.
appearance.setBackIndicatorImage(UIImage(), transitionMaskImage: UIImage())

/// 설정된 appearance 적용
UINavigationBar.appearance().standardAppearance = appearance
UINavigationBar.appearance().scrollEdgeAppearance = appearance
}
Expand Down
66 changes: 63 additions & 3 deletions MarketPlace/View/Request/RequestMarketMapView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,16 @@ import CoreLocation

struct RequestMarketMapView: View {
@Environment(\.presentationMode) var presentationMode

@EnvironmentObject var cheerViewModel: CheerViewModel

@StateObject private var viewModel = RequestMarketMapViewModel()
@State var pois: [KakaoMapPoi]
@State var location: CLLocation
@State var selectedPoi: KakaoMapPoi? /// 역할없음

@State private var showCompletionPopup: Bool = false
@State var click: Bool = false /// 역할없음

let market: KakaoMarketData

init(market: KakaoMarketData) {
Expand Down Expand Up @@ -69,7 +72,7 @@ struct RequestMarketMapView: View {
Button(action: {
Task {
await viewModel.postMarketRequest(name: market.place_name, address: market.road_address_name)
presentationMode.wrappedValue.dismiss()
showCompletionPopup = true
}
}, label: {
Text("입점 요청하기")
Expand All @@ -84,5 +87,62 @@ struct RequestMarketMapView: View {
}
.navigationTitle("요청하기")
.navigationBarTitleDisplayMode(.inline)
.navigationBarBackButtonHidden(true)
.toolbar {
ToolbarItem(placement: .navigationBarLeading) {
Button(action: {
presentationMode.wrappedValue.dismiss()
}) {
Image(systemName: "chevron.backward")
.foregroundColor(.black)
}
}
}
.overlay(
RequestCompletionPopup(
isPresented: $showCompletionPopup,
onConfirm: {
showCompletionPopup = false
cheerViewModel.searchText = ""
cheerViewModel.navigationPath = NavigationPath()
}
)
)
}
}

struct RequestCompletionPopup: View {
@Binding var isPresented: Bool
let onConfirm: () -> Void

var body: some View {
if isPresented {
ZStack {
Color.black.opacity(0.3)
.ignoresSafeArea()

VStack(spacing: 30) {
Text("입점 요청이 완료되었습니다.")
.pretendardFont(size: 18, weight: .semibold)
.multilineTextAlignment(.center)

Button(action: {
onConfirm()
}) {
Text("OK")
.pretendardFont(size: 15, weight: .bold)
.frame(maxWidth: .infinity, minHeight: 48)
.background(Color.black)
.foregroundColor(.white)
.cornerRadius(8)
}
.padding(.horizontal, 20)
}
.frame(width: 300, height: 180)
.background(Color.white)
.cornerRadius(12)
.shadow(radius: 10)
}
}
}
}
2 changes: 2 additions & 0 deletions MarketPlace/View/Search/View/SearchFailedView.swift
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import SwiftUI

struct SearchFailedView: View {
@EnvironmentObject var cheerViewModel: CheerViewModel

var body: some View {
VStack {
VStack {
Expand Down
4 changes: 3 additions & 1 deletion MarketPlace/ViewModel/Cheer/CheerViewModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,16 @@
//

import Foundation
import SwiftUI

@MainActor
final class CheerViewModel: ObservableObject {
@Published var cheerMarket: [CheerMarketModel] = []
@Published var searchMarkets: [CheerMarketModel] = []
@Published var memberCheerTicket: Int = 0
@Published var searchText: String = ""

@Published var navigationPath = NavigationPath()

@Published var upcomingMarketLastMarketId: Int?

var upcomingMarketCurrentPage: Int = 1
Expand Down