pushdeer/ios/PushDeer-iOS/PushDeer/View/Common/EditableText.swift
hext 2136883536 支持微信登录, 修复一些bug:
支持微信登录, 支持同时绑定微信和苹果账号;
解决markdown标题文字显示不全的问题;
markdown中的链接支持内嵌浏览器打开;
增加是否使用内置浏览器的设置项;
改名输入框, 失去焦点的时候也保存;
2022-02-27 23:02:58 +08:00

47 lines
1.0 KiB
Swift

//
// EditableText.swift
// PushDeer
//
// Created by HEXT on 2022/1/10.
//
import SwiftUI
struct EditableText: View {
var placeholder = ""
@State var value = ""
var onCommit: (_ value: String) -> Void = { value in
}
var body: some View {
TextField(placeholder, text: $value, onEditingChanged: { focus in
print("focus", focus, placeholder, value)
if !focus {
//
self.onCommit(value)
}
}, onCommit: {
// enter, 使
// print(":", value)
// self.onCommit(value)
})
.font(.system(size: 20))
.foregroundColor(Color.accentColor)
.submitLabelDone()
}
}
struct EditableText_Previews: PreviewProvider {
static var previews: some View {
VStack {
EditableText(value: "你好")
EditableText(placeholder: "请输入")
EditableText()
EditableText(placeholder: "请输入") { value in
}
}
}
}