ui: add AlbyButton

This will be used for alby's nostr wallet connect implementation
This commit is contained in:
William Casarin
2023-05-09 18:15:16 -07:00
parent 27caffd91f
commit 1db425fd69
3 changed files with 79 additions and 0 deletions

View 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))
}
}

View 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")
})
}
}