Skip to content

Commit

Permalink
Merge pull request #5 from quassummanus/bugfix/access-control-error
Browse files Browse the repository at this point in the history
Fixed access control issue
  • Loading branch information
bring-shrubbery authored Jul 3, 2021
2 parents 113ff85 + e2e67f3 commit 2741c97
Show file tree
Hide file tree
Showing 8 changed files with 58 additions and 41 deletions.
3 changes: 1 addition & 2 deletions Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,10 @@ let package = Package(
name: "SwiftUITooltip",
targets: ["SwiftUITooltip"]),
],
dependencies: [],
targets: [
.target(
name: "SwiftUITooltip",
dependencies: []),
exclude: ["images"]),
// .testTarget(
// name: "SwiftUI-TooltipTests",
// dependencies: ["SwiftUI-Tooltip"]),
Expand Down
18 changes: 18 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,18 @@
SwiftUI does not provide an easy way to show tooltips over exiting views, so we created one!
The tooltip provideded by this package allows you to put any `View` you want into the tooltip and position it on any side of the other `View`.

## Getting started

You can add this package to your project using Swift Package Manager. Enter following url when adding it to your project package dependencies:

```
https://github.com/quassummanus/SwiftUI-Tooltip.git
```

We are using semver for versioning, so we would recomment selecting "Up to next major relase" option for this package.

After you added the package, all you need to do is import it and you can add a tooltip to any SwiftUI View in that file!

## Usage

### Example 1
Expand All @@ -15,10 +27,13 @@ Below you can see the example of code that is required to create the tooltip and
*Code:*

```swift
import SwiftUITooltip
...
Text("Say something nice...")
.tooltip(.bottom) {
Text("Something nice!")
}
...
```

*Result:*
Expand All @@ -32,6 +47,9 @@ Second example shows you how you can add jumping animation to the tooltip from t
*Code:*

```swift
import SwiftUI
import SwiftUITooltip

struct SwiftUIView: View {
var tooltipConfig = DefaultTooltipConfig()

Expand Down
4 changes: 2 additions & 2 deletions Sources/SwiftUITooltip/ArrowShape.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@

import SwiftUI

struct ArrowShape: Shape {
func path(in rect: CGRect) -> Path {
public struct ArrowShape: Shape {
public func path(in rect: CGRect) -> Path {
var path = Path()
path.addLines([
CGPoint(x: 0, y: rect.height),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,22 +8,22 @@

import SwiftUI

struct ArrowOnlyTooltipConfig: TooltipConfig {
public struct ArrowOnlyTooltipConfig: TooltipConfig {
static var shared = ArrowOnlyTooltipConfig()

var side: TooltipSide = .bottom
var margin: CGFloat = 8
public var side: TooltipSide = .bottom
public var margin: CGFloat = 8

var borderRadius: CGFloat = 8
var borderWidth: CGFloat = 0
var borderColor: Color = Color.primary
public var borderRadius: CGFloat = 8
public var borderWidth: CGFloat = 0
public var borderColor: Color = Color.primary

var contentPaddingLeft: CGFloat = 8
var contentPaddingRight: CGFloat = 8
var contentPaddingTop: CGFloat = 4
var contentPaddingBottom: CGFloat = 4
public var contentPaddingLeft: CGFloat = 8
public var contentPaddingRight: CGFloat = 8
public var contentPaddingTop: CGFloat = 4
public var contentPaddingBottom: CGFloat = 4

var contentPaddingEdgeInsets: EdgeInsets {
public var contentPaddingEdgeInsets: EdgeInsets {
EdgeInsets(
top: contentPaddingTop,
leading: contentPaddingLeft,
Expand All @@ -32,13 +32,13 @@ struct ArrowOnlyTooltipConfig: TooltipConfig {
)
}

var showArrow: Bool = true
var arrowWidth: CGFloat = 12
var arrowHeight: CGFloat = 6
public var showArrow: Bool = true
public var arrowWidth: CGFloat = 12
public var arrowHeight: CGFloat = 6

var enableAnimation: Bool = false
var animationOffset: CGFloat = 10
var animationTime: Double = 1
public var enableAnimation: Bool = false
public var animationOffset: CGFloat = 10
public var animationTime: Double = 1

init() {}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,22 +8,22 @@

import SwiftUI

struct DefaultTooltipConfig: TooltipConfig {
public struct DefaultTooltipConfig: TooltipConfig {
static var shared = DefaultTooltipConfig()

var side: TooltipSide = .bottom
var margin: CGFloat = 8
public var side: TooltipSide = .bottom
public var margin: CGFloat = 8

var borderRadius: CGFloat = 8
var borderWidth: CGFloat = 2
var borderColor: Color = Color.primary
public var borderRadius: CGFloat = 8
public var borderWidth: CGFloat = 2
public var borderColor: Color = Color.primary

var contentPaddingLeft: CGFloat = 8
var contentPaddingRight: CGFloat = 8
var contentPaddingTop: CGFloat = 4
var contentPaddingBottom: CGFloat = 4
public var contentPaddingLeft: CGFloat = 8
public var contentPaddingRight: CGFloat = 8
public var contentPaddingTop: CGFloat = 4
public var contentPaddingBottom: CGFloat = 4

var contentPaddingEdgeInsets: EdgeInsets {
public var contentPaddingEdgeInsets: EdgeInsets {
EdgeInsets(
top: contentPaddingTop,
leading: contentPaddingLeft,
Expand All @@ -32,13 +32,13 @@ struct DefaultTooltipConfig: TooltipConfig {
)
}

var showArrow: Bool = true
var arrowWidth: CGFloat = 12
var arrowHeight: CGFloat = 6
public var showArrow: Bool = true
public var arrowWidth: CGFloat = 12
public var arrowHeight: CGFloat = 6

var enableAnimation: Bool = false
var animationOffset: CGFloat = 10
var animationTime: Double = 1
public var enableAnimation: Bool = false
public var animationOffset: CGFloat = 10
public var animationTime: Double = 1

init() {}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

import SwiftUI

protocol TooltipConfig {
public protocol TooltipConfig {
// MARK: Alignment

var side: TooltipSide { get set }
Expand Down
2 changes: 1 addition & 1 deletion Sources/SwiftUITooltip/TooltipSide.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

import SwiftUI

enum TooltipSide: Int {
public enum TooltipSide: Int {
case leading = 2
case center = -1
case trailing = 6
Expand Down
2 changes: 1 addition & 1 deletion Sources/SwiftUITooltip/TooltipViewExtension.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

import SwiftUI

extension View {
public extension View {
func tooltip<TooltipContent: View>(@ViewBuilder content: @escaping () -> TooltipContent) -> some View {
let config: TooltipConfig = DefaultTooltipConfig.shared

Expand Down

0 comments on commit 2741c97

Please sign in to comment.