Files
Reflect/Shared/views/SwitchableView.swift
Trey t 9afbfb2e8e closed #52
added logic to remember tabview but it doesnt work
2022-01-30 19:49:43 -06:00

68 lines
1.9 KiB
Swift

//
// SwitchableView.swift
// Feels (iOS)
//
// Created by Trey Tartt on 1/30/22.
//
import SwiftUI
struct SwitchableView: View {
@State var currentViewIdx = 0
let daysBack: Int
var body: some View {
VStack {
ZStack {
HeaderStatsView(fakeData: false, backDays: daysBack)
.opacity(currentViewIdx == 0 ? 1 : 0)
.allowsHitTesting(false)
HeaderPercView(fakeData: false, backDays: daysBack)
.opacity(currentViewIdx == 1 ? 1 : 0)
.allowsHitTesting(false)
VStack {
HStack {
Spacer()
Image(systemName: "arrow.triangle.2.circlepath.circle")
.resizable()
.frame(width: 25, height: 25, alignment: .trailing)
}
Spacer()
}
.padding(.trailing, 8)
.padding(.top, 8)
.allowsHitTesting(false)
}
.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(UIColor.systemBackground)
)
.clipShape(RoundedRectangle(cornerRadius: 25, style: .continuous))
.contentShape(Rectangle())
.padding(.bottom, 30)
.onTapGesture {
currentViewIdx += 1
if currentViewIdx == 2 {
currentViewIdx = 0
}
}
}
}
struct SwitchableView_Previews: PreviewProvider {
static var previews: some View {
SwitchableView(daysBack: 30)
}
}