ConstValue.swift
//
// ConstValue.swift
// TwentyFivePuzzle
//
// Created by akira ohmachi on 2022/05/31.
//
import SwiftUI
class ConstValue: ObservableObject {
static let colorBg: Color = Color.init(red:1, green:1, blue:1)
static let colorStart: Color = Color.init(red:0.274, green:0.27, blue:0.972)
static let colorSetting: Color = Color.init(red:0.294, green:0.45, blue:0.972)
}
ContentView.swift
//
// ContentView.swift
// TwentyFivePuzzle
//
// Created by akira ohmachi on 2022/05/31.
//
import SwiftUI
import GoogleMobileAds
import UIKit
struct ContentView: View {
@EnvironmentObject var pub: PublicManager
@State private var destroyFlag: Bool = false
@State private var webViewQueryString: String = "?dummy"
private var dateFormatter: DateFormatter = DateFormatter()
var body: some View {
NavigationView {
GeometryReader { bodyView in
VStack(spacing: 0) {
Rectangle().fill(Color.white).frame(width: bodyView.size.width,height: 1)
HStack(spacing: 0) {
Button(action:{
self.webViewQueryString = "?s=1&dateTime=" + dateFormatter.string(from: Date())
}){
Text("start")
.frame(width:bodyView.size.width * 0.7, height: 50, alignment: .center)
.background(ConstValue.colorStart)
.foregroundColor(Color.white)
}
Rectangle().fill(Color.white).frame(width: 1,height: 50)
VStack(spacing: 0) {
NavigationLink(destination: SettingView(),isActive: self.$pub.isSetting) {
Button(action:{
self.pub.isSetting = true
}){
Text("setting")
.frame(width:bodyView.size.width * 0.3, height: 50, alignment: .center)
.background(ConstValue.colorSetting)
.foregroundColor(Color.white)
}
}
}
}
.frame(width:bodyView.size.width, height:50)
Rectangle().fill(Color.white).frame(width: bodyView.size.width,height: 1)
ZStack(alignment: .bottom) {
VStack {
Spacer()
VStack {
WebView(queryString: self.webViewQueryString)
}.frame(width:bodyView.size.width, height:bodyView.size.width)
Spacer()
Spacer()
}
HStack(spacing: 0) {
Spacer(minLength: 0)
PublicManager.AdView().frame(maxWidth: bodyView.size.width, maxHeight: 50)
Spacer(minLength: 0)
}.background(Color(red:0.2,green:0.2,blue:0.2))
}
}
.background(ConstValue.colorBg)
//.navigationBarTitle("")
.navigationBarHidden(true)
}
}
.navigationViewStyle(StackNavigationViewStyle())
.onAppear { //アプリ実行時
self.dateFormatter.dateFormat = "yyyyMMddHHmmss"
}
.onDisappear { //アプリ終了時
self.destroyFlag = true
}
}
}
struct ContentView_Previews: PreviewProvider {
static var previews: some View {
ContentView().environmentObject(PublicManager())
}
}