Skip to content

Commit

Permalink
Merge branch 'addHabit'
Browse files Browse the repository at this point in the history
  • Loading branch information
ys00912 committed Dec 15, 2024
2 parents 6df7c74 + 3ee240e commit 4f73d69
Show file tree
Hide file tree
Showing 74 changed files with 1,433 additions and 325 deletions.
Binary file modified .DS_Store
Binary file not shown.
Binary file modified Washabit/.DS_Store
Binary file not shown.
6 changes: 6 additions & 0 deletions Washabit/Washabit.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -451,9 +451,11 @@
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
CODE_SIGN_IDENTITY = "Apple Development";
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 1;
DEVELOPMENT_ASSET_PATHS = "\"Washabit/Preview Content\"";
DEVELOPMENT_TEAM = 4A3YKSVN4S;
ENABLE_PREVIEWS = YES;
GENERATE_INFOPLIST_FILE = YES;
INFOPLIST_KEY_UIApplicationSceneManifest_Generation = YES;
Expand All @@ -468,6 +470,7 @@
MARKETING_VERSION = 1.0;
PRODUCT_BUNDLE_IDENTIFIER = "-11.Washabit";
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = "";
SWIFT_EMIT_LOC_STRINGS = YES;
SWIFT_VERSION = 5.0;
TARGETED_DEVICE_FAMILY = "1,2";
Expand All @@ -479,9 +482,11 @@
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
CODE_SIGN_IDENTITY = "Apple Development";
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 1;
DEVELOPMENT_ASSET_PATHS = "\"Washabit/Preview Content\"";
DEVELOPMENT_TEAM = 4A3YKSVN4S;
ENABLE_PREVIEWS = YES;
GENERATE_INFOPLIST_FILE = YES;
INFOPLIST_KEY_UIApplicationSceneManifest_Generation = YES;
Expand All @@ -496,6 +501,7 @@
MARKETING_VERSION = 1.0;
PRODUCT_BUNDLE_IDENTIFIER = "-11.Washabit";
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = "";
SWIFT_EMIT_LOC_STRINGS = YES;
SWIFT_VERSION = 5.0;
TARGETED_DEVICE_FAMILY = "1,2";
Expand Down
Binary file modified Washabit/Washabit/.DS_Store
Binary file not shown.
95 changes: 81 additions & 14 deletions Washabit/Washabit/AddHabitView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,34 @@
//

import SwiftUI
import SwiftData

