Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ let package = Package(
.library(
name: "ToolTipKit",
targets: ["ToolTipKit"]
)
),
],
dependencies: [],
targets: [
Expand Down
178 changes: 174 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -132,10 +132,180 @@ or you can create your own `Config`
)
ToolTipManager.shared.config = toolTipConfig
```

## What's next
- [] SwiftUI representable code example.
- [] Backward compatibility for Apple's [TipKit](https://developer.apple.com/videos/play/wwdc2023/10229/).

---

# TooltipKitUI

A simple and customizable tooltip library for SwiftUI applications. TooltipKitUI allows you to easily add beautiful tooltips to any view with extensive customization options.

## Features

- 🎨 Highly customizable appearance
- 📱 iOS 14+
- ✨ Smooth animations
- 🎭 Highlight effect around target views
- 📐 Flexible arrow positioning (top/bottom)

## Installation

### Swift Package Manager

Add TooltipKitUI to your project using Swift Package Manager:

1. In Xcode, go to **File** → **Add Packages...**
2. Enter the repository URL
3. Select the version you want to use
4. Add the package to your target

## Quick Start

### 1. Wrap your content in `TooltipContainer`

```swift
import SwiftUI
import TooltipKitUI

struct ContentView: View {
var body: some View {
TooltipContainer {
// Your app content here
}
}
}
```

### 2. Add tooltip to any view

```swift
struct ContentView: View {
@State private var showTooltip = false

var body: some View {
TooltipContainer {
Button("Show Tooltip") {
showTooltip = true
}
.tooltip(
isPresented: $showTooltip,
title: "Welcome!",
description: "This is a tooltip example"
)
}
}
}
```

## Configuration Parameters

The `.tooltip()` modifier accepts the following parameters:

### Required Parameters

| Parameter | Type | Description |
|-----------|------|-------------|
| `isPresented` | `Binding<Bool>` | Controls tooltip visibility |
| `title` | `String` | Tooltip title text |
| `description` | `String` | Tooltip description text |

### Optional Parameters

#### Arrow & Layout

| Parameter | Type | Default | Description |
|-----------|------|---------|-------------|
| `arrowDirection` | `ArrowDirection` | `.top` | Arrow position (`.top` or `.bottom`) |
| `tooltipWidth` | `CGFloat` | `350` | Width of the tooltip |
| `spacing` | `CGFloat` | `16` | Spacing between title and description |
| `highlightCornerRadius` | `CGFloat` | `8` | Corner radius of the highlight effect |

#### Typography

| Parameter | Type | Default | Description |
|-----------|------|---------|-------------|
| `titleFont` | `Font` | `.system(size: 12)` | Font for the title |
| `descriptionFont` | `Font` | `.system(size: 12)` | Font for the description |
| `titleColor` | `Color` | `.black` | Color of the title text |
| `descriptionColor` | `Color` | `.gray` | Color of the description text |

#### Padding

| Parameter | Type | Default | Description |
|-----------|------|---------|-------------|
| `titlePadding` | `EdgeInsets` | `EdgeInsets(top: 16, leading: 16, bottom: 0, trailing: 16)` | Padding around the title |
| `descriptionPadding` | `EdgeInsets` | `EdgeInsets(top: 0, leading: 32, bottom: 32, trailing: 32)` | Padding around the description |

#### Appearance

| Parameter | Type | Default | Description |
|-----------|------|---------|-------------|
| `backgroundColor` | `Color` | `.white` | Background color of the tooltip |
| `shadowRadius` | `CGFloat` | `10` | Shadow radius around the tooltip |
| `cornerRadius` | `CGFloat` | `8` | Corner radius of the tooltip |

## Usage Examples

### Basic Tooltip

```swift
Button("Info") {
showTooltip = true
}
.tooltip(
isPresented: $showTooltip,
title: "Information",
description: "This button provides additional information"
)
```

### Customized Tooltip

```swift
Button("Custom Tooltip") {
showTooltip = true
}
.tooltip(
isPresented: $showTooltip,
title: "Custom Style",
description: "This tooltip has custom colors and fonts",
arrowDirection: .bottom,
titleFont: .system(size: 16, weight: .bold),
descriptionFont: .system(size: 14),
titleColor: .blue,
descriptionColor: .secondary,
tooltipWidth: 300,
backgroundColor: .systemBackground,
shadowRadius: 15
)
```

### Tooltip with Bottom Arrow

```swift
Image(systemName: "questionmark.circle")
.tooltip(
isPresented: $showTooltip,
title: "Help",
description: "Tap anywhere to dismiss",
arrowDirection: .bottom
)
```

## Dismissal

Tooltips are automatically dismissed when:
- User taps anywhere on the screen (outside or inside the tooltip)
- The `isPresented` binding is set to `false` programmatically

## Requirements

- iOS 14.0+ / macOS 11.0+
- Swift 5.0+
- Xcode 12.0+

## License

Copyright © 2025 Mobven. All rights reserved.

---
Developed with 🖤 at [Mobven](https://mobven.com/) for [MAC+](https://apps.apple.com/tr/app/mac-online-fitness-deneyimi/id1573778936/)
19 changes: 19 additions & 0 deletions Sample/Sample.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@
objects = {

/* Begin PBXBuildFile section */
1989F0162EE1BA50000AF66B /* TooltipPreviewScreen.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1989F0152EE1BA50000AF66B /* TooltipPreviewScreen.swift */; };
1B9624932A38A870005CA52B /* ToolTipKit in Frameworks */ = {isa = PBXBuildFile; productRef = 1B9624922A38A870005CA52B /* ToolTipKit */; };
1B9624952A38A88000A8BD94 /* TooltipKitUI in Frameworks */ = {isa = PBXBuildFile; productRef = 1B9624942A38A88000A8BD94 /* TooltipKitUI */; };
1BE7B8ED2A38A47B00A8BD94 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1BE7B8EC2A38A47B00A8BD94 /* AppDelegate.swift */; };
1BE7B8EF2A38A47B00A8BD94 /* SceneDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1BE7B8EE2A38A47B00A8BD94 /* SceneDelegate.swift */; };
1BE7B8F12A38A47B00A8BD94 /* ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1BE7B8F02A38A47B00A8BD94 /* ViewController.swift */; };
Expand All @@ -17,6 +19,7 @@
/* End PBXBuildFile section */

/* Begin PBXFileReference section */
1989F0152EE1BA50000AF66B /* TooltipPreviewScreen.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TooltipPreviewScreen.swift; sourceTree = "<group>"; };
1BE7B8E92A38A47B00A8BD94 /* Sample.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Sample.app; sourceTree = BUILT_PRODUCTS_DIR; };
1BE7B8EC2A38A47B00A8BD94 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = "<group>"; };
1BE7B8EE2A38A47B00A8BD94 /* SceneDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SceneDelegate.swift; sourceTree = "<group>"; };
Expand All @@ -34,12 +37,21 @@
buildActionMask = 2147483647;
files = (
1B9624932A38A870005CA52B /* ToolTipKit in Frameworks */,
1B9624952A38A88000A8BD94 /* TooltipKitUI in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXFrameworksBuildPhase section */

/* Begin PBXGroup section */
1989F0142EE1BA3A000AF66B /* SwiftUI */ = {
isa = PBXGroup;
children = (
1989F0152EE1BA50000AF66B /* TooltipPreviewScreen.swift */,
);
path = SwiftUI;
sourceTree = "<group>";
};
1B9624912A38A870005CA52B /* Frameworks */ = {
isa = PBXGroup;
children = (
Expand Down Expand Up @@ -68,6 +80,7 @@
1BE7B8EB2A38A47B00A8BD94 /* Sample */ = {
isa = PBXGroup;
children = (
1989F0142EE1BA3A000AF66B /* SwiftUI */,
1BE7B8EC2A38A47B00A8BD94 /* AppDelegate.swift */,
1BE7B8EE2A38A47B00A8BD94 /* SceneDelegate.swift */,
1BE7B8F02A38A47B00A8BD94 /* ViewController.swift */,
Expand Down Expand Up @@ -105,6 +118,7 @@
name = Sample;
packageProductDependencies = (
1B9624922A38A870005CA52B /* ToolTipKit */,
1B9624942A38A88000A8BD94 /* TooltipKitUI */,
);
productName = Sample;
productReference = 1BE7B8E92A38A47B00A8BD94 /* Sample.app */;
Expand Down Expand Up @@ -163,6 +177,7 @@
files = (
1BE7B8F12A38A47B00A8BD94 /* ViewController.swift in Sources */,
1BE7B8ED2A38A47B00A8BD94 /* AppDelegate.swift in Sources */,
1989F0162EE1BA50000AF66B /* TooltipPreviewScreen.swift in Sources */,
1BE7B8EF2A38A47B00A8BD94 /* SceneDelegate.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
Expand Down Expand Up @@ -387,6 +402,10 @@
isa = XCSwiftPackageProductDependency;
productName = ToolTipKit;
};
1B9624942A38A88000A8BD94 /* TooltipKitUI */ = {
isa = XCSwiftPackageProductDependency;
productName = TooltipKitUI;
};
/* End XCSwiftPackageProductDependency section */
};
rootObject = 1BE7B8E12A38A47B00A8BD94 /* Project object */;
Expand Down
Loading