-
Notifications
You must be signed in to change notification settings - Fork 421
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #666 from rechsteiner/swiftui-api
Add new API for PageView implementation in SwiftUI
- Loading branch information
Showing
24 changed files
with
1,414 additions
and
293 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
import Parchment | ||
import SwiftUI | ||
import UIKit | ||
|
||
struct ChangeItemsView: View { | ||
@State var isToggled: Bool = false | ||
|
||
var body: some View { | ||
PageView { | ||
if isToggled { | ||
Page("Title 2") { | ||
VStack { | ||
Text("Page 2") | ||
.font(.largeTitle) | ||
.padding(.bottom) | ||
|
||
Button("Click me") { | ||
isToggled.toggle() | ||
} | ||
} | ||
} | ||
|
||
Page("Title 3") { | ||
VStack { | ||
Text("Page 3") | ||
.font(.largeTitle) | ||
.padding(.bottom) | ||
|
||
Button("Click me") { | ||
isToggled.toggle() | ||
} | ||
} | ||
} | ||
} else { | ||
Page("Title 0") { | ||
VStack { | ||
Text("Page 0") | ||
.font(.largeTitle) | ||
.padding(.bottom) | ||
|
||
Button("Click me") { | ||
isToggled.toggle() | ||
} | ||
} | ||
} | ||
|
||
Page("Title 1") { | ||
VStack { | ||
Text("Page 1") | ||
.font(.largeTitle) | ||
.padding(.bottom) | ||
|
||
Button("Click me") { | ||
isToggled.toggle() | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
import Parchment | ||
import SwiftUI | ||
import UIKit | ||
|
||
struct CustomizedView: View { | ||
var body: some View { | ||
PageView { | ||
Page("Title 1") { | ||
VStack(spacing: 25) { | ||
Text("Page 1") | ||
Image(systemName: "arrow.down") | ||
} | ||
.font(.largeTitle) | ||
} | ||
|
||
Page("Title 2") { | ||
VStack(spacing: 25) { | ||
Image(systemName: "arrow.up") | ||
Text("Page 2") | ||
} | ||
.font(.largeTitle) | ||
} | ||
} | ||
.menuItemSize(.fixed(width: 100, height: 60)) | ||
.menuItemSpacing(20) | ||
.menuItemLabelSpacing(30) | ||
.menuBackgroundColor(.white) | ||
.menuInsets(.vertical, 20) | ||
.menuHorizontalAlignment(.center) | ||
.menuPosition(.bottom) | ||
.menuTransition(.scrollAlongside) | ||
.menuInteraction(.swipe) | ||
.contentInteraction(.scrolling) | ||
.contentNavigationOrientation(.vertical) | ||
.selectedScrollPosition(.preferCentered) | ||
.indicatorOptions(.visible(height: 4)) | ||
.indicatorColor(.blue) | ||
.borderOptions(.visible(height: 4)) | ||
.borderColor(.blue.opacity(0.2)) | ||
.foregroundColor(.blue) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import Parchment | ||
import SwiftUI | ||
import UIKit | ||
|
||
struct DynamicItemsView: View { | ||
@State var items: [Int] = [0, 1, 2, 3, 4] | ||
|
||
var body: some View { | ||
PageView(items, id: \.self) { item in | ||
Page("Title \(item)") { | ||
VStack { | ||
Text("Page \(item)") | ||
.font(.largeTitle) | ||
.padding(.bottom) | ||
|
||
Button("Click me") { | ||
if items.count > 2 { | ||
items = [5, 6] | ||
} else { | ||
items = [0, 1, 2, 3, 4] | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
import Parchment | ||
import SwiftUI | ||
import UIKit | ||
|
||
struct InterpolatedView: View { | ||
var body: some View { | ||
PageView { | ||
Page { state in | ||
Image(systemName: "star.fill") | ||
.scaleEffect(x: 1 + state.progress, y: 1 + state.progress) | ||
.rotationEffect(Angle(degrees: 180 * state.progress)) | ||
.padding(30 * state.progress + 20) | ||
} content: { | ||
Text("Page 1") | ||
.font(.largeTitle) | ||
.foregroundColor(.gray) | ||
} | ||
Page { state in | ||
Text("Rotate") | ||
.fixedSize() | ||
.rotationEffect(Angle(degrees: 90 * state.progress)) | ||
.padding(.horizontal, 10) | ||
} content: { | ||
Text("Page 2") | ||
.font(.largeTitle) | ||
.foregroundColor(.gray) | ||
} | ||
|
||
Page { state in | ||
Text("Tracking") | ||
.tracking(10 * state.progress) | ||
.fixedSize() | ||
.padding() | ||
} content: { | ||
Text("Page 3") | ||
.font(.largeTitle) | ||
.foregroundColor(.gray) | ||
} | ||
|
||
Page { state in | ||
Text("Growing") | ||
.fixedSize() | ||
.padding(.vertical) | ||
.padding(.horizontal, 20 * state.progress + 10) | ||
.background(Color.black.opacity(0.1)) | ||
.cornerRadius(6) | ||
} content: { | ||
Text("Page 4") | ||
.font(.largeTitle) | ||
.foregroundColor(.gray) | ||
} | ||
|
||
Page("Normal") { | ||
Text("Page 5") | ||
.font(.largeTitle) | ||
.foregroundColor(.gray) | ||
} | ||
|
||
Page("Normal") { | ||
Text("Page 6") | ||
.font(.largeTitle) | ||
.foregroundColor(.gray) | ||
} | ||
} | ||
.menuItemSize(.selfSizing(estimatedWidth: 100, height: 80)) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.