-
Notifications
You must be signed in to change notification settings - Fork 0
/
HabitsApp.swift
81 lines (73 loc) · 1.85 KB
/
HabitsApp.swift
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
//
// HabitsApp.swift
// Habits
//
// Created by Mathis Le Bonniec on 10/02/2024.
//
import OnBoardingKit
import SwiftUI
import TipKit
@main
struct HabitsApp: App {
// MARK: Body
var body: some Scene {
WindowGroup {
ContentView()
.environmentObject(HabitsNotificationsDelegate())
}
}
}
struct ContentView: View {
// MARK: Private Properties
@State private var activeTab: AppTabView = .habits
@EnvironmentObject private var notificationDelegate: HabitsNotificationsDelegate
// MARK: Body
var body: some View {
TabView(selection: $activeTab) {
HabitsListFactory.createView()
.tabItem(
label: "Habits",
systemImage: "checklist",
activeSystemImage: "checklist.checked",
tag: .habits,
activeTab: activeTab
)
HabitsScheduleFactory.createView()
.tabItem(
label: "Schedule",
systemImage: "calendar",
tag: .calendar,
activeTab: activeTab
)
HabitsHistoryFactory.createView()
.tabItem(
label: "History",
systemImage: "clock.arrow.circlepath",
tag: .history,
activeTab: activeTab
)
}
.task {
if #available(iOS 17.0, *) {
// MARK: Demo purpose only
try? Tips.resetDatastore()
try? Tips.configure([
.displayFrequency(.immediate),
.datastoreLocation(.applicationDefault)
])
}
}
.onAppear {
NotificationsHelper.resetBadgeCount()
// MARK: Demo purpose only
OnBoardingKit.resetDatastore()
}
.sheet(item: $notificationDelegate.shownDetails) { id in
if let habit = HabitsMapper.mapById(id: id) {
HabitDetailsFactory.createView(habit: habit)
.navigable()
}
}
.presentOnBoarding(HabitsOnBoarding(), mode: .sheet)
}
}