Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[2.0.0] 공지사항 UI에 발생하던 이슈 수정 #155

Merged
merged 2 commits into from
Mar 19, 2024
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
15 changes: 10 additions & 5 deletions package-kuring/Sources/UIKit/BookmarkUI/BookmarkList.swift
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
//

import SwiftUI
import ColorSet
import NoticeUI
import NoticeFeatures
import BookmarkFeatures
Expand All @@ -13,9 +14,13 @@ public struct BookmarkList: View {
@Bindable var store: StoreOf<BookmarkListFeature>

public var body: some View {
ZStack(alignment: .bottom) {
ZStack(alignment: .center) {
ColorSet.bg.ignoresSafeArea()

if store.bookmarkedNotices.isEmpty {
Text("보관된 공지사항이 없습니다.")
.font(.system(size: 16, weight: .medium))
.foregroundStyle(ColorSet.body)
} else {
List {
ForEach(self.store.bookmarkedNotices, id: \.id) { notice in
Expand Down Expand Up @@ -52,13 +57,13 @@ public struct BookmarkList: View {
} label: {
Image(
systemName: store.selectedIDs.contains(notice.id)
? "checkmark.circle.fill"
: "circle"
? "checkmark.circle.fill"
: "circle"
)
.foregroundStyle(
store.selectedIDs.contains(notice.id)
? Color.accentColor
: Color.caption1.opacity(0.15)
? ColorSet.primary
: ColorSet.body
)
}
}
Expand Down
11 changes: 7 additions & 4 deletions package-kuring/Sources/UIKit/DepartmentUI/DepartmentEditor.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

import Models
import SwiftUI
import ColorSet
import DepartmentFeatures
import ComposableArchitecture

Expand All @@ -17,24 +18,25 @@ public struct DepartmentEditor: View {
VStack(alignment: .leading) {
Text("학과를 추가하거나\n삭제할 수 있어요")
.font(.system(size: 24, weight: .bold))
.foregroundStyle(Color(red: 0.1, green: 0.12, blue: 0.15))
.foregroundStyle(ColorSet.title)
.padding(.top, 28)
.padding(.bottom, 24)

HStack(alignment: .center, spacing: 12) {
Image(systemName: "magnifyingglass")
.frame(width: 16, height: 16)
.foregroundStyle(Color.caption1.opacity(0.6))
.foregroundStyle(ColorSet.gray400)

TextField("추가할 학과를 검색해 주세요", text: $store.searchText)
.focused($focus, equals: .search)
.autocorrectionDisabled()
.bind($store.focus, to: self.$focus)
.background(ColorSet.gray300)

if !store.searchText.isEmpty {
Image(systemName: "xmark")
.frame(width: 16, height: 16)
.foregroundStyle(Color.caption1.opacity(0.6))
.foregroundStyle(ColorSet.gray400)
.onTapGesture {
store.send(.clearTextFieldButtonTapped)
focus = nil
Expand All @@ -49,7 +51,7 @@ public struct DepartmentEditor: View {

Text(store.searchText.isEmpty ? "내 학과" : "검색 결과")
.font(.system(size: 14))
.foregroundStyle(Color.caption1.opacity(0.6))
.foregroundStyle(ColorSet.caption1)
.padding(.horizontal, 4)
.padding(.vertical, 10)

Expand Down Expand Up @@ -86,6 +88,7 @@ public struct DepartmentEditor: View {
Spacer()
}
.padding(.horizontal, 20)
.background(ColorSet.bg)
.toolbar {
ToolbarItem(placement: .topBarTrailing) {
Button("전체 삭제") {
Expand Down
8 changes: 4 additions & 4 deletions package-kuring/Sources/UIKit/DepartmentUI/DepartmentRow.swift
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,13 @@ public struct DepartmentRow: View {
Button(action: action) {
Image(
systemName: isSelected
? "checkmark.circle.fill"
: "plus.circle"
? "checkmark.circle.fill"
: "plus.circle"
)
.foregroundStyle(
isSelected
? Color.accentColor
: Color.black.opacity(0.1)
? ColorSet.primary
: ColorSet.gray400
)
}
}
Expand Down
6 changes: 4 additions & 2 deletions package-kuring/Sources/UIKit/NoticeUI/NoticeApp.swift
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
//

import SwiftUI
import ColorSet
import SearchUI
import DepartmentUI
import SubscriptionUI
Expand All @@ -22,6 +23,7 @@ public struct NoticeApp: View {
action: \.noticeList
)
)
.background(ColorSet.bg)
.navigationBarTitleDisplayMode(.inline)
.toolbar {
ToolbarItem(placement: .navigationBarLeading) {
Expand All @@ -37,7 +39,7 @@ public struct NoticeApp: View {
)
) {
Image(systemName: "magnifyingglass")
.foregroundStyle(Color.black)
.foregroundStyle(ColorSet.gray400)
}
}

Expand All @@ -48,7 +50,7 @@ public struct NoticeApp: View {
store.send(.changeSubscriptionButtonTapped)
} label: {
Image(systemName: "bell")
.foregroundStyle(.black)
.foregroundStyle(ColorSet.gray400)
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

import Models
import SwiftUI
import ColorSet
import NoticeFeatures
import DepartmentFeatures
import ComposableArchitecture
Expand All @@ -18,7 +19,7 @@ extension NoticeContentView {
Text("아직 추가된 학과가 없어요.\n관심 학과를 추가하고 공지를 확인해 보세요!")
.font(.system(size: 15, weight: .medium))
.multilineTextAlignment(.center)
.foregroundColor(.black.opacity(0.36))
.foregroundStyle(ColorSet.caption2)

NavigationLink(
state: NoticeAppFeature.Path.State.departmentEditor(
Expand Down Expand Up @@ -46,7 +47,7 @@ extension NoticeContentView {
.foregroundStyle(Color.white)
.padding(.horizontal, 36)
.padding(.vertical, 16)
.background(Color.accentColor)
.background(ColorSet.primary)
.cornerRadius(100)
}
}
105 changes: 60 additions & 45 deletions package-kuring/Sources/UIKit/NoticeUI/NoticeList.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,57 +12,72 @@ struct NoticeList: View {
@Bindable var store: StoreOf<NoticeListFeature>

var body: some View {
Section {
List(self.store.currentNotices, id: \.id) { notice in
NavigationLink(
state: NoticeAppFeature.Path.State.detail(
NoticeDetailFeature.State(
notice: notice,
isBookmarked: self.store.bookmarkIDs.contains(notice.id)
)
)
) {
NoticeRow(
notice: notice,
bookmarked: self.store.bookmarkIDs.contains(notice.id)
)
.listRowInsets(EdgeInsets())
.onAppear {
let type = self.store.provider
let noticeInfo = self.store.noticeDictionary[type]

/// 마지막 공지가 보이면 update
if noticeInfo?.notices.last == notice {
self.store.send(.fetchNotices)
ScrollView {
LazyVStack(spacing: 0) {
ForEach(self.store.currentNotices, id: \.id) { notice in
ZStack {
NavigationLink(
state: NoticeAppFeature.Path.State.detail(
NoticeDetailFeature.State(
notice: notice,
isBookmarked: self.store.bookmarkIDs.contains(notice.id)
)
)
) {
EmptyView()
}
}
.swipeActions(edge: .leading) {
Button {
self.store.send(.bookmarkTapped(notice))
} label: {
Image(systemName: self.store.bookmarkIDs.contains(notice.id)
? "bookmark.slash"
: "bookmark"
)
.opacity(0)

Section {
LazyVStack(spacing: 0) {
NoticeRow(
notice: notice,
bookmarked: self.store.bookmarkIDs.contains(notice.id)
)
.listRowInsets(.init(top: 0, leading: 0, bottom: 0, trailing: 0))
.onAppear {
let type = self.store.provider
let noticeInfo = self.store.noticeDictionary[type]

/// 마지막 공지가 보이면 update
if noticeInfo?.notices.last == notice {
self.store.send(.fetchNotices)
}
}
.swipeActions(edge: .leading) {
Button {
self.store.send(.bookmarkTapped(notice))
} label: {
Image(systemName: self.store.bookmarkIDs.contains(notice.id)
? "bookmark.slash"
: "bookmark"
)
}
.tint(Color.accentColor)
}

Divider()
.frame(height: 1)
}

} header: {
if self.store.provider.category == .학과 {
DepartmentSelectorLink(
department: self.store.provider,
isLoading: $store.isLoading.sending(\.loadingChanged)
) {
self.store.send(.changeDepartmentButtonTapped)
}
} else {
EmptyView()
}
}
.tint(Color.accentColor)
.navigationTitle("")

}
}
}
.listStyle(.plain)
} header: {
if self.store.provider.category == .학과 {
DepartmentSelectorLink(
department: self.store.provider,
isLoading: $store.isLoading.sending(\.loadingChanged)
) {
self.store.send(.changeDepartmentButtonTapped)
}
} else {
EmptyView()
}
}
.navigationTitle("")
}
}

Expand Down
28 changes: 16 additions & 12 deletions package-kuring/Sources/UIKit/NoticeUI/NoticeRow.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import Caches
import Models
import SwiftUI
import ColorSet
import ComposableArchitecture

public struct NoticeRow: View {
Expand Down Expand Up @@ -48,7 +49,8 @@ public struct NoticeRow: View {
ZStack {
switch rowType {
case .important, .importantAndBookmark:
Color.accentColor.opacity(0.1)
ColorSet.primary.opacity(0.1)
.ignoresSafeArea()
default:
Color.clear
}
Expand All @@ -70,10 +72,13 @@ public struct NoticeRow: View {
.padding(.horizontal, 20)
.padding(.bottom, 12)
case .important:
VStack(alignment: .leading, spacing: 4) {
importantTagView
titleView
dateView
HStack(alignment: .top, spacing: 0) {
VStack(alignment: .leading, spacing: 4) {
importantTagView
titleView
dateView
}
Spacer()
}
.padding(.horizontal, 20)
.padding(.vertical, 12)
Expand All @@ -92,7 +97,7 @@ public struct NoticeRow: View {
.padding(.horizontal, 20)
.padding(.bottom, 12)
case .none:
HStack {
HStack(alignment: .top, spacing: 0) {
VStack(alignment: .leading, spacing: 4) {
titleView
dateView
Expand All @@ -111,34 +116,33 @@ public struct NoticeRow: View {
.font(.system(size: 12, weight: .semibold))
.padding(.horizontal, 8)
.padding(.vertical, 4)
.foregroundStyle(Color.accentColor)
.background(Color.white)
.foregroundStyle(ColorSet.primary)
.background(ColorSet.bg)
.cornerRadius(16)
.overlay(
RoundedRectangle(cornerRadius: 16)
.inset(by: 0.25)
.stroke(Color.accentColor, lineWidth: 0.5)
.stroke(ColorSet.primary, lineWidth: 0.5)
)
}

@ViewBuilder
private var titleView: some View {
Text(notice.subject)
.font(.system(size: 15, weight: .medium))
.foregroundStyle(Color.caption1)
.foregroundStyle(ColorSet.body)
}

@ViewBuilder
private var dateView: some View {
// TODO: - 정보 재구성
Text(notice.postedDate)
.font(.system(size: 14))
.foregroundStyle(Color.caption1.opacity(0.6))
.foregroundStyle(ColorSet.caption1)
}

@ViewBuilder
private var bookmarkView: some View {
// TODO: 디자인 시스템 분리 - 북마크
ZStack {
RoundedRectangle(cornerRadius: 2)
.compositingGroup()
Expand Down
Loading