LiTranslate-iOS/LiTranslate/Presentation/Component/Settings/SelfHostingView.swift
Viktor 5ac00486dc
release v1.1 (#1)
Now speech synthesizer works in silent mode.
Fixing iOS 16 compatibility:
- Speech syntesizer
- Colors
2022-10-24 20:52:38 +03:00

76 lines
2.3 KiB
Swift

//
// SelfHostingView.swift
// LiTranslate
//
// Created by Viktor Kalyniuk on 22.08.2022.
//
import SwiftUI
struct SelfHostingView: View {
@EnvironmentObject var instance: InstanceURL
@Environment(\.presentationMode) var mode: Binding<PresentationMode>
@State private var input: String = ""
private let selfHostingTitle = "Self Hosting"
private let textFieldTitle = "url"
private let useInstanceTitle = "Use default instance"
private let infoTitle = "Info"
private let instructionTitle = "Instruction"
private let doneTitle = "Done"
var body: some View {
List {
Section(selfHostingTitle) {
TextField(textFieldTitle, text: $input)
.onAppear {
input = instance.selfHostURL
}
.listRowBackground(Colors.Background.primaryView)
.foregroundColor(Colors.Foreground.label)
}
.textCase(nil)
Button {
instance.selfHostURL = ""
self.mode.wrappedValue.dismiss()
} label: {
Text(useInstanceTitle)
.foregroundColor(Colors.Foreground.label)
}
.listRowBackground(Colors.Background.primaryView)
Section(infoTitle) {
if let url = URL(string: Links.Info.libreTranslateHosting) {
Link(destination: url) {
HStack {
Text(instructionTitle)
Spacer()
Image(systemName: SystemNames.openLink)
}
.foregroundColor(Colors.Foreground.label)
}
}
}
.listRowBackground(Colors.Background.primaryView)
.textCase(nil)
}
.modifier(ScrollContentBackgroundModifier())
.background(Colors.Background.mainView)
.toolbar {
Button {
instance.selfHostURL = input
self.mode.wrappedValue.dismiss()
} label: {
Text(doneTitle)
}
}
}
}
struct SelfHostingView_Previews: PreviewProvider {
static var previews: some View {
SelfHostingView()
.environmentObject(InstanceURL())
}
}