Fixed that keyboard covers lower part of the views and that there's been no way so scroll to the end to view
This commit is contained in:
parent
372c0ec15d
commit
cd3a24a360
|
@ -7,6 +7,7 @@
|
|||
objects = {
|
||||
|
||||
/* Begin PBXBuildFile section */
|
||||
3607829924E148D40098FEFE /* AdaptsToKeyboard.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3607829824E148D40098FEFE /* AdaptsToKeyboard.swift */; };
|
||||
366FA4DA24C472A90094F009 /* Extensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = 366FA4D924C472A90094F009 /* Extensions.swift */; };
|
||||
366FA4DC24C479120094F009 /* BankInfoListItem.swift in Sources */ = {isa = PBXBuildFile; fileRef = 366FA4DB24C479120094F009 /* BankInfoListItem.swift */; };
|
||||
366FA4E024C4924A0094F009 /* RemitteeListItem.swift in Sources */ = {isa = PBXBuildFile; fileRef = 366FA4DF24C4924A0094F009 /* RemitteeListItem.swift */; };
|
||||
|
@ -124,6 +125,7 @@
|
|||
/* End PBXCopyFilesBuildPhase section */
|
||||
|
||||
/* Begin PBXFileReference section */
|
||||
3607829824E148D40098FEFE /* AdaptsToKeyboard.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AdaptsToKeyboard.swift; sourceTree = "<group>"; };
|
||||
366FA4D924C472A90094F009 /* Extensions.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Extensions.swift; sourceTree = "<group>"; };
|
||||
366FA4DB24C479120094F009 /* BankInfoListItem.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BankInfoListItem.swift; sourceTree = "<group>"; };
|
||||
366FA4DF24C4924A0094F009 /* RemitteeListItem.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RemitteeListItem.swift; sourceTree = "<group>"; };
|
||||
|
@ -400,6 +402,7 @@
|
|||
36BE06C724D0DE7400CBBB68 /* UIKitTextField.swift */,
|
||||
36E21EDA24DC990300649DC8 /* LabelledUIKitTextField.swift */,
|
||||
36E21EDC24DCA89100649DC8 /* TanProcedurePicker.swift */,
|
||||
3607829824E148D40098FEFE /* AdaptsToKeyboard.swift */,
|
||||
);
|
||||
path = ui;
|
||||
sourceTree = "<group>";
|
||||
|
@ -645,6 +648,7 @@
|
|||
36E21ED124DC540400649DC8 /* SettingsDialog.swift in Sources */,
|
||||
366FA4DC24C479120094F009 /* BankInfoListItem.swift in Sources */,
|
||||
36FC929E24B39A05002B12E9 /* SceneDelegate.swift in Sources */,
|
||||
3607829924E148D40098FEFE /* AdaptsToKeyboard.swift in Sources */,
|
||||
36E21ECF24DA0EEE00649DC8 /* IconView.swift in Sources */,
|
||||
36BCF88524C098C8005BEC29 /* BankAccountListItem.swift in Sources */,
|
||||
36FC92EF24B3BB81002B12E9 /* AddAccountDialog.swift in Sources */,
|
||||
|
|
|
@ -0,0 +1,39 @@
|
|||
import SwiftUI
|
||||
import Combine
|
||||
|
||||
|
||||
/**
|
||||
By default the keyboard covers the lower part of views - and there's not way to scroll down to the end of the dialog.
|
||||
|
||||
Found a solution to fix this bug by : https://stackoverflow.com/a/60178361/8837882.
|
||||
*/
|
||||
struct AdaptsToKeyboard: ViewModifier {
|
||||
|
||||
@State var currentHeight: CGFloat = 0
|
||||
|
||||
|
||||
func body(content: Content) -> some View {
|
||||
GeometryReader { geometry in
|
||||
content
|
||||
.padding(.bottom, self.currentHeight)
|
||||
.animation(.easeOut(duration: 0.16))
|
||||
.onAppear(perform: {
|
||||
NotificationCenter.Publisher(center: NotificationCenter.default, name: UIResponder.keyboardWillShowNotification)
|
||||
.merge(with: NotificationCenter.Publisher(center: NotificationCenter.default, name: UIResponder.keyboardWillChangeFrameNotification))
|
||||
.compactMap { notification in
|
||||
notification.userInfo?["UIKeyboardFrameEndUserInfoKey"] as? CGRect
|
||||
}
|
||||
.map { rect in
|
||||
rect.height - geometry.safeAreaInsets.bottom
|
||||
}
|
||||
.subscribe(Subscribers.Assign(object: self, keyPath: \.currentHeight))
|
||||
|
||||
NotificationCenter.Publisher(center: NotificationCenter.default, name: UIResponder.keyboardWillHideNotification)
|
||||
.compactMap { notification in
|
||||
CGFloat.zero
|
||||
}
|
||||
.subscribe(Subscribers.Assign(object: self, keyPath: \.currentHeight))
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
|
@ -4,6 +4,10 @@ import BankingUiSwift
|
|||
|
||||
extension View {
|
||||
|
||||
func fixKeyboardCoversLowerPart() -> some View {
|
||||
return self.modifier(AdaptsToKeyboard())
|
||||
}
|
||||
|
||||
func hideNavigationBar() -> some View {
|
||||
return self
|
||||
.navigationBarHidden(true)
|
||||
|
|
|
@ -58,6 +58,7 @@ struct AddAccountDialog: View {
|
|||
.alert(item: $errorMessage) { message in
|
||||
Alert(title: message.title, message: message.message, dismissButton: message.primaryButton)
|
||||
}
|
||||
.fixKeyboardCoversLowerPart()
|
||||
.showNavigationBarTitle("Add account")
|
||||
}
|
||||
|
||||
|
|
|
@ -63,6 +63,7 @@ struct BankAccountSettingsDialog: View {
|
|||
.alert(item: $unsavedChangesMessage) { message in
|
||||
Alert(title: message.title, message: message.message, primaryButton: message.primaryButton, secondaryButton: message.secondaryButton!)
|
||||
}
|
||||
.fixKeyboardCoversLowerPart()
|
||||
.showNavigationBarTitle(LocalizedStringKey(account.displayName))
|
||||
.setCancelAndDoneNavigationBarButtons(onCancelPressed: cancelPressed, onDonePressed: donePressed)
|
||||
}
|
||||
|
|
|
@ -95,6 +95,7 @@ struct BankSettingsDialog: View {
|
|||
.alert(item: $askToDeleteAccountMessage) { message in
|
||||
Alert(title: message.title, message: message.message, primaryButton: message.primaryButton, secondaryButton: message.secondaryButton!)
|
||||
}
|
||||
.fixKeyboardCoversLowerPart()
|
||||
.showNavigationBarTitle(LocalizedStringKey(bank.displayName))
|
||||
.setCancelAndDoneNavigationBarButtons(onCancelPressed: cancelPressed, onDonePressed: donePressed)
|
||||
}
|
||||
|
|
|
@ -128,6 +128,7 @@ struct EnterTanDialog: View {
|
|||
.alert(item: $errorMessage) { message in
|
||||
Alert(title: message.title, message: message.message, dismissButton: message.primaryButton)
|
||||
}
|
||||
.fixKeyboardCoversLowerPart()
|
||||
.showNavigationBarTitle("Enter TAN Dialog Title")
|
||||
.customNavigationBarBackButton {
|
||||
self.sendEnterTanResult(EnterTanResult.Companion().userDidNotEnterTan())
|
||||
|
|
|
@ -67,6 +67,7 @@ struct SelectBankDialog: View {
|
|||
.alert(item: $errorMessage) { message in
|
||||
Alert(title: message.title, message: message.message, dismissButton: message.primaryButton)
|
||||
}
|
||||
.fixKeyboardCoversLowerPart()
|
||||
.showNavigationBarTitle("Select Bank Dialog Title")
|
||||
}
|
||||
|
||||
|
|
|
@ -155,6 +155,7 @@ struct TransferMoneyDialog: View {
|
|||
return Alert(title: message.title, message: message.message, dismissButton: message.primaryButton)
|
||||
}
|
||||
}
|
||||
.fixKeyboardCoversLowerPart()
|
||||
.showNavigationBarTitle("Transfer Money Dialog Title")
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue