Skip to content

Commit

Permalink
[Feat] #51 - RepeatPickerView 구현
Browse files Browse the repository at this point in the history
  • Loading branch information
rafa-e1 committed Jan 18, 2025
1 parent 559550e commit 4fceaff
Show file tree
Hide file tree
Showing 3 changed files with 101 additions and 0 deletions.
1 change: 1 addition & 0 deletions Memento-iOS/Memento-iOS.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
Source/Presentation/Add/AddSchedule/View/AllDayCheckBoxButton.swift,
Source/Presentation/Add/AddSchedule/View/DateTimePickerSectionView.swift,
Source/Presentation/Add/AddSchedule/View/DateTimePickerView.swift,
Source/Presentation/Add/AddSchedule/View/RepeatPickerView.swift,
Source/Presentation/Add/AddSchedule/View/RepeatTypeListView.swift,
Source/Presentation/Add/AddSchedule/ViewModel/AddEventTitleViewModel.swift,
Source/Presentation/Add/AddSchedule/ViewModel/DateTimePickerViewModel.swift,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ struct AddScheduleView: View {
VStack {
AddEventTitleView(viewModel: viewModel)
DateTimePickerView(viewModel: PickerButtonViewModel())
RepeatPickerView(viewModel: PickerButtonViewModel())
Spacer()
enterButton
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
//
// RepeatPickerView.swift
// Memento-iOS
//
// Created by RAFA on 1/18/25.
//

import SwiftUI

import MDSKit

struct RepeatPickerView: View {

// MARK: - Properties

@ObservedObject var viewModel: PickerButtonViewModel
@StateObject private var repeatViewModel = PickerButtonViewModel(type: .repeat)
@StateObject private var endRepeatViewModel = PickerButtonViewModel(type: .endRepeat)

var body: some View {
VStack(spacing: 14) {
HStack {
Text("Repeat")
.applyFont(.body_r_16)
.foregroundStyle(Color.gray05)
Spacer()

PickerButton(
type: .repeat,
title: viewModel.repeatType.title,
titleColor: .gray02,
width: 200,
action: { repeatViewModel.togglePresentation() },
viewModel: repeatViewModel
)
.sheet(
isPresented: $repeatViewModel.isPresented,
onDismiss: { repeatViewModel.dismiss() }
) {
SheetContainer(height: 350) {
VStack {
SheetHeaderView {
viewModel.updateRepeatType(repeatViewModel.repeatType)
repeatViewModel.confirmSelection()
}

RepeatTypeListView(viewModel: repeatViewModel)
}
}
}
}

if viewModel.shouldShowEndRepeat {
HStack {
Text("End Repeat")
.applyFont(.body_r_16)
.foregroundStyle(Color.gray05)
Spacer()

PickerButton(
type: .endRepeat,
title: viewModel.endRepeatDate?.formattedDate(with: "MMM d, yyyy") ?? "Select Date",
titleColor: viewModel.endRepeatDate == nil ? .mementoBlue : .gray02,
width: 200,
action: { endRepeatViewModel.togglePresentation() },
viewModel: endRepeatViewModel
)
.sheet(
isPresented: $endRepeatViewModel.isPresented,
onDismiss: { endRepeatViewModel.dismiss() }
) {
BaseSheetView(
selection: Binding(
get: { viewModel.endRepeatDate ?? Date() },
set: { viewModel.updateEndRepeatDate($0) }
),
isPresented: $endRepeatViewModel.isPresented,
type: .date,
minimumDate: Date(),
onDismiss: viewModel.confirmSelection
)
}
}
.transition(.opacity)
.animation(.easeInOut, value: viewModel.shouldShowEndRepeat)
}
}
.padding(.top)
}
}

#Preview {
ZStack {
Color.gray10
.ignoresSafeArea()

RepeatPickerView(viewModel: PickerButtonViewModel())
}
}

0 comments on commit 4fceaff

Please sign in to comment.