forked from agarwalayush9/Shelves
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPageControl.swift
37 lines (32 loc) · 961 Bytes
/
PageControl.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
//
// PageControl.swift
// Shelves-User
//
// Created by Suraj Singh on 04/07/24.
//
import SwiftUI
struct PageControl: View {
var numberOfPages: Int
@Binding var currentPage: Int
var body: some View {
HStack(spacing: 8) {
ForEach(0..<numberOfPages, id: \.self) { index in
Circle()
.fill(index == currentPage ? Color(red: 0.4, green: 0.2, blue: 0.1) : Color.white)
.frame(width: 10, height: 10)
.overlay(
Circle()
.stroke(Color(red: 0.4, green: 0.2, blue: 0.1), lineWidth: 1)
)
.onTapGesture {
currentPage = index
}
}
}
}
}
struct PageControl_Previews: PreviewProvider {
static var previews: some View {
PageControl(numberOfPages: 3, currentPage: .constant(0))
}
}