Skip to content

Commit

Permalink
Merge pull request #14 from TheClimeet/CIOS-31-RootSelectionUI
Browse files Browse the repository at this point in the history
Feature/Cios 31/RootSelection UI (초기구현)
  • Loading branch information
iOS-Woong authored Jun 20, 2024
2 parents 8657296 + 5514387 commit 7852014
Show file tree
Hide file tree
Showing 12 changed files with 202 additions and 31 deletions.
4 changes: 4 additions & 0 deletions Climeet-iOS/Climeet-iOS.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
D473920C2C193C090059AE45 /* SheetType.swift in Sources */ = {isa = PBXBuildFile; fileRef = D473920B2C193C090059AE45 /* SheetType.swift */; };
D47392102C196C070059AE45 /* DateTimePicker.swift in Sources */ = {isa = PBXBuildFile; fileRef = D473920F2C196C070059AE45 /* DateTimePicker.swift */; };
D47392122C198E250059AE45 /* DateFormatter + .swift in Sources */ = {isa = PBXBuildFile; fileRef = D47392112C198E250059AE45 /* DateFormatter + .swift */; };
D476AF8F2C23FD0300943FA7 /* UIColor + hex.swift in Sources */ = {isa = PBXBuildFile; fileRef = D476AF8E2C23FD0200943FA7 /* UIColor + hex.swift */; };
D47A3AAB2C0CAC400031DCAA /* SearchView.swift in Sources */ = {isa = PBXBuildFile; fileRef = D47A3AAA2C0CAC400031DCAA /* SearchView.swift */; };
D47A3AAD2C0CAC4B0031DCAA /* SearchReducer.swift in Sources */ = {isa = PBXBuildFile; fileRef = D47A3AAC2C0CAC4B0031DCAA /* SearchReducer.swift */; };
D47A3AB02C0CAD810031DCAA /* GymSearchResult.swift in Sources */ = {isa = PBXBuildFile; fileRef = D47A3AAF2C0CAD810031DCAA /* GymSearchResult.swift */; };
Expand Down Expand Up @@ -97,6 +98,7 @@
D473920B2C193C090059AE45 /* SheetType.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SheetType.swift; sourceTree = "<group>"; };
D473920F2C196C070059AE45 /* DateTimePicker.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DateTimePicker.swift; sourceTree = "<group>"; };
D47392112C198E250059AE45 /* DateFormatter + .swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "DateFormatter + .swift"; sourceTree = "<group>"; };
D476AF8E2C23FD0200943FA7 /* UIColor + hex.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "UIColor + hex.swift"; sourceTree = "<group>"; };
D47A3AAA2C0CAC400031DCAA /* SearchView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SearchView.swift; sourceTree = "<group>"; };
D47A3AAC2C0CAC4B0031DCAA /* SearchReducer.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SearchReducer.swift; sourceTree = "<group>"; };
D47A3AAF2C0CAD810031DCAA /* GymSearchResult.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = GymSearchResult.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -404,6 +406,7 @@
D47392092C192D7F0059AE45 /* View + onReadSize.swift */,
D47392112C198E250059AE45 /* DateFormatter + .swift */,
D42357532C1FC8910070DB70 /* Date + datesOfMonth.swift */,
D476AF8E2C23FD0200943FA7 /* UIColor + hex.swift */,
);
path = Extension;
sourceTree = "<group>";
Expand Down Expand Up @@ -583,6 +586,7 @@
04CFB9EC2C007F3100580395 /* Token.swift in Sources */,
D44FF1F72C145E66005E9EB1 /* ActivityRecordReducer.swift in Sources */,
D442A3DE2BF9D36500A58F92 /* SearchAPI.swift in Sources */,
D476AF8F2C23FD0300943FA7 /* UIColor + hex.swift in Sources */,
D4B75EF02C0B3D540074870D /* Error + toAppError.swift in Sources */,
D4F161782C1AAB6300BF4392 /* RootSelectionView.swift in Sources */,
D47A3AB32C0CAE2D0031DCAA /* SearchUsecase.swift in Sources */,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"images" : [
{
"filename" : "[email protected]",
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "[email protected]",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "[email protected]",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
{
"colors" : [
{
"color" : {
"color-space" : "srgb",
"components" : {
"alpha" : "1.000",
"blue" : "0x64",
"green" : "0x64",
"red" : "0x64"
}
},
"idiom" : "universal"
},
{
"appearances" : [
{
"appearance" : "luminosity",
"value" : "dark"
}
],
"color" : {
"color-space" : "srgb",
"components" : {
"alpha" : "1.000",
"blue" : "0x64",
"green" : "0x64",
"red" : "0x64"
}
},
"idiom" : "universal"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
34 changes: 34 additions & 0 deletions Climeet-iOS/Climeet-iOS/Common/Extension/UIColor + hex.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
//
// UIColor + hex.swift
// Climeet-iOS
//
// Created by KOVI on 6/20/24.
//

import SwiftUI

extension UIColor {
convenience init?(hex: String) {
let r, g, b, a: CGFloat
if hex.hasPrefix("#") {
let start = hex.index(hex.startIndex, offsetBy: 1)
let hexColor = String(hex[start...])

if hexColor.count == 6 {
let scanner = Scanner(string: hexColor)
var hexNumber: UInt64 = 0

if scanner.scanHexInt64(&hexNumber) {
r = CGFloat((hexNumber & 0xff0000) >> 16) / 255
g = CGFloat((hexNumber & 0x00ff00) >> 8) / 255
b = CGFloat(hexNumber & 0x0000ff) / 255
a = 1.0

self.init(red: r, green: g, blue: b, alpha: a)
return
}
}
}
return nil
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ import ComposableArchitecture
struct ActivityCalendarReducer {
@Reducer
enum Destination {
case selectDate(DateTimePickerReducer)
case selectDateHalfSheet(DateTimePickerReducer)
case recordActivitySheet(ActivityRecordReducer)
}

@ObservableState
Expand All @@ -33,6 +34,7 @@ struct ActivityCalendarReducer {
case recordButtonTapped
case statisticButtonTapped
case calendarTitleButtonTapped
case plusButtonTapped
case destination(PresentationAction<Destination.Action>)
}

Expand Down Expand Up @@ -72,7 +74,7 @@ struct ActivityCalendarReducer {
}
reducer.selectedDate = datePickerSelectedDate ?? Date()

state.destination = .selectDate(reducer)
state.destination = .selectDateHalfSheet(reducer)

return .none

Expand All @@ -86,7 +88,14 @@ struct ActivityCalendarReducer {

return .none

case let .destination(.presented(.selectDate(.delegate(.selectDate(selectedDate))))):
case .plusButtonTapped:
let reducer = ActivityRecordReducer.State()

state.destination = .recordActivitySheet(reducer)

return .none

case let .destination(.presented(.selectDateHalfSheet(.delegate(.selectDate(selectedDate))))):
let monthDifference = monthsBetweenNowDate(date: selectedDate)
state.selectedMonth = monthDifference
state.tappedCalendarDate = CalendarDate(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,20 @@ struct ActivityCalendarView: View {
store.send(.calendarTitleButtonTapped)
}
)

HStack {
Spacer()
Button(action: {
store.send(.plusButtonTapped)
}, label: {
Image("activity_plus")
})
.frame(width: 54, height: 54)
.background(Color.climeetMain)
.clipShape(Circle())
}
.padding(.vertical, 37)
.padding(.trailing, 25)
}
.frame(maxWidth: .infinity, maxHeight: .infinity)
.background(.text09)
Expand All @@ -57,12 +71,19 @@ struct ActivityCalendarView: View {
})
.sheet(
item: $store.scope(
state: \.destination?.selectDate,
action: \.destination.selectDate)
state: \.destination?.selectDateHalfSheet,
action: \.destination.selectDateHalfSheet)
) { dateTimePickerStore in
DateTimePickerView(store: dateTimePickerStore)
.presentationDetents([.height(store.bottomSheetHeight)])
}
.fullScreenCover(
item: $store.scope(
state: \.destination?.recordActivitySheet,
action: \.destination.recordActivitySheet)
) { recordActivityStore in
ActivityRecordView(store: recordActivityStore)
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,14 @@ struct ActivityRecordReducer {
case readViewSize(CGSize)
case selectDateButtonTapped
case selectTimeButtonTapped
case closeButtonTapped
case destination(PresentationAction<Destination.Action>)
case path(StackAction<SearchReducer.State, SearchReducer.Action>)
}

// MARK: Internal

@Dependency(\.dismiss) var dismiss
var body: some ReducerOf<Self> {
Reduce { state, action in
switch action {
Expand Down Expand Up @@ -75,6 +77,10 @@ struct ActivityRecordReducer {
state.destination = .selectDateTime(reducer)

return .none

case .closeButtonTapped:

return .run { _ in await dismiss() }

case let .path(.element(_, action: .delegate(.selectGym(selectedGym)))):
state.selectedGym = selectedGym
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,9 +73,8 @@ struct ActivityRecordView: View {
.background(.text08)
.cornerRadius(5)
} else {
// TODO: 캘린더
Text("안녕하세요")
.foregroundColor(.red)
// TODO: 루트셀렉션 이니셜라이저 값 채워줘야함
RootSelectionView()
}
}
.padding(.leading, 28)
Expand All @@ -87,8 +86,13 @@ struct ActivityRecordView: View {
.background(.text09)
.toolbar {
ToolbarItem(placement: .topBarLeading) {
Image("activity_close")
.frame(width: 24, height: 24)
Button(action: {
store.send(.closeButtonTapped)
}, label: {
Image("activity_close")
.frame(width: 24, height: 24)
})

}
}
.toolbarBackground(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,37 @@
//

import SwiftUI
import Kingfisher

// MARK: ForTest
struct Difficulty: Identifiable {
var id = UUID()
let climeetDifficultyName: String
let gymDifficultyName: String
let difficulty: Int
let gymDifficultyColor: UIColor
}

let testItems = ["Jaws", "Cheesegrater", "The Wallus", "Moonraker", "Starcatcher", "Dreamweaver"]
let testDifficultyList: [Difficulty] = [
Difficulty(climeetDifficultyName: "VB", gymDifficultyName: "하양", difficulty: 0, gymDifficultyColor: UIColor.white),
Difficulty(climeetDifficultyName: "V1", gymDifficultyName: "빨강", difficulty: 1, gymDifficultyColor: UIColor(hex: "#F34040")!),
Difficulty(climeetDifficultyName: "서울", gymDifficultyName: "주황", difficulty: 2, gymDifficultyColor: UIColor(hex: "#FF9000")!),
Difficulty(climeetDifficultyName: "V3", gymDifficultyName: "노랑", difficulty: 3, gymDifficultyColor: UIColor(hex: "#FDDA16")!),
Difficulty(climeetDifficultyName: "V4", gymDifficultyName: "초록", difficulty: 4, gymDifficultyColor: UIColor(hex: "#63B75D")!),
Difficulty(climeetDifficultyName: "V5", gymDifficultyName: "하늘", difficulty: 5, gymDifficultyColor: UIColor(hex: "#74D5FF")!),
Difficulty(climeetDifficultyName: "V6", gymDifficultyName: "파랑", difficulty: 6, gymDifficultyColor: UIColor(hex: "#0094FF")!),
Difficulty(climeetDifficultyName: "V7", gymDifficultyName: "남색", difficulty: 7, gymDifficultyColor: UIColor(hex: "#393FD6")!),
Difficulty(climeetDifficultyName: "V8", gymDifficultyName: "갈색", difficulty: 8, gymDifficultyColor: UIColor(hex: "#6E4C41")!),
Difficulty(climeetDifficultyName: "V9+", gymDifficultyName: "회색", difficulty: 9, gymDifficultyColor: UIColor(hex: "#8B8B8B")!),
Difficulty(climeetDifficultyName: "C", gymDifficultyName: "컴피", difficulty: 10, gymDifficultyColor: UIColor(hex: "#000000")!)
]

struct RootSelectionView: View {
let items = ["안녕하십니까", "여기는 파크123", "", "여긴여", "여긴여파크입니다여기는여긴여파크입니다여기는여긴여파크입니다여기는여긴여파크입니다여기는여긴여파크입니다여기는"]

var body: some View {
VStack {
Image(systemName: "cloud.fill")
KFImage(URL(string: "https://climeet-production-bucket.s3.ap-northeast-2.amazonaws.com/final_1.png"))
.resizable()
.aspectRatio(contentMode: .fill)
.frame(height: 132)
Expand All @@ -21,40 +45,48 @@ struct RootSelectionView: View {

ScrollView(.horizontal) {
HStack(spacing: 9) {
ForEach(items, id: \.self) { item in
VStack {
ForEach(testItems, id: \.self) { item in
Button(action: {

// TODO: Item ButtonAction
}, label: {
Text(item)
.font(.climeetFontParagraph5())
})
.padding(.horizontal, 16)
.padding(.top, 5.5)
.padding(.bottom, 6.5)
.background(Color.red)
.frame(height: 30)
.background(.text06)
.cornerRadius(8)

.frame(maxWidth: .infinity)
.cornerRadius(/*@START_MENU_TOKEN@*/3.0/*@END_MENU_TOKEN@*/)
}
.foregroundColor(.levelColorWhite)
}
}
.padding()
}
Spacer()
.scrollIndicators(.never)

ScrollView(.horizontal) {
HStack(spacing: 9) {
ForEach(testDifficultyList) { testDifficulty in
Button(action: {
// TODO: Difficulty ButtonAction
}, label: {
Text(testDifficulty.climeetDifficultyName)
.font(.climeetFontParagraph4())
.foregroundColor(Color(testDifficulty.gymDifficultyColor))
})
.padding(.horizontal, 5)
.padding(.vertical, 8)
.background(.text065)
.clipShape(Circle())
}
}
}
.scrollIndicators(.never)
}
}
}

#Preview {
RootSelectionView()
}

/*
Text("Item \(item)")
.font(.headline)
.padding()
.background(Color.red)
.cornerRadius(10)
.foregroundColor(.white)

*/

0 comments on commit 7852014

Please sign in to comment.