Files
sodalive-ios/SodaLive/Sources/Live/Room/V2/Component/Button/LiveRoomRightBottomButton.swift

63 lines
1.5 KiB
Swift

//
// LiveRoomRightBottomButton.swift
// SodaLive
//
// Created by klaus on 2024/01/17.
//
import SwiftUI
struct LiveRoomRightBottomButton: View {
let imageName: String
let onClick: () -> Void
let backgroundColor: Color?
let onLongPress: (() -> Void)?
let longPressDuration: Double
init(
imageName: String,
onClick: @escaping () -> Void,
backgroundColor: Color? = nil,
onLongPress: (() -> Void)? = nil,
longPressDuration: Double = 2.0
) {
self.imageName = imageName
self.onClick = onClick
self.backgroundColor = backgroundColor
self.onLongPress = onLongPress
self.longPressDuration = longPressDuration
}
var body: some View {
Image(imageName)
.resizable()
.frame(width: 24, height: 24)
.padding(10)
.background(
backgroundColor ?? Color(
.sRGB,
red: 82 / 255,
green: 82 / 255,
blue: 82 / 255,
opacity: 0.6
)
)
.cornerRadius(10)
.onTapGesture { onClick() }
.onLongPressGesture(minimumDuration: longPressDuration) {
onLongPress?()
}
}
}
struct LiveRoomRightBottomButton_Previews: PreviewProvider {
static var previews: some View {
LiveRoomRightBottomButton(
imageName: "ic_donation",
onClick: {},
onLongPress: {}
)
}
}