Commit 460c8567 authored by sugita mamoru's avatar sugita mamoru

webView実装、スライダー修正、メニュー画面変更

parent f2d52421
......@@ -44,10 +44,13 @@
022789092AE1FE4C00A87787 /* Turf.xcframework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 022788F72AE1FE3C00A87787 /* Turf.xcframework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
0227890C2AE22E0B00A87787 /* SharingData.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0227890B2AE22E0B00A87787 /* SharingData.swift */; };
022A98202AF8B8960079C55A /* LocationCalculation.swift in Sources */ = {isa = PBXBuildFile; fileRef = 022A981F2AF8B8960079C55A /* LocationCalculation.swift */; };
024EDE1B2B0C41E40013BAC8 /* MenuSettingView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 024EDE1A2B0C41E40013BAC8 /* MenuSettingView.swift */; };
024EDE1D2B0C42F70013BAC8 /* MenuGpsSelectView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 024EDE1C2B0C42F70013BAC8 /* MenuGpsSelectView.swift */; };
025C27FA2AFE119D00BADC49 /* MenuTitleView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 025C27F92AFE119D00BADC49 /* MenuTitleView.swift */; };
025C27FC2AFE191A00BADC49 /* MenuManualView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 025C27FB2AFE191A00BADC49 /* MenuManualView.swift */; };
025C27FE2B0206D700BADC49 /* PDFDownloadManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = 025C27FD2B0206D700BADC49 /* PDFDownloadManager.swift */; };
025C28002B034A1900BADC49 /* PDFViewer.swift in Sources */ = {isa = PBXBuildFile; fileRef = 025C27FF2B034A1900BADC49 /* PDFViewer.swift */; };
027EF9F22B0D804C0079B825 /* WebView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 027EF9F12B0D804C0079B825 /* WebView.swift */; };
02A1DE2F2AFB4AA0005BCF55 /* ChatInputView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 02A1DE2E2AFB4AA0005BCF55 /* ChatInputView.swift */; };
02A1DE312AFB61D8005BCF55 /* MyChatContentView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 02A1DE302AFB61D8005BCF55 /* MyChatContentView.swift */; };
02A1DE332AFB654A005BCF55 /* CustomCornerRadius.swift in Sources */ = {isa = PBXBuildFile; fileRef = 02A1DE322AFB654A005BCF55 /* CustomCornerRadius.swift */; };
......@@ -167,10 +170,13 @@
022788FA2AE1FE3D00A87787 /* MapboxMaps.xcframework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.xcframework; path = MapboxMaps.xcframework; sourceTree = "<group>"; };
0227890B2AE22E0B00A87787 /* SharingData.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SharingData.swift; sourceTree = "<group>"; };
022A981F2AF8B8960079C55A /* LocationCalculation.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = LocationCalculation.swift; path = Sailassist/Location/LocationCalculation.swift; sourceTree = SOURCE_ROOT; };
024EDE1A2B0C41E40013BAC8 /* MenuSettingView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; name = MenuSettingView.swift; path = Sailassist/Menu/View/MenuSettingView.swift; sourceTree = SOURCE_ROOT; };
024EDE1C2B0C42F70013BAC8 /* MenuGpsSelectView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; name = MenuGpsSelectView.swift; path = Sailassist/Menu/View/MenuGpsSelectView.swift; sourceTree = SOURCE_ROOT; };
025C27F92AFE119D00BADC49 /* MenuTitleView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; name = MenuTitleView.swift; path = Sailassist/Menu/View/MenuTitleView.swift; sourceTree = SOURCE_ROOT; };
025C27FB2AFE191A00BADC49 /* MenuManualView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; name = MenuManualView.swift; path = Sailassist/Menu/View/MenuManualView.swift; sourceTree = SOURCE_ROOT; };
025C27FD2B0206D700BADC49 /* PDFDownloadManager.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; name = PDFDownloadManager.swift; path = Sailassist/ServerSession/PDFDownloadManager.swift; sourceTree = SOURCE_ROOT; };
025C27FF2B034A1900BADC49 /* PDFViewer.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; name = PDFViewer.swift; path = Sailassist/Menu/View/PDFViewer.swift; sourceTree = SOURCE_ROOT; };
027EF9F12B0D804C0079B825 /* WebView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; name = WebView.swift; path = Sailassist/WebView.swift; sourceTree = SOURCE_ROOT; };
02A1DE2E2AFB4AA0005BCF55 /* ChatInputView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; name = ChatInputView.swift; path = Sailassist/Chat/View/ChatInputView.swift; sourceTree = SOURCE_ROOT; };
02A1DE302AFB61D8005BCF55 /* MyChatContentView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; name = MyChatContentView.swift; path = Sailassist/Chat/View/MyChatContentView.swift; sourceTree = SOURCE_ROOT; };
02A1DE322AFB654A005BCF55 /* CustomCornerRadius.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; name = CustomCornerRadius.swift; path = Sailassist/Chat/View/CustomCornerRadius.swift; sourceTree = SOURCE_ROOT; };
......@@ -314,6 +320,7 @@
D5CB6F9A2B021C4F00EC2010 /* LocationViewModel.swift */,
D5CB6F9C2B02203500EC2010 /* RequestLocationView.swift */,
D5CB6F9E2B0220A700EC2010 /* ErrorView.swift */,
027EF9F12B0D804C0079B825 /* WebView.swift */,
);
path = SailAssist;
sourceTree = "<group>";
......@@ -527,6 +534,8 @@
025C27F92AFE119D00BADC49 /* MenuTitleView.swift */,
025C27FB2AFE191A00BADC49 /* MenuManualView.swift */,
025C27FF2B034A1900BADC49 /* PDFViewer.swift */,
024EDE1A2B0C41E40013BAC8 /* MenuSettingView.swift */,
024EDE1C2B0C42F70013BAC8 /* MenuGpsSelectView.swift */,
);
path = View;
sourceTree = "<group>";
......@@ -870,6 +879,7 @@
020B98412AD8C3810029DE4C /* LoginView.swift in Sources */,
D5AE351D2AEBA6FC00059889 /* SessionLogin.swift in Sources */,
D5258C9F2B03527400365276 /* ResGetMessages.swift in Sources */,
024EDE1B2B0C41E40013BAC8 /* MenuSettingView.swift in Sources */,
020B98552AD924930029DE4C /* QrCodeScannerView.swift in Sources */,
02CE4D7F2ADE42A9002E79BC /* MenuContentView.swift in Sources */,
D5AE351B2AEBA66A00059889 /* ResLogin.swift in Sources */,
......@@ -886,6 +896,7 @@
02CE4D852ADF6295002E79BC /* TaskSwitchingMenuView.swift in Sources */,
D5CB6F9F2B0220A700EC2010 /* ErrorView.swift in Sources */,
D5CB6F992B02088C00EC2010 /* ResShipStatus.swift in Sources */,
027EF9F22B0D804C0079B825 /* WebView.swift in Sources */,
020B984B2AD915810029DE4C /* QRReadView.swift in Sources */,
02A1DE332AFB654A005BCF55 /* CustomCornerRadius.swift in Sources */,
D545FC762B09C81300F206D0 /* PushNotificationTypes.swift in Sources */,
......@@ -919,6 +930,7 @@
02CE4D872ADF62A7002E79BC /* EcaListView.swift in Sources */,
020B986C2ADD3E810029DE4C /* InTextLib.swift in Sources */,
02C3E5D12AFCC16800AF7837 /* ChatTitleView.swift in Sources */,
024EDE1D2B0C42F70013BAC8 /* MenuGpsSelectView.swift in Sources */,
020B98472AD8FEE30029DE4C /* ColorSet.swift in Sources */,
D51AA4072B099FCC00EBBDD4 /* AlertDB.swift in Sources */,
020B98652ADD14F60029DE4C /* NotificationView.swift in Sources */,
......
......@@ -8,6 +8,7 @@
import SwiftUI
struct ChatView: View {
@EnvironmentObject private var selectedTabModel: SelectedTabModel
@ObservedObject var message = SharingData.message
@State var isShowMember: Bool = false
var body: some View {
......@@ -40,11 +41,7 @@ struct ChatView: View {
Spacer()
VStack{
Button{
if message.mode == 0{
message.mode = 1
}else{
message.mode = 0
}
selectedTabModel.isShowChangeEmrMode.toggle()
}label: {
Image(systemName: "exclamationmark.triangle.fill")
.foregroundColor(.white)
......
......@@ -196,8 +196,8 @@ class MapViewController : UIViewController{
switchingLabels.append(label)
}
var lineGeoJson = FeatureCollection(features: switchingLines)
var labelGeoJson = FeatureCollection(features: switchingLabels)
let lineGeoJson = FeatureCollection(features: switchingLines)
let labelGeoJson = FeatureCollection(features: switchingLabels)
try self.mapView.mapboxMap.style.updateGeoJSONSource(withId: ecaSwitchingLine.sourceId, geoJSON: .featureCollection(lineGeoJson))
try self.mapView.mapboxMap.style.updateGeoJSONSource(withId: ecaSwLineLabel.sourceId, geoJSON: .featureCollection(labelGeoJson))
}catch{}
......
......@@ -14,17 +14,26 @@ struct EcaSettingView: View {
var body: some View {
VStack(spacing: 0){
SliderView(param: $edittingEca.swFinish, title: "Switching Finish - ECA")
SwSliderView(data: $edittingEca, type: .Finish)
.padding(.horizontal, 30)
.padding(.vertical, 17)
Divider()
SliderView(param: $edittingEca.swStart, title: "Switching Start - ECA")
.frame(height: 1)
.background(ColorSet.LineColor04.color)
SwSliderView(data: $edittingEca, type: .Start)
.padding(.horizontal, 30)
.padding(.vertical, 17)
Divider()
SliderView(param: $edittingEca.swNotice, title: "Switching Notice - ECA")
.frame(height: 1)
.background(ColorSet.LineColor04.color)
SwSliderView(data: $edittingEca, type: .Notice)
.padding(.horizontal, 30)
.padding(.vertical, 17)
Divider()
.frame(height: 1)
.background(ColorSet.LineColor04.color)
Button(action: {
......@@ -40,27 +49,63 @@ struct EcaSettingView: View {
.background(ColorSet.PrimaryActiveIcon.color)
.cornerRadius(30)
.padding(.vertical, 20)
.disabled(!checkSwitchingDistance())
}
}
}
fileprivate struct SliderView: View {
init(param: Binding<Float>, title: String, min: Float = 1, max: Float = 10) {
private func checkSwitchingDistance() -> Bool{
let notice = edittingEca.swNotice
let start = edittingEca.swStart
let finish = edittingEca.swFinish
return notice > start && notice > finish && start > finish
}
struct SwSliderView: View {
@Binding var data : RegisteredEca
@Binding var param : Float
var type: SwType
var min : Float = 1
var max : Float = 10
init(data: Binding<RegisteredEca>, type: SwType) {
let thumb = UIImage(systemName: "circle.fill")
UISlider.appearance().setThumbImage(thumb, for: .normal)
UISlider.appearance().maximumTrackTintColor = UIColor(ColorSet.Slidebar.color)
self._param = param
self.title = title
self.min = min
self.max = max
self._data = data
self._param = type == .Notice ? data.swNotice : type == .Start ? data.swStart : data.swFinish
self.type = type
switch type{
case .Finish:
self.max = data.swStart.wrappedValue <= 2 ? 2 : data.swStart.wrappedValue - 1
case .Start:
self.min = data.swFinish.wrappedValue
self.max = data.swNotice.wrappedValue
case .Notice:
self.min = data.swStart.wrappedValue >= 9 ? 9 : data.swStart.wrappedValue + 1
}
}
enum SwType: String{
case Notice
case Start
case Finish
var title: String {
switch self {
case .Notice:
"Switching Notice - ECA"
case .Start:
"Switching Start - ECA"
case .Finish:
"Switching Finish - ECA"
}
}
}
@Binding var param: Float
let title: String
var min : Float = 1
var max : Float = 10
var body: some View {
VStack(alignment: .leading){
Text(title)
Text(type.title)
.font(FontStyle.EmphasisText.font)
HStack(alignment: .bottom){
......@@ -74,7 +119,26 @@ fileprivate struct SliderView: View {
HStack(spacing: 9){
Button(action: {
switch type{
case .Finish:
break
case .Start:
if data.swFinish >= param - 1 && param > 2{
data.swFinish -= 1
}
if param <= 2{
return
}
case .Notice:
if data.swNotice - data.swStart <= 1{
data.swStart -= 1
if data.swStart <= data.swFinish{
data.swFinish = data.swStart - 1
}
}
}
param -= 1
}, label: {
Image(systemName: "minus.circle")
.resizable()
......@@ -82,10 +146,51 @@ fileprivate struct SliderView: View {
})
.disabled(param <= min)
Slider(value: $param, in: min...max, step: 1)
Slider(value: $param, in: min...max, step: 1){_ in
if type == .Start{
if param == min{
param += 1
}
if param == max{
param -= 1
}
}else if type == .Notice{
if param <= data.swStart{
data.swStart = param - 1
if data.swStart <= data.swFinish{
data.swFinish = data.swStart - 1
}
}
}else if type == .Finish{
if param >= data.swStart{
data.swStart = param + 1
if data.swStart >= data.swNotice{
data.swNotice = data.swStart + 1
}
}
}
}
Button(action: {
switch type{
case .Finish:
if data.swStart - data.swFinish <= 1{
data.swStart += 1
if data.swStart >= data.swNotice{
data.swNotice = data.swStart + 1
}
}
case .Start:
if data.swNotice <= param + 1 && param < 9{
data.swNotice += 1
}
if param >= 9{
return
}
case .Notice:
break
}
param += 1
}, label: {
Image(systemName: "plus.circle")
......@@ -98,9 +203,11 @@ fileprivate struct SliderView: View {
}
.tint(ColorSet.SlidebarActive.color)
.foregroundColor(ColorSet.SlidebarActive.color)
}
.foregroundColor(ColorSet.Body.color)
}
}
}
#Preview {
......
......@@ -14,6 +14,8 @@ enum MenuPath: String, Hashable{
case ManualRADAR
case ManualJmarineNeCST
case Information
case Setting
case GpsSelect
case Help
case AboutApp
case ContactUs
......@@ -30,6 +32,10 @@ enum MenuPath: String, Hashable{
"J-marine NeCST"
case .Information:
"Information"
case .Setting:
"Setting"
case .GpsSelect:
"Fuel Switching GPS Select"
case .Help:
"Help"
case .AboutApp:
......@@ -79,21 +85,9 @@ struct MenuView: View {
}
Button{
path.append(.Help)
path.append(.Setting)
}label: {
MenuContentView(content: .Help)
}
Button{
path.append(.AboutApp)
}label: {
MenuContentView(content: .AboutApp)
}
Button{
path.append(.ContactUs)
}label: {
MenuContentView(content: .ContactUs)
MenuContentView(content: .Setting)
}
Spacer()
......@@ -105,6 +99,12 @@ struct MenuView: View {
if goto == .Manual{
MenuManualView(path: $path)
.navigationBarHidden(true)
}else if goto == .Setting{
MenuSettingView(path: $path)
.navigationBarHidden(true)
}else if goto == .GpsSelect{
MenuGpsSelectView(path: $path)
.navigationBarHidden(true)
}else{
VStack(spacing: 0) {
MenuTitleView(path: $path, title: goto.title)
......
//
// MenuGpsSelectView.swift
// Sailassist
//
// Created by Mamoru Sugita on 2023/11/21.
//
import SwiftUI
struct MenuGpsSelectView: View {
@Binding var path : [MenuPath]
@State var selected : GpsSelect = .Mobile
enum GpsSelect: String, CaseIterable{
case Mobile
case Cloud
var title: String{
switch self {
case .Mobile:
"Mobile Phone GPS"
case .Cloud:
"Cloud GPS"
}
}
}
var body: some View {
VStack{
MenuTitleView(path: $path, title: MenuPath.Setting.title)
ForEach(GpsSelect.allCases, id:\.rawValue){ content in
SelectContentView(selected: $selected, content: content)
}
Spacer()
}
.background(ColorSet.BackgroundPrimary.color)
}
struct SelectContentView: View {
@Binding var selected : GpsSelect
var content : GpsSelect
var body: some View {
VStack(spacing: 0){
Button{
selected = content
}label:{
HStack {
Text(content.title)
.font(FontStyle.EmphasisText.font)
.foregroundColor(ColorSet.Body.color)
Spacer()
if selected == content{
Image(systemName: "checkmark.square.fill")
.resizable()
.frame(width: 22, height: 22)
}else{
Image(systemName: "square")
.resizable()
.frame(width: 22, height: 22)
}
}
.padding(.vertical, 17)
.padding(.horizontal, 30)
}
Divider()
.background(ColorSet.LineColor04.color)
}
}
}
}
#Preview {
MenuGpsSelectView(path: .constant([.Setting]))
}
//
// MenuSettingView.swift
// Sailassist
//
// Created by Mamoru Sugita on 2023/11/21.
//
import SwiftUI
struct MenuSettingView: View {
@Binding var path : [MenuPath]
var body: some View {
VStack{
MenuTitleView(path: $path, title: MenuPath.Setting.title)
Button{
path.append(.GpsSelect)
}label: {
MenuContentView(content: .GpsSelect)
}
Button{
path.append(.Help)
}label: {
MenuContentView(content: .Help)
}
Button{
path.append(.AboutApp)
}label: {
MenuContentView(content: .AboutApp)
}
Button{
path.append(.ContactUs)
}label: {
MenuContentView(content: .ContactUs)
}
Spacer()
}
.background(ColorSet.BackgroundPrimary.color)
}
}
#Preview {
MenuSettingView(path: .constant([.Setting]))
}
......@@ -89,6 +89,20 @@ struct CustomTabBar: View {
.frame(height: 50)
}
.background(ColorSet.BottomNav.color)
.alert("", isPresented: $selectedTabModel.isShowChangeEmrMode) {
Button("Yes"){
if SharingData.message.mode == 0{
SharingData.message.mode = 1
}else{
SharingData.message.mode = 0
}
}
Button("No"){
}
} message: {
Text("Do you change an emargency mode?")
}
}
}
......
......@@ -10,4 +10,5 @@ import SwiftUI
//@Observable
class SelectedTabModel: ObservableObject {
@Published var activeTab: Tab = .task
@Published var isShowChangeEmrMode: Bool = false
}
//
// WebView.swift
// Sailassist
//
// Created by Mamoru Sugita on 2023/11/22.
//
import SwiftUI
import WebKit
struct WebView: UIViewRepresentable {
@Binding var isLoading: Bool
var url : String
func makeUIView(context: Context) -> WKWebView {
let request = URLRequest(url: URL(string: url)!)
let webView = WKWebView()
webView.navigationDelegate = context.coordinator
webView.load(request)
return webView
}
func updateUIView(_ uiView: WKWebView, context: Context) {}
func makeCoordinator() -> Coordinator {
return Coordinator(owner: self)
}
class Coordinator: NSObject, WKNavigationDelegate {
private let owner: WebView
init(owner: WebView) {
self.owner = owner
super.init()
}
func webView(_ webView: WKWebView, didStartProvisionalNavigation navigation: WKNavigation!) {
owner.isLoading = true
}
func webView(_ webView: WKWebView, didFinish navigation: WKNavigation!) {
owner.isLoading = false
}
}
}
#Preview {
WebView(isLoading: .constant(false), url: "https://ssv-canary-web.azurewebsites.net/login?ReturnUrl=%2F")
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment