Comments (13)
You have to create it your self. But it's easy. This should be enough to get you started. ( I stripped a bunch of stuff out of some live code so I won't guarantee it compiles. 😄 )
class GerbilPageItem: BLTNPageItem {
public private(set) var textField: UITextField!
override init(title: String) {
super.init(title: "Title")
self.descriptionText = "Description"
self.actionButtonTitle = "Ok"
self.isDismissable = true
self.alternativeButtonTitle = "Cancel"
self.presentationHandler = { (_ item: BLTNItem) in
self.textField?.becomeFirstResponder() // open the keyboard
}
override func makeViewsUnderDescription(with interfaceBuilder: BLTNInterfaceBuilder) -> [UIView]? {
var contentViews = [UIView]()
let textField = interfaceBuilder.makeTextField(delegate: self)
textField.returnKeyType = .done
textField.spellCheckingType = .no
textField.autocorrectionType = .no
textField.autocapitalizationType = .none
textField.placeholder = "username"
textField.addTarget(self, action: #selector(textFieldDidChange), for: .editingChanged)
contentViews.append(textField)
self.textField = textField
return contentViews
}
}
extension GerbilPageItem: UITextFieldDelegate {
@objc func textFieldDidChange(textField: UITextField) {
textField.text = textField.text?.lowercased()
// actionButton?.isEnabled = textField.text?.trim().isValidUsername() ?? false
}
func textFieldShouldReturn(_ textField: UITextField) -> Bool {
if let text = textField.text, text.isEmpty == false {
textField.resignFirstResponder()
return true
} else {
textField.backgroundColor = .red
return false
}
}
}
from bulletinboard.
Oops. I had a bug in my test code, and i got confused between ActionBulletinItem and PageBulletinItem.
Maybe headerViews should be moved into ActionBulletinItem to be consistent?
Other than that, I think this is very good.
from bulletinboard.
That's definitely an important missing feature. Thanks for requesting it!
I've been testing several ways to implement it, and I've pushed what I think is the easiest solution on the master branch (f8f7657).
I've created a base class ActionBulletinItem
that handles creating the buttons and recognizing the taps. It has an open
method named makeContentViews(interfaceBuilder:)
that you can override to return the elements displayed above the buttons. PageBulletinItem
builds on top of this class now.
@eliburke You can check out the git diff of the commit to see how it makes creating custom items with buttons easier and more flexible. Tell me if you think more customization is needed.
from bulletinboard.
@alexaubry this is interesting. It's pretty different than what I was thinking. Customizing custom Bulletins that look like PageBulletinItem will still take a fair bit of boilerplate, but it is manageable. Customizing the buttons as in PetSelectorBulletinPage is weighty.
For kicks, I tried updating TextFieldBulletinPage to use ActionBulletinItem. It is unfortunately difficult to get the text input out cleanly with the existing API. See #35
I know it would be a departure from the current API, but what do you think about changing the actionHandler/altActionHandler to call a single closure with an enum and perhaps associated data?
from bulletinboard.
FWIW, I don't mean to sound negative about this update. It's a great improvement for modifying the stock appearance and using the standard button behavior, and also makes implementing a completely custom design much cleaner.
from bulletinboard.
@eliburke Thank you very much for you feedback! I've implemented your initial suggestion in PR #41, and it makes customization way easier and reduces the amount of boilerplate code 💯
Can I ask you to review the PR and tell me if you think some improvements are still needed?
from bulletinboard.
I will open a separate issue about callback changes for actionHandler/altActionHandler.
from bulletinboard.
Hi @alexaubry I'm happy to take a look. Do you want me to do a full PR review (which I think you have to initiate?) or just let you know what I think?
from bulletinboard.
Couple of things I've noticed:
footerViews() is not being called by ActionBulletinItem.makeContentViews()
There is a bug in BulletinInterfaceBuilder.makeTextField(). It does not honor the returnKey parameter but rather hard codes it to .default.
from bulletinboard.
Thanks for the feedback! I fixed the returnKey parameter bug.
I'm actually calling footerViews()
after makeContentViews()
, so I think it's good.
Please let me know if you think other customisation options are missing for the page item, or if you think there are enough now 😄
from bulletinboard.
I thought headerViews
made more sense in PageBulletinItem, because it has a title.
from bulletinboard.
These changes are now in the master
branch and will ship with the next release. Thank you very much for the feature request and your help to implement it 💯
from bulletinboard.
Hi, in relation to this- is there a textField ready page out of the box? or should I build I myself?
from bulletinboard.
Related Issues (20)
- How to set background color? HOT 1
- UIKitCore con < iOS 11 HOT 2
- 4.1.1 and 4.1.2 Blurview is clipped at the bottom of iPhone running iOS 13.6 HOT 5
- Xcode 12 - Double-quoted include in framework header, expecting angle-bracketed instead HOT 1
- iPad: do not show centered on the screen but on the bottom
- Add an option for manually setting dark mode on/off HOT 1
- Swift Compiler Warning: Cannot match several associated values at once HOT 3
- Crash on BulletinCloseButton HOT 1
- Crash when dismissing bulletin board HOT 2
- Swift: Buttons not working HOT 9
- Landscape mode HOT 1
- Add dismissHandler to BLTNItemManager
- Adjust tableView height when keyboard appears HOT 2
- SwiftUI life cycle example
- How to add textfield ? HOT 3
- Documentation & Youtube Video Links Broken. HOT 1
- SwiftUi support
- Could not find module 'BLTNBoard' for target 'x86_64-apple-ios-simulator'; found: arm64, arm64-apple-ios-simulator, at: .../Build/Products/Debug-iphonesimulator/BLTNBoard.swiftmodule HOT 1
- Wrong title will be used after set alternativeButtonTitle
- Background color for alternativeButton? HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from bulletinboard.