ui: add AlbyButton
This will be used for alby's nostr wallet connect implementation
This commit is contained in:
25
damus/Util/Extensions/FillAndStroke.swift
Normal file
25
damus/Util/Extensions/FillAndStroke.swift
Normal file
@@ -0,0 +1,25 @@
|
||||
//
|
||||
// FillAndStroke.swift
|
||||
// damus
|
||||
//
|
||||
// Created by William Casarin on 2023-05-09.
|
||||
//
|
||||
|
||||
import Foundation
|
||||
import SwiftUI
|
||||
|
||||
extension Shape {
|
||||
func fill<Fill: ShapeStyle, Stroke: ShapeStyle>(_ fillStyle: Fill, strokeBorder strokeStyle: Stroke, lineWidth: Double = 1) -> some View {
|
||||
self
|
||||
.stroke(strokeStyle, lineWidth: lineWidth)
|
||||
.background(self.fill(fillStyle))
|
||||
}
|
||||
}
|
||||
|
||||
extension InsettableShape {
|
||||
func fill<Fill: ShapeStyle, Stroke: ShapeStyle>(_ fillStyle: Fill, strokeBorder strokeStyle: Stroke, lineWidth: Double = 1) -> some View {
|
||||
self
|
||||
.strokeBorder(strokeStyle, lineWidth: lineWidth)
|
||||
.background(self.fill(fillStyle))
|
||||
}
|
||||
}
|
||||
46
damus/Views/Buttons/AlbyButton.swift
Normal file
46
damus/Views/Buttons/AlbyButton.swift
Normal file
@@ -0,0 +1,46 @@
|
||||
//
|
||||
// AlbyButton.swift
|
||||
// damus
|
||||
//
|
||||
// Created by William Casarin on 2023-05-09.
|
||||
//
|
||||
|
||||
import SwiftUI
|
||||
|
||||
struct AlbyButton: View {
|
||||
let action: () -> ()
|
||||
|
||||
@Environment(\.colorScheme) var colorScheme
|
||||
|
||||
init(action: @escaping () -> ()) {
|
||||
self.action = action
|
||||
}
|
||||
|
||||
var body: some View {
|
||||
Button(action: {
|
||||
action()
|
||||
}) {
|
||||
HStack {
|
||||
Image("alby")
|
||||
|
||||
Text("Connect to Alby")
|
||||
}
|
||||
.offset(x: -25)
|
||||
.frame(minWidth: 300, maxWidth: .infinity, minHeight: 50, maxHeight: 50, alignment: .center)
|
||||
.foregroundColor(DamusColors.black)
|
||||
.background {
|
||||
RoundedRectangle(cornerRadius: 24)
|
||||
.fill(AlbyGradient, strokeBorder: colorScheme == .light ? DamusColors.black : DamusColors.white, lineWidth: 2)
|
||||
}
|
||||
.padding(EdgeInsets(top: 10, leading: 50, bottom: 25, trailing: 50))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
struct AlbyButton_Previews: PreviewProvider {
|
||||
static var previews: some View {
|
||||
AlbyButton(action: {
|
||||
print("alby button")
|
||||
})
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user