struct AddHabitView: View {
@Environment(\.modelContext) private var modelContext
@Query private var habits: [HabitData]
@State var title:String = ""
@State private var selectedOption: String? = "고치고 싶은"
@State private var date = Date()
@State private var totalHabitCount:Int = 30
@State private var startDate: Date? = nil
@State private var endDate: Date? = nil

@Environment(\.presentationMode) var presentationMode: Binding<PresentationMode>

@State private var showAlert: Bool = false
@State private var alertMessage: String = ""
@State private var showConfirmation: Bool = false

var backButton : some View { // <-- 👀 커스텀 버튼
Button{
self.presentationMode.wrappedValue.dismiss()
} label: {
HStack {
Image(systemName: "chevron.left")
.font(.system(size: 18, weight: .bold))
.foregroundColor(Color("StrongBlue-font"))
}
}
}

let options = ["고치고 싶은", "만들고 싶은"]
@State private var selectedCount: Int = 1
Expand All @@ -25,13 +47,20 @@ struct AddHabitView: View {
Color("MainColor")
VStack{
HStack{
Image(systemName: "chevron.left")
.font(.system(size: 18, weight: .bold))
.foregroundColor(Color("StrongBlue-font"))
Button{
self.presentationMode.wrappedValue.dismiss()
} label: {
HStack {
Image(systemName: "chevron.left")
.font(.system(size: 18, weight: .bold))
.foregroundColor(Color("StrongBlue-font"))
.padding(.top,10)
.padding(.leading,20)
}
}
Spacer()
}
.padding([.top,.leading],20)
ZStack{
HStack{
Text("새 목표 추가하기")
.foregroundColor(Color("StrongBlue-font"))
.bold()
Expand All @@ -46,7 +75,7 @@ struct AddHabitView: View {
.cornerRadius(12)
HStack{
Spacer()
Text("\(totalHabitCount)번째 목표")
Text("\(habits.count + 1)번째 목표")
.font(.system(size: 13, weight: .bold))
.foregroundColor(.white)
.frame(width:85, height:28)
Expand All @@ -55,7 +84,7 @@ struct AddHabitView: View {
}
.padding(.trailing, 40)
}
ZStack{
HStack{
Text("목표 설정하기")
.foregroundColor(Color("StrongBlue-font"))
.bold()
Expand All @@ -70,6 +99,7 @@ struct AddHabitView: View {
.padding([.top,.leading],20)
.bold()
.font(.system(size: 15))
.foregroundColor(Color("StrongGray-font"))
HStack(spacing:25){
Spacer()
ForEach(options, id:\.self){ option in
Expand All @@ -89,7 +119,6 @@ struct AddHabitView: View {
}
.onTapGesture {
selectedOption = option
print("Selected: \(selectedOption!)")
}
}
Spacer()
Expand All @@ -100,13 +129,15 @@ struct AddHabitView: View {
.padding(.bottom, 10)
.bold()
.font(.system(size: 15))
CustomDatePickerView()
.foregroundColor(Color("StrongGray-font"))
CustomDatePickerView(startDate: $startDate, endDate: $endDate)

HStack{
Text(selectedOption == "고치고 싶은" ? "하루 제한 횟수" : "하루 실행 횟수")
.padding(.leading, 20)
.bold()
.font(.system(size: 15))
.foregroundColor(Color("StrongGray-font"))
Spacer()

Menu {
Expand Down Expand Up @@ -135,6 +166,7 @@ struct AddHabitView: View {
.padding(.leading, 20)
.bold()
.font(.system(size: 15))
.foregroundColor(Color("StrongGray-font"))
Spacer()
Menu {
ForEach(percentageOptions, id: \.self) { option in
Expand Down Expand Up @@ -163,22 +195,57 @@ struct AddHabitView: View {
.cornerRadius(15)
HStack{
Spacer()
Button{
if title.isEmpty || startDate == nil || endDate == nil {
alertMessage = "습관 정보를 입력해주세요."
showAlert = true
} else {
showConfirmation = true
}

}
label: {
Circle()
.fill(Color(.white))
.frame(width:66, height:66)
.shadow(color: Color.black.opacity(0.25), radius: 8, x: 0, y: 2)
.overlay(
Image(systemName:"checkmark")
.font(.system(size: 20))
.foregroundColor(Color("StrongBlue-font"))

HStack {
Image("Icons/checkmark")
}
)
}
}}
.padding(.trailing,20)
.padding(.top,10)
}
.padding()
}
.ignoresSafeArea()
.ignoresSafeArea(.keyboard)
.navigationBarBackButtonHidden(true)
.alert(isPresented: $showAlert) {
Alert(title: Text("알림"), message: Text(alertMessage), dismissButton: .default(Text("확인")))
}
.confirmationDialog(
"습관을 등록하시겠습니까?",
isPresented: $showConfirmation,
titleVisibility: .visible
) {
Button("등록", role: .none) {
HabitManager.addNewHabit(
title,
selectedOption ?? "고치고 싶은",
selectedCount,
selectedPercentage,
startDate ?? Date(),
endDate ?? Date(),
to: modelContext
)
self.presentationMode.wrappedValue.dismiss()
}
Button("취소", role: .cancel) {}
}
}
}

Expand Down
Binary file modified Washabit/Washabit/Assets.xcassets/.DS_Store
Binary file not shown.
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.
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.
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.
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.
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.
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.
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.
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.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit 4f73d69

Please sign in to comment.