LiTranslate-iOS/LiTranslate/Presentation/Component/Settings/DefaultInstancePicker.swift
Viktor Kalyniuk 823b3abe77 release v1.0
2022-09-10 20:46:05 +03:00

35 lines
979 B
Swift

//
// DefaultInstancePicker.swift
// LiTranslate
//
// Created by Viktor Kalyniuk on 22.08.2022.
//
import SwiftUI
struct DefaultInstancePicker: View {
private let defaultInstancesTitle: String = "Default Instances"
@State private var instances: Links.LibreTranslateMirrors = Links.LibreTranslateMirrors.de
@EnvironmentObject var instance: InstanceURL
var body: some View {
Picker(defaultInstancesTitle, selection: $instance.defaultURL) {
ForEach(Links.LibreTranslateMirrors.allCases, id: \.self) { url in
Text(url.rawValue)
.foregroundColor(Colors.Foreground.secondaryLabel)
}
}
.onChange(of: instance.defaultURL) { newValue in
instance.defaultURL = newValue
}
}
}
struct DefaultInstancePicker_Previews: PreviewProvider {
static var previews: some View {
DefaultInstancePicker()
.environmentObject(InstanceURL())
}
}