Dev Notes: January 17 - 23, 2025
Work
- Updated SwiftLint to 0.58.2
Android Quick Guides
Just found out the new quick guides from the Android developer’s documentation. This is what I have been looking for, just quick code snippets where I don’t have to open a YouTube tutorial and look for that particular timestamp.
Customizing SwiftUI TextFields
I learned how to simply add a bottom underline inside a TextField leveraging .safeAreaInset
.
import SwiftUI
struct UnderlineTextFieldStyle: TextFieldStyle {
func _body(configuration: TextField<Self._Label>) -> some View {
configuration
.padding([.top, .bottom], 13)
.padding([.leading, .trailing], 19)
.frame(height: 55)
.background(Color.clear)
.tint(Color(.gray))
.safeAreaInset(edge: .bottom) {
Rectangle()
.frame(height: 1)
}
}
}
Fixed Compose insets due to enableEdgeToEdge()
feature
Our TextField was partially hidden behind the bottom app bar, based on this documentation), it seems I need to use a combination of systemBarsPadding() and consumeWindowInsets in our modifier and it worked.
Modifier.consumeWindowInsets(values).systemBarsPadding()
Make sure to use Modifier.consumeWindowInsets
instead of Modifier.padding(values)
or it won’t work.