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

Refactor/home #12

Merged
merged 18 commits into from
Jun 3, 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
18 changes: 18 additions & 0 deletions HANE24.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
objects = {

/* Begin PBXBuildFile section */
0E0FE5F32BB3E6110050498E /* CircularProgressBar.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0E0FE5F22BB3E6110050498E /* CircularProgressBar.swift */; };
0E0FE5F42BB3E6180050498E /* CircularProgressBar.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0E0FE5F22BB3E6110050498E /* CircularProgressBar.swift */; };
0E1654F3299A285B001E5EED /* HANE24App.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0E1654F2299A285B001E5EED /* HANE24App.swift */; };
0E1654F5299A285B001E5EED /* ContentView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0E1654F4299A285B001E5EED /* ContentView.swift */; };
0E1654F7299A285E001E5EED /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 0E1654F6299A285E001E5EED /* Assets.xcassets */; };
Expand Down Expand Up @@ -37,6 +39,9 @@
0ED6E3FC2B354DFC0026E69D /* HANE24WidgetConstant.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0ED6E3FA2B354DFC0026E69D /* HANE24WidgetConstant.swift */; };
0ED6E3FF2B354E670026E69D /* AccumulationTimeStruct.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0ED6E3FE2B354E670026E69D /* AccumulationTimeStruct.swift */; };
0ED6E4002B354E670026E69D /* AccumulationTimeStruct.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0ED6E3FE2B354E670026E69D /* AccumulationTimeStruct.swift */; };
0EE06CBD2BB2819500B4988C /* HomeVM.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0EE06CBC2BB2819500B4988C /* HomeVM.swift */; };
0EE06CBF2BB2AD4C00B4988C /* HomeHeaderView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0EE06CBE2BB2AD4C00B4988C /* HomeHeaderView.swift */; };
0EE06CC12BB2B2EB00B4988C /* PullToRefresh.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0EE06CC02BB2B2EB00B4988C /* PullToRefresh.swift */; };
0EE58193299CC24000EE3351 /* MoreView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0EE58192299CC24000EE3351 /* MoreView.swift */; };
0EE58198299CC74C00EE3351 /* ReissuanceView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0EE58197299CC74C00EE3351 /* ReissuanceView.swift */; };
0EEB0E2429AE2AF700FEB700 /* CardProgressView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0EEB0E2329AE2AF700FEB700 /* CardProgressView.swift */; };
Expand Down Expand Up @@ -110,6 +115,7 @@
/* End PBXCopyFilesBuildPhase section */

