Skip to content

Commit

Permalink
Don’t dismiss keyboard when changing micropub textfields
Browse files Browse the repository at this point in the history
  • Loading branch information
hartlco committed May 3, 2020
1 parent 6434b32 commit 35404d5
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 13 deletions.
1 change: 0 additions & 1 deletion Icro/View/Settings/SettingsContentView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,6 @@ struct MicropubSection: View {
}, label: {
Text("Indie Auth")
})
.disabled(self.store.indieAuthMeURLString == "")
}
})
} else {
Expand Down
16 changes: 4 additions & 12 deletions Icro/ViewModel/SettingsViewModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@ final class SettingsViewModel: ObservableObject {
case none
}

var objectWillChange = ObservableObjectPublisher()

private let userSettings: UserSettings
private let notificationCenter: NotificationCenter

Expand Down Expand Up @@ -48,13 +46,11 @@ final class SettingsViewModel: ObservableObject {

@objc private func updateValues() {
self.micropubToken = userSettings.micropubToken ?? ""

objectWillChange.send()
}

let canSendMail: Bool

var isWordpressBlog: Bool {
@Published var isWordpressBlog: Bool {
didSet {
if isWordpressBlog, isMicropubBlog {
isMicropubBlog = false
Expand All @@ -81,7 +77,7 @@ final class SettingsViewModel: ObservableObject {
}
}

var isMicropubBlog: Bool {
@Published var isMicropubBlog: Bool {
didSet {
if isWordpressBlog, isMicropubBlog {
isWordpressBlog = false
Expand All @@ -96,7 +92,7 @@ final class SettingsViewModel: ObservableObject {
}
}

var micropubToken: String {
@Published var micropubToken: String {
didSet {
updateSetup()
}
Expand Down Expand Up @@ -125,8 +121,6 @@ final class SettingsViewModel: ObservableObject {
}

private func updateSetup() {
objectWillChange.send()

if isWordpressBlog,
!wordpressURL.isEmpty,
!wordpressUsername.isEmpty,
Expand All @@ -139,9 +133,7 @@ final class SettingsViewModel: ObservableObject {
userSettings.setWordpressInfo(info: nil)
}

if isMicropubBlog,
!micropubURL.isEmpty,
!micropubToken.isEmpty {
if isMicropubBlog {
let micropubInfo = UserSettings.MicropubInfo(urlString: micropubURL,
micropubToken: micropubToken)
userSettings.setMicropubInfo(info: micropubInfo)
Expand Down

0 comments on commit 35404d5

Please sign in to comment.