Skip to content

Commit

Permalink
Merge pull request #87 from tukcomCD2024/feat/#86-ios-debate-ui
Browse files Browse the repository at this point in the history
Feat/#86 ios debate UI
  • Loading branch information
realhsb authored Apr 23, 2024
2 parents 4395770 + 6c8d2a9 commit f0ea519
Show file tree
Hide file tree
Showing 6 changed files with 265 additions and 90 deletions.
10 changes: 10 additions & 0 deletions iOS/RollTheDice/RollTheDice/RollTheDiceApp.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ struct RollTheDiceApp: App {
@StateObject private var pathModel = PathModel()

@StateObject var newsListViewModel = NewsListViewModel()
@StateObject var bookmarkListViewModel = BookmarkListViewModel()

var body: some Scene {
WindowGroup {
Expand All @@ -23,6 +24,7 @@ struct RollTheDiceApp: App {
MainTabView(newsListViewModel: newsListViewModel)
.navigationDestination(for: PathType.self, destination: { pathType in

// 각 뷰마다 .navigationBarBackButtonHidden() 설정하기!
switch pathType {
case .chatView(isAiMode: true) :
GPTChatView()
Expand All @@ -37,11 +39,19 @@ struct RollTheDiceApp: App {
TypeReportView()
case .dailyReportView:
DailyReportView()
case .bookmarkView:
BookmarkListView(bookmarkListViewModel: bookmarkListViewModel)
case .mypageView:
Text("mypageView")
case .debateSummaryView:
DebateSummaryView()
}
})
}

.environmentObject(pathModel)


} else {
SignUpView()
}
Expand Down
8 changes: 7 additions & 1 deletion iOS/RollTheDice/RollTheDice/Source/Model/Path/PathType.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,13 @@ import Foundation

enum PathType: Hashable {
case chatView(isAiMode: Bool)
case detailNewsView
case detailNewsView // 뉴스 자세히 보기

case typeReportView // 분야별 뉴스 통계
case dailyReportView // 요일별 뉴스 관람 개수 통계

case debateSummaryView // 토론 요약 페이지 뷰

case bookmarkView // 북마크뷰
case mypageView // 마이페이지뷰
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,43 +8,87 @@
import SwiftUI

struct BookmarkListView: View {
@EnvironmentObject var bookmarkListViewModel : BookmarkListViewModel
@EnvironmentObject var pathModel: PathModel
@StateObject var bookmarkListViewModel : BookmarkListViewModel
@State var selectedIndex: Int = 0

var columns: [GridItem] = [ GridItem(), GridItem()]

var body: some View {
ZStack {
Color.backgroundDark.ignoresSafeArea(.all)
BookmarkListContentView()
.padding(.leading, 20)
ZStack {
bookmarkListView
// BookmarkListContentView()
.padding(.leading, 20)
VStack(spacing: 0) {

CustomNavigationBar(
title: "북마크",
isDisplayLeadingBtn: true,
leadingItems:
[
(Image(.chevronLeft), { pathModel.paths.popLast() }),
]
)

Spacer()

}

Spacer()
}
}
.navigationBarBackButtonHidden()
}

private struct BookmarkListContentView: View {
@EnvironmentObject var bookmarkListViewModel: BookmarkListViewModel
var columns: [GridItem] = [ GridItem(), GridItem() ]
var bookmarkListView: some View {

fileprivate var body: some View {
ScrollViewReader { value in
ScrollView(.horizontal, showsIndicators: false) {
LazyHGrid(rows: columns, spacing: 10) {
ForEach(bookmarkListViewModel.bookmarkList, id: \.self) { bookmark in
BookmarkView(bookmark: bookmark)

ScrollViewReader { value in
ScrollView(.horizontal, showsIndicators: false) {
LazyHGrid(rows: columns, spacing: 10) {
ForEach(bookmarkListViewModel.bookmarkList, id: \.self) { bookmark in
BookmarkView(bookmark: bookmark)
// .onTapGesture {
// withAnimation {
// selectedIndex = index
// value.scrollTo(index)
// }
// }
}
}
.padding(.vertical, 90)
}
.padding(.vertical, 90)
}
}
}

// private struct BookmarkListContentView: View {
// @StateObject var bookmarkListViewModel: BookmarkListViewModel
// var columns: [GridItem] = [ GridItem(), GridItem()]
//
// fileprivate var body: some View {
// ScrollViewReader { value in
// ScrollView(.horizontal, showsIndicators: false) {
// LazyHGrid(rows: columns, spacing: 10) {
// ForEach(bookmarkListViewModel.bookmarkList, id: \.self) { bookmark in
// BookmarkView(bookmark: bookmark)
//// .onTapGesture {
//// withAnimation {
//// selectedIndex = index
//// value.scrollTo(index)
//// }
//// }
// }
// }
// .padding(.vertical, 90)
// }
// }
// }
// }
}

#Preview {
BookmarkListView()
BookmarkListView(bookmarkListViewModel: BookmarkListViewModel())
.environmentObject(BookmarkListViewModel())
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,90 +9,143 @@ import SwiftUI

struct ChatTypeView: View {
@EnvironmentObject private var pathModel: PathModel
@State var isSelected: Bool = false
// @State var isSelected: Bool = false

var body: some View {
ZStack {
Color.backgroundDark.ignoresSafeArea(.all)
ChatTypeContentView(isSelected: $isSelected)
VStack {
CustomNavigationBar(
isDisplayTrailingBtn: true,
trailingItems: [
(Image(.bookmarkfill), { pathModel.paths.append(.bookmarkView)}),
(Image(.profileWhite), { pathModel.paths.append(.mypageView)})
]
)
Spacer()
recentReadNewsView
Spacer()

chatListView


}

}
}

private struct ChatTypeContentView: View {

@Binding var isSelected: Bool
@EnvironmentObject private var pathModel: PathModel

fileprivate var body: some View {
var recentReadNewsView: some View {
VStack(alignment: .leading) {
Text("최근에 본 뉴스")
.foregroundStyle(.gray01)
.font(.pretendardBold32)
HStack {
Button {
isSelected.toggle()
pathModel.paths.append(.chatView(isAiMode: true))
// isSelected.toggle()
// pathModel.paths.append(.chatView(isAiMode: true))
} label: {
RoundedRectangle(cornerRadius: 15)
.foregroundStyle(.primary01)
.frame(width: 350, height: 400)
.frame(width: 200, height: 200)

.overlay {
VStack {
HStack {
Text("Chat GPT랑\n토론하기")
Text("기사제목")
.multilineTextAlignment(.leading)
.font(.system(size: 40, weight: .bold))
.font(.pretendardBold24)
.foregroundStyle(.basicWhite)

Spacer()
}

Spacer()

}
}
}

Button {
// isSelected.toggle()
// pathModel.paths.append(.chatView(isAiMode: true))
} label: {
RoundedRectangle(cornerRadius: 15)
.foregroundStyle(.primary01)
.frame(width: 200, height: 200)

.overlay {
VStack {
HStack {
Spacer()
Text("🤖")
.font(.system(size: 100))
Text("기사제목")
.multilineTextAlignment(.leading)
.font(.pretendardBold24)
.foregroundStyle(.basicWhite)
}
}
.padding(.horizontal, 35)
.padding(.bottom, 35)
.padding(.top, 45)


}
}

Button {
pathModel.paths.append(.chatView(isAiMode: false))
// isSelected.toggle()
// pathModel.paths.append(.chatView(isAiMode: true))
} label: {
RoundedRectangle(cornerRadius: 15)
.foregroundStyle(.gray01)
.frame(width: 350, height: 400)
.foregroundStyle(.primary01)
.frame(width: 200, height: 200)

.overlay {
VStack {
HStack {
Spacer()
Text("인간이랑\n토론하기")
.multilineTextAlignment(.trailing)
.font(.system(size: 40, weight: .bold))
.foregroundStyle(.primary01)
Text("기사제목")
.multilineTextAlignment(.leading)
.font(.pretendardBold24)
.foregroundStyle(.basicWhite)
}

Spacer()

}
}
}
}
}
}

var chatListView: some View {
VStack(alignment: .leading) {

Text("채팅 목록")
.foregroundStyle(.gray01)
.font(.pretendardBold32)

ScrollView {
HStack {
Button {
// isSelected.toggle()
// pathModel.paths.append(.chatView(isAiMode: true))
} label: {
RoundedRectangle(cornerRadius: 15)
.foregroundStyle(.primary01)
.frame(width: 600, height: 100)

.overlay {
HStack {
Text("🫶")
.font(.system(size: 100))
Text("기사제목")
.multilineTextAlignment(.leading)
.font(.pretendardBold24)
.foregroundStyle(.basicWhite)

Spacer()


}
}
.padding(.horizontal, 35)
.padding(.bottom, 35)
.padding(.top, 45)
}
}
Button {
pathModel.paths.append(.debateSummaryView)
} label: {

Image(.chevronRight)
.padding(10)
.background(.basicBlack)
}
}
}
}
}

}

#Preview {
Expand Down
Loading

0 comments on commit f0ea519

Please sign in to comment.