-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
[Feat/#21] 챌린지뷰 구현 및 스크린타임 API 연결
- Loading branch information
Showing
27 changed files
with
743 additions
and
86 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
// | ||
// ActivityModel.swift | ||
// HMHDeviceActivityReport | ||
// | ||
// Created by 이지희 on 5/12/24. | ||
// | ||
|
||
import Foundation | ||
|
||
import ManagedSettings | ||
|
||
struct ActivityReport { | ||
let totalDuration: TimeInterval | ||
let apps: [AppDeviceActivity] | ||
} | ||
|
||
struct AppDeviceActivity: Identifiable { | ||
var id: String | ||
var displayName: String | ||
var duration: TimeInterval | ||
var numberOfPickups: Int | ||
var token: ApplicationToken? | ||
} | ||
|
||
extension TimeInterval { | ||
/// TimeInterval 타입 값을 00:00 형식의 String으로 변환해주는 메서드 | ||
func toString() -> String { | ||
let time = NSInteger(self) | ||
let minutes = (time / 60) % 60 | ||
let hours = (time / 3600) | ||
return String(format: "%0.2d시간 %0.2d분", hours,minutes) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
// | ||
// AppActivityReport.swift | ||
// HMHDeviceActivityReport | ||
// | ||
// Created by 이지희 on 5/13/24. | ||
// | ||
|
||
|
||
import SwiftUI | ||
import DeviceActivity | ||
|
||
struct AppActivityReport: DeviceActivityReportScene { | ||
let context : DeviceActivityReport.Context = .appActivity | ||
let content: (ActivityReport) -> AppActivityView | ||
|
||
func makeConfiguration(representing data: DeviceActivityResults<DeviceActivityData>) async -> ActivityReport { | ||
|
||
var totalActivityDuration: Double = 0 | ||
var list: [AppDeviceActivity] = [] | ||
|
||
/// DeviceActivityResults 데이터에서 화면에 보여주기 위해 필요한 내용을 추출해줍니다. | ||
for await eachData in data { | ||
/// 특정 시간 간격 동안 사용자의 활동 | ||
for await activitySegment in eachData.activitySegments { | ||
/// 활동 세그먼트 동안 사용자의 카테고리 별 Device Activity | ||
for await categoryActivity in activitySegment.categories { | ||
/// 이 카테고리의 totalActivityDuration에 기여한 사용자의 application Activity | ||
for await applicationActivity in categoryActivity.applications { | ||
let appName = (applicationActivity.application.localizedDisplayName ?? "nil") /// 앱 이름 | ||
let bundle = (applicationActivity.application.bundleIdentifier ?? "nil") /// 앱 번들id | ||
let duration = applicationActivity.totalActivityDuration /// 앱의 total activity 기간 | ||
totalActivityDuration += duration | ||
let numberOfPickups = applicationActivity.numberOfPickups /// 앱에 대해 직접적인 pickup 횟수 | ||
let token = applicationActivity.application.token /// 앱의 토큰 | ||
let appActivity = AppDeviceActivity( | ||
id: bundle, | ||
displayName: appName, | ||
duration: duration, | ||
numberOfPickups: numberOfPickups, | ||
token: token | ||
) | ||
list.append(appActivity) | ||
} | ||
} | ||
|
||
} | ||
} | ||
|
||
/// 필터링된 ActivityReport 데이터들을 반환 | ||
return ActivityReport(totalDuration: totalActivityDuration, apps: list) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file added
BIN
+28.9 KB
...OS/HMH_iOS/Assets.xcassets/ChallengeBackground.imageset/ChallengeBackground.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+82 KB
...HMH_iOS/Assets.xcassets/ChallengeBackground.imageset/ChallengeBackground@2x.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+154 KB
...HMH_iOS/Assets.xcassets/ChallengeBackground.imageset/ChallengeBackground@3x.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
23 changes: 23 additions & 0 deletions
23
HMH_iOS/HMH_iOS/Assets.xcassets/ChallengeBackground.imageset/Contents.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
{ | ||
"images" : [ | ||
{ | ||
"filename" : "ChallengeBackground.png", | ||
"idiom" : "universal", | ||
"scale" : "1x" | ||
}, | ||
{ | ||
"filename" : "ChallengeBackground@2x.png", | ||
"idiom" : "universal", | ||
"scale" : "2x" | ||
}, | ||
{ | ||
"filename" : "ChallengeBackground@3x.png", | ||
"idiom" : "universal", | ||
"scale" : "3x" | ||
} | ||
], | ||
"info" : { | ||
"author" : "xcode", | ||
"version" : 1 | ||
} | ||
} |
23 changes: 23 additions & 0 deletions
23
HMH_iOS/HMH_iOS/Assets.xcassets/addAppButton.imageset/Contents.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
{ | ||
"images" : [ | ||
{ | ||
"filename" : "addAppButton.png", | ||
"idiom" : "universal", | ||
"scale" : "1x" | ||
}, | ||
{ | ||
"filename" : "addAppButton@2x.png", | ||
"idiom" : "universal", | ||
"scale" : "2x" | ||
}, | ||
{ | ||
"filename" : "addAppButton@3x.png", | ||
"idiom" : "universal", | ||
"scale" : "3x" | ||
} | ||
], | ||
"info" : { | ||
"author" : "xcode", | ||
"version" : 1 | ||
} | ||
} |
Binary file added
BIN
+667 Bytes
HMH_iOS/HMH_iOS/Assets.xcassets/addAppButton.imageset/addAppButton.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+1.44 KB
HMH_iOS/HMH_iOS/Assets.xcassets/addAppButton.imageset/addAppButton@2x.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+2.24 KB
HMH_iOS/HMH_iOS/Assets.xcassets/addAppButton.imageset/addAppButton@3x.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Oops, something went wrong.