52 lines
1.2 KiB
Swift
52 lines
1.2 KiB
Swift
//
|
|
// LiveRoomRightBottomButton.swift
|
|
// SodaLive
|
|
//
|
|
// Created by klaus on 2024/01/17.
|
|
//
|
|
|
|
import SwiftUI
|
|
|
|
struct LiveRoomRightBottomButton: View {
|
|
|
|
let imageName: String
|
|
let onClick: () -> Void
|
|
let onLongPress: (() -> Void)?
|
|
let longPressDuration: Double
|
|
|
|
init(
|
|
imageName: String,
|
|
onClick: @escaping () -> Void,
|
|
onLongPress: (() -> Void)? = nil,
|
|
longPressDuration: Double = 2.0
|
|
) {
|
|
self.imageName = imageName
|
|
self.onClick = onClick
|
|
self.onLongPress = onLongPress
|
|
self.longPressDuration = longPressDuration
|
|
}
|
|
|
|
var body: some View {
|
|
Image(imageName)
|
|
.resizable()
|
|
.frame(width: 24, height: 24)
|
|
.padding(10)
|
|
.background(Color.gray52.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: {}
|
|
)
|
|
}
|
|
}
|