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
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>SchemeUserState</key>
<dict>
<key>SlidingTabView.xcscheme_^#shared#^_</key>
<dict>
<key>orderHint</key>
<integer>0</integer>
</dict>
</dict>
<key>SuppressBuildableAutocreation</key>
<dict>
<key>SlidingTabView</key>
<dict>
<key>primary</key>
<true/>
</dict>
<key>SlidingTabViewTests</key>
<dict>
<key>primary</key>
<true/>
</dict>
</dict>
</dict>
</plist>
5 changes: 5 additions & 0 deletions Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@ import PackageDescription

let package = Package(
name: "SlidingTabView",
platforms: [
.iOS(.v13),
.macOS(.v10_15),
.tvOS(.v13)
],
products: [
// Products define the executables and libraries produced by a package, and make them visible to other packages.
.library(
Expand Down
29 changes: 15 additions & 14 deletions Sources/SlidingTabView/SlidingTabView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ public struct SlidingTabView : View {
selectionBarHeight: CGFloat = 2,
selectionBarBackgroundColor: Color = Color.gray.opacity(0.2),
selectionBarBackgroundHeight: CGFloat = 1) {
self.selectionState = selection.wrappedValue
self._selection = selection
self.tabs = tabs
self.font = font
Expand Down Expand Up @@ -123,14 +124,14 @@ public struct SlidingTabView : View {
}
}
.padding(.vertical, 16)
.accentColor(
self.isSelected(tabIdentifier: tab)
? self.activeAccentColor
: self.inactiveAccentColor)
.background(
self.isSelected(tabIdentifier: tab)
? self.activeTabColor
: self.inactiveTabColor)
.accentColor(
self.isSelected(tabIdentifier: tab)
? self.activeAccentColor
: self.inactiveAccentColor)
.background(
self.isSelected(tabIdentifier: tab)
? self.activeTabColor
: self.inactiveTabColor)
}
}
GeometryReader { geometry in
Expand Down Expand Up @@ -168,20 +169,20 @@ public struct SlidingTabView : View {

@available(iOS 13.0, *)
struct SlidingTabConsumerView : View {
@State private var selectedTabIndex = 0
@State private var selectedTabIndex = 1

var body: some View {
VStack(alignment: .leading) {
SlidingTabView(selection: self.$selectedTabIndex,
tabs: ["First", "Second"],
font: .body,
activeAccentColor: Color.blue,
selectionBarColor: Color.blue)
tabs: ["First", "Second"],
font: .body,
activeAccentColor: Color.blue,
selectionBarColor: Color.blue)
(selectedTabIndex == 0 ? Text("First View") : Text("Second View")).padding()
Spacer()
}
.padding(.top, 50)
.animation(.none)
.animation(.none)
}
}

Expand Down