LiTranslate-iOS/LiTranslate/Presentation/Component/Settings/DefaultInstancePicker.swift

36 lines
979 B
Swift
Raw Normal View History

2022-09-10 19:46:05 +02:00
//
// 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())
}
}