Skip to content

Commit b6eb639

Browse files
author
hadiuzzaman
committed
chore: add documentation
1 parent bbe1413 commit b6eb639

File tree

1 file changed

+110
-0
lines changed

1 file changed

+110
-0
lines changed

README.md

Lines changed: 110 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,111 @@
11
# ScrollableTabView
2+
ScrollableTabView is a customizable, horizontally scrollable tab view built in SwiftUI. It allows you to display multiple tabs with smooth scrolling and animation. The tabs can be styled with different colors, backgrounds, and layouts. The package includes predefined tab item views like WithText and WithTextAndIcon, which make it easy to display text or text with an icon in your tabs.
3+
4+
## Features
5+
- Horizontally scrollable tabs with customizable background and foreground colors.
6+
- Support for active/inactive tab states with separate styles.
7+
- Adjustable tab corner radius, spacing, and padding.
8+
- Easy-to-use TabItem initializer to define custom tab views.
9+
- Smooth transitions and animations between tabs.
10+
- Works with SwiftUI's TabView for content rendering.
11+
12+
## Installation
13+
14+
Swift Package Manager (SPM)
15+
To install the ScrollableTabView using Swift Package Manager, follow these steps:
16+
17+
1. Open your Xcode project.
18+
19+
2. Go to File > Add Packages.
20+
21+
3. In the search bar, paste the following URL:
22+
23+
```bash
24+
https://github.com/hadiuzzaman524/swiftui-scrollable-tab-view.git
25+
26+
```
27+
4. Select the package and click Add Package to integrate it into your project.
28+
29+
30+
To create a `ScrollableTabView`, initialize it with an array of TabItem instances that define the title and body for each tab.
31+
32+
### Example 1: Simple Text Tabs
33+
```swift
34+
import SwiftUI
35+
import ScrollableTabView
36+
37+
struct ContentView: View {
38+
var body: some View {
39+
ScrollableTabView(
40+
items: [
41+
TabItem(title: WithText(text: "Home"), body: Text("Home Content")),
42+
TabItem(title: WithText(text: "Profile"), body: Text("Profile Content")),
43+
TabItem(title: WithText(text: "Settings"), body: Text("Settings Content"))
44+
]
45+
)
46+
}
47+
}
48+
49+
```
50+
Each tab's title is displayed using the WithText component.
51+
The corresponding body is simple text content.
52+
53+
### Example 2: Tabs with Icons
54+
55+
```swift
56+
import SwiftUI
57+
import ScrollableTabView
58+
59+
struct ContentView: View {
60+
var body: some View {
61+
ScrollableTabView(
62+
items: [
63+
TabItem(title: WithTextAndIcon(text: "Home", systemName: "house"), body: Text("Home Content")),
64+
TabItem(title: WithTextAndIcon(text: "Profile", systemName: "person.circle"), body: Text("Profile Content")),
65+
TabItem(title: WithTextAndIcon(text: "Settings", systemName: "gearshape"), body: Text("Settings Content"))
66+
]
67+
)
68+
}
69+
}
70+
71+
```
72+
### Custom Styling
73+
`ScrollableTabView` allows you to fully customize the appearance of the tabs through several styling parameters. You can control the background color, foreground color, corner radius, and spacing for both active and inactive states of the tabs.
74+
75+
#### Customizing Background and Foreground Colors
76+
You can change the background and text (foreground) colors of the active and inactive tabs using the following parameters:
77+
78+
- `activeBgColor`: The background color of the active tab.
79+
- `inactiveBgColor`: The background color of inactive tabs.
80+
- `activeColor`: The text (foreground) color of the active tab.
81+
- `inActiveColor`: The text (foreground) color of inactive tabs.
82+
- `cornerRadius`: Controls the roundness of the tab corners.
83+
- `spaceBetween`: Defines the space between each tab in the scroll view.
84+
- `leadingSpace` and `trailingSpace`: Set custom padding before the first tab and after the last tab, respectively.
85+
86+
```swift
87+
import SwiftUI
88+
import ScrollableTabView
89+
90+
struct ContentView: View {
91+
var body: some View {
92+
ScrollableTabView(
93+
activeBgColor: Color.green,
94+
inactiveBgColor: Color.orange,
95+
activeColor: Color.white,
96+
inActiveColor: Color.black,
97+
cornerRadius: 16,
98+
spaceBetween: 10,
99+
leadingSpace: 20,
100+
trailingSpace: 20,
101+
items: [
102+
TabItem(title: WithTextAndIcon(text: "Home", systemName: "house"), body: Text("Home Content")),
103+
TabItem(title: WithTextAndIcon(text: "Search", systemName: "magnifyingglass"), body: Text("Search Content")),
104+
TabItem(title: WithTextAndIcon(text: "Settings", systemName: "gearshape"), body: Text("Settings Content"))
105+
]
106+
)
107+
}
108+
}
109+
110+
111+
```

0 commit comments

Comments
 (0)