forked from fermoya/SwiftUIPager
-
Notifications
You must be signed in to change notification settings - Fork 0
/
BizarreExampleView.swift
58 lines (52 loc) · 1.57 KB
/
BizarreExampleView.swift
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
//
// VerticalExampleView.swift
// SwiftUIPagerExample
//
// Created by Fernando Moya de Rivas on 02/03/2020.
// Copyright © 2020 Fernando Moya de Rivas. All rights reserved.
//
import SwiftUI
struct BizarreExampleView: View {
@StateObject var page1: Page = .first()
@StateObject var page2: Page = .first()
var data = Array(0..<10)
var body: some View {
GeometryReader { proxy in
VStack(spacing: 10) {
Text("Vertical, alignment start").bold()
Pager(page: self.page1,
data: self.data,
id: \.self) {
self.pageView($0)
}
.vertical()
.alignment(.start)
.itemSpacing(10)
.itemAspectRatio(1.3)
.background(Color.gray.opacity(0.2))
Spacer()
Text("Start to End, interactive").bold()
Pager(page: self.page2,
data: self.data,
id: \.self) {
self.pageView($0)
}
.itemSpacing(10)
.horizontal(.endToStart)
.interactive(scale: 0.8)
.itemAspectRatio(0.7)
.background(Color.gray.opacity(0.5))
}
}
}
func pageView(_ page: Int) -> some View {
ZStack {
Rectangle()
.fill(Color.yellow)
Text("Page: \(page)")
.bold()
}
.cornerRadius(5)
.shadow(radius: 5)
}
}