Skip to content

Commit

Permalink
refactor: set tab titles as parameter
Browse files Browse the repository at this point in the history
  • Loading branch information
juandahurt committed Jun 2, 2022
1 parent 69a79c5 commit b893219
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
2 changes: 1 addition & 1 deletion PuraceDemo/PuraceDemo/Examples/Complex/TabExample.swift
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ struct TabExample: View {
)

var body: some View {
PuraceTabView { index in
PuraceTabView(titles: ["Acerca de", "Imágenes"]) { index in
Group {
switch index {
case 0:
Expand Down
5 changes: 3 additions & 2 deletions Sources/Purace/Views/Complex/Tab/PuraceTabView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,13 @@ import Foundation
import SwiftUI

public struct PuraceTabView<T: View>: View {
let titles: [String] = ["Acerca de", "Imágenes"]
let titles: [String]
@State var selectedIndex = 0
@State var indicatorOffset: CGFloat = .zero
var viewForIndex: (Int) -> T

public init(viewForIndex: @escaping (Int) -> T) {
public init(titles: [String], viewForIndex: @escaping (Int) -> T) {
self.titles = titles
self.viewForIndex = viewForIndex
}

Expand Down

0 comments on commit b893219

Please sign in to comment.