improve app ui for demo
This commit is contained in:
1 parent
59670cb841
commit
32da6b41c4
6 files changed
+200
-61
No files matched your search
@@ -0,0 +1,24 @@
|
||||
//
|
||||
// MaterialView.swift
|
||||
// Pocket Poster
|
||||
//
|
||||
// Created by lemin on 5/31/25.
|
||||
//
|
||||
|
||||
import SwiftUI
|
||||
|
||||
struct MaterialView: UIViewRepresentable {
|
||||
let material: UIBlurEffect.Style
|
||||
|
||||
init(_ material: UIBlurEffect.Style) {
|
||||
self.material = material
|
||||
}
|
||||
|
||||
func makeUIView(context: Context) -> UIVisualEffectView {
|
||||
UIVisualEffectView(effect: UIBlurEffect(style: material))
|
||||
}
|
||||
|
||||
func updateUIView(_ uiView: UIVisualEffectView, context: Context) {
|
||||
uiView.effect = UIBlurEffect(style: material)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,56 @@
|
||||
//
|
||||
// TintedButton.swift
|
||||
// Pocket Poster
|
||||
//
|
||||
// Created by lemin on 5/31/25.
|
||||
//
|
||||
|
||||
import SwiftUI
|
||||
|
||||
struct TintedButton: ButtonStyle {
|
||||
var color: Color
|
||||
var material: UIBlurEffect.Style?
|
||||
var fullwidth: Bool = false
|
||||
|
||||
func makeBody(configuration: Configuration) -> some View {
|
||||
ZStack {
|
||||
if fullwidth {
|
||||
configuration.label
|
||||
.padding(15)
|
||||
.frame(maxWidth: .infinity)
|
||||
.background(material == nil ? AnyView(color.opacity(0.2)) : AnyView(MaterialView(material!)))
|
||||
.cornerRadius(8)
|
||||
.foregroundColor(color)
|
||||
} else {
|
||||
configuration.label
|
||||
.padding(15)
|
||||
.background(material == nil ? AnyView(color.opacity(0.2)) : AnyView(MaterialView(material!)))
|
||||
.cornerRadius(8)
|
||||
.foregroundColor(color)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
init(color: Color = .blue, fullwidth: Bool = false) {
|
||||
self.color = color
|
||||
self.fullwidth = fullwidth
|
||||
}
|
||||
init(color: Color = .blue, material: UIBlurEffect.Style, fullwidth: Bool = false) {
|
||||
self.color = color
|
||||
self.material = material
|
||||
self.fullwidth = fullwidth
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#if DEBUG
|
||||
struct FullwidthTintedButton_Previews: PreviewProvider {
|
||||
static var previews: some View {
|
||||
Button("Exaple") {
|
||||
|
||||
}
|
||||
.buttonStyle(TintedButton(color: .red, fullwidth: true))
|
||||
.padding()
|
||||
}
|
||||
}
|
||||
#endif
|
||||
Reference in new issue
Block a user