Skip to content

Commit

Permalink
[Feat/#12] HomeView 구현
Browse files Browse the repository at this point in the history
  • Loading branch information
Zoe0929 committed Apr 14, 2024
1 parent b007345 commit 76b141a
Showing 1 changed file with 65 additions and 44 deletions.
109 changes: 65 additions & 44 deletions HMH_iOS/HMH_iOS/Presentation/Home/HomeView.swift
Original file line number Diff line number Diff line change
@@ -1,71 +1,92 @@
import SwiftUI
import FamilyControls
import DeviceActivity

import Lottie

struct HomeView: View {

//@StateObject var usageTimeData = HomeViewModel()
@StateObject var usageTimeData = HomeViewModel()

var body: some View {
ZStack {
Color(.blackground)
.ignoresSafeArea()
ScrollView {
VStack(alignment: .leading) {
ZStack(alignment: .topLeading) {
LottieView(animation: .named("Main-A-final.json"))
.playing(loopMode: .autoReverse)
.resizable()
.aspectRatio(contentMode: .fit)
Text(StringLiteral.Home.usageStatusA)
.font(.text1_medium_22)
.foregroundStyle(.whiteText)
.frame(alignment: .topLeading)
.padding(EdgeInsets(top: 8,
leading: 20,
bottom: 0,
trailing: 0))
VStack(alignment: .leading){
Text(StringLiteral.Home.usageStatusA)
.font(.text1_medium_22)
.foregroundStyle(.whiteText)
.frame(alignment: .topLeading)
.padding(EdgeInsets(top: 8,
leading: 20,
bottom: 0,
trailing: 0))
Spacer()
VStack(alignment: .leading) {
Text("목표 사용 시간 3시간 중")
.font(.detail4_medium_12)
.foregroundStyle(.gray2)
.frame(alignment: .leading)
.padding(EdgeInsets(top: 0,
leading: 20,
bottom: 0,
trailing: 0))
HStack {
Text("20분 사용")
.font(.title2_semibold_24)
.foregroundStyle(.whiteText)
Spacer()
Text("20분 남음")
.font(.detail3_semibold_12)
.foregroundStyle(.whiteText)
}
. padding(EdgeInsets(top: 2,
leading: 20,
bottom: 24,
trailing: 20))
ProgressView(value: 3, total: 10)
.foregroundStyle(.gray5)
.padding(EdgeInsets(top: 0,
leading: 20,
bottom: 0,
trailing: 20))
.tint(.whiteText)
}
.padding(.bottom, -20)
}
}
Text("목표 사용 시간 3시간 중")
.font(.detail4_medium_12)
.foregroundStyle(.gray2)
.frame(alignment: .leading)
.padding(EdgeInsets(top: 0,
leading: 20,
bottom: 0,
trailing: 0))
Text("20분 사용")
.font(.title2_semibold_24)
.foregroundStyle(.whiteText)
.padding(EdgeInsets(top: 2,
leading: 20,
bottom: 0,
trailing: 0))
ProgressView(value: 3, total: 10)
.foregroundStyle(.gray5)
.padding(EdgeInsets(top: 0,
leading: 20,
bottom: 0,
trailing: 20))
.tint(.whiteText)
List {
.padding(.bottom, 60)
ForEach(usageTimeData.appsUsage) { appUsage in
UsageTimeListItemView(appName: appUsage.appName,
usageTime: Int(appUsage.usedTime), remainingTime: "\(appUsage.goalTime - appUsage.usedTime)")

}



}
.background(.blackground)
}

.onAppear {
requestAuthorization()
usageTimeData.generateDummyData()
}
.background(.blackground)
}
}

extension HomeView {
enum lottie {
case statusA
case statusB
case statusC
case statusD
case statusE
func requestAuthorization() {
AuthorizationCenter.shared.revokeAuthorization { result in
switch result {
case .success():
break
case .failure(let error):
print("Error for Family Controls: \(error)")
}
}
}
}

Expand Down

0 comments on commit 76b141a

Please sign in to comment.