/* Begin PBXFileReference section */
0E0FE5F22BB3E6110050498E /* CircularProgressBar.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CircularProgressBar.swift; sourceTree = "<group>"; };
0E1654EF299A285B001E5EED /* 24HANE.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = 24HANE.app; sourceTree = BUILT_PRODUCTS_DIR; };
0E1654F2299A285B001E5EED /* HANE24App.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HANE24App.swift; sourceTree = "<group>"; };
0E1654F4299A285B001E5EED /* ContentView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ContentView.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -140,6 +146,9 @@
0ED6E3FE2B354E670026E69D /* AccumulationTimeStruct.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AccumulationTimeStruct.swift; sourceTree = "<group>"; };
0ED6E4032B3559B80026E69D /* 24HANE.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = 24HANE.entitlements; sourceTree = "<group>"; };
0ED6E4042B3559DF0026E69D /* HANE24WidgetExtension.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = HANE24WidgetExtension.entitlements; sourceTree = "<group>"; };
0EE06CBC2BB2819500B4988C /* HomeVM.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HomeVM.swift; sourceTree = "<group>"; };
0EE06CBE2BB2AD4C00B4988C /* HomeHeaderView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HomeHeaderView.swift; sourceTree = "<group>"; };
0EE06CC02BB2B2EB00B4988C /* PullToRefresh.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PullToRefresh.swift; sourceTree = "<group>"; };
0EE58192299CC24000EE3351 /* MoreView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MoreView.swift; sourceTree = "<group>"; };
0EE58197299CC74C00EE3351 /* ReissuanceView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ReissuanceView.swift; sourceTree = "<group>"; };
0EEB0E2329AE2AF700FEB700 /* CardProgressView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CardProgressView.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -281,8 +290,10 @@
children = (
0E16550F299A5A82001E5EED /* HomeView.swift */,
9A1A4BED299ADE650076D650 /* TodayAccTimeCardView.swift */,
0E0FE5F22BB3E6110050498E /* CircularProgressBar.swift */,
0E165507299A3C20001E5EED /* ChartView.swift */,
0E16550B299A3DF6001E5EED /* ChartDetailView.swift */,
0EE06CBE2BB2AD4C00B4988C /* HomeHeaderView.swift */,
0E17EFA9299B5C0A0089BCD8 /* PopulationView.swift */,
2B1326102B2821E600301A8B /* ThisMonthAccTimeCardView.swift */,
2B1326122B285B1D00301A8B /* NoticeView.swift */,
Expand Down Expand Up @@ -325,6 +336,7 @@
0E16550D299A5887001E5EED /* MainView.swift */,
0EFAF5BD29A4D97800125948 /* LoadingView.swift */,
0E3B32A829A3815B001D10BF /* SignInWebView.swift */,
0EE06CC02BB2B2EB00B4988C /* PullToRefresh.swift */,
0EFAF5B729A492A500125948 /* SignInView.swift */,
0EE5818F299CC01D00EE3351 /* Home */,
0EE58190299CC02A00EE3351 /* Calendar */,
Expand Down Expand Up @@ -363,6 +375,7 @@
D6C528F72BBECE0700F51A06 /* ReissueVM.swift */,
D6185AE02BB3C71800E6944A /* CalendarVM.swift */,
0E3ED8A72BB13727001B0BAE /* NetworkManager.swift */,
0EE06CBC2BB2819500B4988C /* HomeVM.swift */,
0E6B608E29AC850D009D8BC4 /* NetworkMonitoringManager.swift */,
);
path = ViewModel;
Expand Down Expand Up @@ -608,6 +621,7 @@
0EFDFD47299F5AF500A911F7 /* DarkMode.swift in Sources */,
0E17EFAA299B5C0A0089BCD8 /* PopulationView.swift in Sources */,
0E165510299A5A82001E5EED /* HomeView.swift in Sources */,
0EE06CBD2BB2819500B4988C /* HomeVM.swift in Sources */,
0EEB0E2629AE303100FEB700 /* AlertView.swift in Sources */,
9AF730F1299D58F100AF2E53 /* AccTimeCardForCalendarView.swift in Sources */,
2B1326112B2821E600301A8B /* ThisMonthAccTimeCardView.swift in Sources */,
Expand All @@ -628,9 +642,11 @@
D6E780C92BCCE84300FB547D /* CalendarModel.swift in Sources */,
D6185AE12BB3C71800E6944A /* CalendarVM.swift in Sources */,
9AF730EF299D3A4900AF2E53 /* CalendarGridView.swift in Sources */,
0EE06CC12BB2B2EB00B4988C /* PullToRefresh.swift in Sources */,
0E3ED8A82BB13727001B0BAE /* NetworkManager.swift in Sources */,
D68CC3F02BCC1E81008D62E2 /* ReissueButtonAppearance.swift in Sources */,
0E9868252B2B6C0B00E127DC /* CalendarHeaderView.swift in Sources */,
0EE06CBF2BB2AD4C00B4988C /* HomeHeaderView.swift in Sources */,
D6E780D02BCD03AE00FB547D /* HowToReissue.swift in Sources */,
D6E780D72BCD0CAE00FB547D /* AlertButtons.swift in Sources */,
D68CC3F62BCC1FA4008D62E2 /* LogoutButton.swift in Sources */,
Expand All @@ -654,6 +670,7 @@
D6C528F82BBECE0700F51A06 /* ReissueVM.swift in Sources */,
D6E19CF32BEB427B005DF8C3 /* Error.swift in Sources */,
9AF730F3299D599300AF2E53 /* TagLogView.swift in Sources */,
0E0FE5F32BB3E6110050498E /* CircularProgressBar.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand All @@ -664,6 +681,7 @@
0ED6E4002B354E670026E69D /* AccumulationTimeStruct.swift in Sources */,
0ED6E3F92B354DD00026E69D /* UserDefaultsExtension.swift in Sources */,
0ED6E3E82B354D320026E69D /* HANE24WidgetBundle.swift in Sources */,
0E0FE5F42BB3E6180050498E /* CircularProgressBar.swift in Sources */,
0ED6E3EA2B354D320026E69D /* HANE24Widget.swift in Sources */,
0ED6E3F52B354DBD0026E69D /* DateExtensions.swift in Sources */,
0ED6E3F62B354DC00026E69D /* ColorExtension.swift in Sources */,
Expand Down
28 changes: 28 additions & 0 deletions HANE24/Model/JSONs.swift
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,21 @@ struct PerMonth: Codable {
struct InfoMessage: Codable {
let title: String
let content: String

init() {
self.title = ""
self.content = ""
}
}

struct InfoMessages: Codable {
let fundInfoNotice: InfoMessage
let tagLatencyNotice: InfoMessage

init() {
self.fundInfoNotice = InfoMessage()
self.tagLatencyNotice = InfoMessage()
}
}

struct MainInfo: Codable {
Expand All @@ -41,6 +51,16 @@ struct MainInfo: Codable {
let gaepo: Int
/// v3
let infoMessages: InfoMessages

init() {
self.login = ""
self.profileImage = ""
self.isAdmin = false
self.inoutState = ""
self.tagAt = ""
self.gaepo = 0
self.infoMessages = InfoMessages()
}
}

struct AccumulationTimes: Codable {
Expand All @@ -50,6 +70,14 @@ struct AccumulationTimes: Codable {
let sixMonthAccumulationTime: [Double]
/// v3
let monthlyAcceptedAccumulationTime: Int64

init() {
self.todayAccumulationTime = 0
self.monthAccumulationTime = 0
self.sixWeekAccumulationTime = Array(repeating: 0, count: 6)
self.sixMonthAccumulationTime = Array(repeating: 0, count: 6)
self.monthlyAcceptedAccumulationTime = 0
}
}

// 카드 신청 상태를 확인하는 API의 Response Parsing 구조체
Expand Down
5 changes: 5 additions & 0 deletions HANE24/Model/Structs.swift
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,9 @@ struct MoreItem: Identifiable {
struct Notice {
var title: String
var content: String

init(title: String = "", content: String = "") {
self.title = title
self.content = content
}
}
2 changes: 1 addition & 1 deletion HANE24/Utils/DateExtensions.swift
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ extension Date {
var daysOfMonth: [Date?] {
var days: [Date?] = []
var day = self.firstDay

for _ in 1..<self.firstDay.weekdayToInt {
days.append(nil)
}
Expand Down
76 changes: 76 additions & 0 deletions HANE24/View/Home/CircularProgressBar.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
//
// CircularProgressBar.swift
// 24HANE
//
// Created by Katherine JANG on 3/27/24.
//

import SwiftUI

struct CircularProgressBar: View {

var drawingStroke: Binding<Bool>
var percentage: Int

init(drawingStroke: Binding<Bool>, objectiveTime: Double, progressiveTime: Double) {
self.percentage = Int(progressiveTime / objectiveTime * 3600) * 100
self.drawingStroke = drawingStroke
}

var body: some View {
ZStack {
HStack(spacing: 0) {
Text("\(percentage)")
.font(.system(size: 32, weight: .medium, design: .default))
.foregroundColor(.black)
Text("%")
.font(.system(size: 14, weight: .medium, design: .default))
.foregroundColor(.black)
.padding(.top, 10)
}
Circle()
.stroke(
AngularGradient(
gradient: Gradient(
colors: [
.gradientBlue,
.gradientWhtie,
.gradientPurple,
.gradientPurple,
.gradientWhtie,
.gradientBlue
]
),
center: .center,
startAngle: .zero,
endAngle: .degrees(360)
).opacity(0.1),
style: StrokeStyle(lineWidth: 8, lineCap: .round)
)
.overlay {
Circle()
.trim(from: 0, to: drawingStroke.wrappedValue ? CGFloat(percentage / 100) : 0)
.stroke(
AngularGradient(
gradient: Gradient(colors: [
.gradientBlue.opacity(0.35),
.gradientWhtie,
.gradientPurple,
.gradientPurple,
.gradientWhtie,
.gradientBlue.opacity(0.35)
]),
center: .center,
startAngle: .degrees(0),
endAngle: .degrees(360)
),
style: StrokeStyle(lineWidth: 8, lineCap: .round))
.rotationEffect(.degrees(270))
}
}
}
}

#Preview {
CircularProgressBar(drawingStroke: .constant(false), objectiveTime: 12345, progressiveTime: 1234)
}
66 changes: 66 additions & 0 deletions HANE24/View/Home/HomeHeaderView.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
//
// HeaderView.swift
// 24HANE
//
// Created by Katherine JANG on 3/26/24.
//

import SwiftUI

struct HomeHeaderView: View {
@Environment(\.colorScheme) var colorScheme
@ObservedObject var homeManager: HomeVM

var body: some View {
VStack(alignment: .center, spacing: 20) {
HStack(alignment: .center) {
if homeManager.mainInfo.profileImage != "" {
AsyncImage(url: URL(string: homeManager.mainInfo.profileImage)) { image in
image
.resizable()
.scaledToFill()
.frame(width: 28, height: 28)
.clipShape(Circle())
.padding(.trailing, 3)
} placeholder: {
Image(systemName: "person.circle")
.resizable()
.frame(width: 28, height: 28)
.padding(.trailing, 3)
.foregroundColor(.iconColor)
}
} else {
Image(systemName: "person.circle")
.resizable()
.frame(width: 28, height: 28)
.padding(.trailing, 3)
.foregroundColor(.iconColor)
}

Check warning on line 39 in HANE24/View/Home/HomeHeaderView.swift

View workflow job for this annotation

GitHub Actions / Test

Trailing Whitespace Violation: Lines should not have trailing whitespace (trailing_whitespace)
Text(homeManager.mainInfo.login)
.font(.system(size: 20, weight: .semibold, design: .rounded))
.foregroundColor(!homeManager.isInCluster && colorScheme == .light ? .black : .white)

if homeManager.isInCluster {
Circle()
.foregroundColor(.green)
.frame(width: 8, height: 8)
.padding(.bottom, 10)
.padding(.leading, 0)
}

Spacer()
}
.padding(.top, 20)
.frame(height: 30)
.padding(.horizontal, 30)
}

}
}

#Preview {
@StateObject var homeVM = HomeVM()

Check warning on line 64 in HANE24/View/Home/HomeHeaderView.swift

View workflow job for this annotation

GitHub Actions / Test

Trailing Whitespace Violation: Lines should not have trailing whitespace (trailing_whitespace)
return HomeHeaderView(homeManager: homeVM)
}
Loading
Loading