76 lines
2.4 KiB
Swift
76 lines
2.4 KiB
Swift
//
|
|
// SwitchableView.swift
|
|
// Feels (iOS)
|
|
//
|
|
// Created by Trey Tartt on 1/30/22.
|
|
//
|
|
|
|
import SwiftUI
|
|
|
|
|
|
struct SwitchableView: View {
|
|
@State var currentViewIdx = 0
|
|
@AppStorage(UserDefaultsStore.Keys.theme.rawValue, store: GroupUserDefaults.groupDefaults) private var theme: Theme = .system
|
|
|
|
let daysBack: Int
|
|
|
|
var body: some View {
|
|
VStack {
|
|
ZStack {
|
|
HeaderStatsView(fakeData: false, backDays: daysBack)
|
|
.opacity(currentViewIdx == 0 ? 1 : 0)
|
|
.padding([.leading, .trailing], -20)
|
|
.padding([.top, .bottom], 8)
|
|
.allowsHitTesting(false)
|
|
|
|
HeaderPercView(fakeData: false, backDays: daysBack, type: .circular)
|
|
.opacity(currentViewIdx == 1 ? 1 : 0)
|
|
.allowsHitTesting(false)
|
|
|
|
HeaderPercView(fakeData: false, backDays: daysBack, type: .text)
|
|
.opacity(currentViewIdx == 2 ? 1 : 0)
|
|
.allowsHitTesting(false)
|
|
|
|
VStack {
|
|
HStack {
|
|
Spacer()
|
|
Image(systemName: "arrow.triangle.2.circlepath.circle")
|
|
.resizable()
|
|
.frame(width: 20, height: 20, alignment: .trailing)
|
|
}
|
|
Spacer()
|
|
}
|
|
.padding(.trailing, 8)
|
|
.padding(.top, 12)
|
|
.allowsHitTesting(false)
|
|
.foregroundColor(Color(UIColor.systemGray))
|
|
}
|
|
.padding(.top, -7)
|
|
|
|
Text(String(format: String(localized: "content_view_header_title"), daysBack))
|
|
.font(.body)
|
|
.foregroundColor(Color(UIColor.systemGray))
|
|
.frame(maxWidth: .infinity, alignment: .center)
|
|
.padding(.top, -12)
|
|
}
|
|
.background(
|
|
Color(theme.currentTheme.secondaryBGColor)
|
|
)
|
|
.contentShape(Rectangle())
|
|
.cornerRadius(10, corners: [.topLeft, .topRight, .bottomLeft, .bottomRight])
|
|
.padding(.bottom, 30)
|
|
.onTapGesture {
|
|
currentViewIdx += 1
|
|
if currentViewIdx == 3 {
|
|
currentViewIdx = 0
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
struct SwitchableView_Previews: PreviewProvider {
|
|
static var previews: some View {
|
|
SwitchableView(daysBack: 30)
|
|
}
|
|
}
|