Visual_Novel_iOS/crush/Crush/Src/Components/UI/Popover/FSPopoverViewDataSource.swift

49 lines
1.3 KiB
Swift
Raw Normal View History

2025-10-09 10:29:35 +00:00
//
// FSPopoverViewDataSource.swift
// FSPopoverView
//
// Created by Sheng on 2022/4/3.
// Copyright © 2023 Sheng. All rights reserved.
//
import UIKit
public protocol FSPopoverViewDataSource: AnyObject {
func backgroundView(for popoverView: FSPopoverView) -> UIView?
func contentView(for popoverView: FSPopoverView) -> UIView?
func contentSize(for popoverView: FSPopoverView) -> CGSize
func containerSafeAreaInsets(for popoverView: FSPopoverView) -> UIEdgeInsets
func popoverViewShouldDismissOnTapOutside(_ popoverView: FSPopoverView) -> Bool
}
/// Optional
public extension FSPopoverViewDataSource {
func backgroundView(for popoverView: FSPopoverView) -> UIView? {
let view = UIView()
view.backgroundColor = FSPopoverViewAppearance.shared.backgroundColor
return view
}
func contentView(for popoverView: FSPopoverView) -> UIView? {
return nil
}
func contentSize(for popoverView: FSPopoverView) -> CGSize {
return .zero
}
func containerSafeAreaInsets(for popoverView: FSPopoverView) -> UIEdgeInsets {
return .init(top: 18.0, left: 16.0, bottom: 18.0, right: 16.0)// 10,10,10,10
}
func popoverViewShouldDismissOnTapOutside(_ popoverView: FSPopoverView) -> Bool {
return true
}
}