mirror of
https://github.com/lumaa-dev/BubbleApp.git
synced 2025-01-20 04:39:16 +01:00
Grayed button when disabled
This commit is contained in:
parent
f36ce5ff96
commit
447fe8263b
@ -5,6 +5,15 @@ import SwiftUI
|
|||||||
struct LargeButton: ButtonStyle {
|
struct LargeButton: ButtonStyle {
|
||||||
var filled: Bool = false
|
var filled: Bool = false
|
||||||
var height: CGFloat? = nil
|
var height: CGFloat? = nil
|
||||||
|
var disabled: Bool = false
|
||||||
|
|
||||||
|
private var fillColor: Color {
|
||||||
|
if disabled {
|
||||||
|
Color.gray
|
||||||
|
} else {
|
||||||
|
Color(uiColor: UIColor.label)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func makeBody(configuration: Configuration) -> some View {
|
func makeBody(configuration: Configuration) -> some View {
|
||||||
configuration.label
|
configuration.label
|
||||||
@ -12,7 +21,7 @@ struct LargeButton: ButtonStyle {
|
|||||||
.padding(.vertical, height)
|
.padding(.vertical, height)
|
||||||
.background {
|
.background {
|
||||||
if filled {
|
if filled {
|
||||||
Color(uiColor: UIColor.label)
|
fillColor
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
.foregroundStyle(filled ? Color(uiColor: UIColor.systemBackground) : Color(uiColor: UIColor.label))
|
.foregroundStyle(filled ? Color(uiColor: UIColor.systemBackground) : Color(uiColor: UIColor.label))
|
||||||
|
@ -37,7 +37,7 @@ struct PostingView: View {
|
|||||||
VStack(alignment: .leading) {
|
VStack(alignment: .leading) {
|
||||||
// MARK: Status main content
|
// MARK: Status main content
|
||||||
VStack(alignment: .leading, spacing: 10) {
|
VStack(alignment: .leading, spacing: 10) {
|
||||||
Text(accountManager.forceAccount().username)
|
Text("@\(accountManager.forceAccount().username)")
|
||||||
.multilineTextAlignment(.leading)
|
.multilineTextAlignment(.leading)
|
||||||
.bold()
|
.bold()
|
||||||
|
|
||||||
@ -116,7 +116,7 @@ struct PostingView: View {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
.disabled(postingStatus || viewModel.postText.length <= 0)
|
.disabled(postingStatus || viewModel.postText.length <= 0)
|
||||||
.buttonStyle(LargeButton(filled: true, height: 7.5))
|
.buttonStyle(LargeButton(filled: true, height: 7.5, disabled: postingStatus || viewModel.postText.length <= 0))
|
||||||
}
|
}
|
||||||
.padding()
|
.padding()
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user