-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Component 4 - Segment Controller using List and ScrollView
- Loading branch information
1 parent
fb48577
commit 5e3aff4
Showing
12 changed files
with
812 additions
and
2 deletions.
There are no files selected for viewing
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
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
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
30 changes: 30 additions & 0 deletions
30
SwiftUILearning/Components/SegmentController - Week 4/Model/SegmentControllerModel.swift
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,30 @@ | ||
// | ||
// SegmentControllerModel.swift | ||
// SwiftUILearning | ||
// | ||
// Created by Shikalgar, Shahrukh on 21/07/20. | ||
// Copyright © 2020 Shahrukh Shikalgar. All rights reserved. | ||
// | ||
|
||
import Foundation | ||
|
||
// MARK: - SegmentControll Model | ||
/// Model for segment controller screen | ||
struct SegmentControllModel: Codable, Identifiable, Hashable { | ||
let id: Int? | ||
let teamName: String | ||
let index: Int | ||
let homeIndex: Int | ||
let awayIndex: Int | ||
let all: GameRecord | ||
let home: GameRecord | ||
let away: GameRecord | ||
} | ||
|
||
struct GameRecord: Codable, Identifiable, Hashable { | ||
let id: Int | ||
let played: Int | ||
let won: Int | ||
let draw: Int | ||
let lost: Int | ||
} |
38 changes: 38 additions & 0 deletions
38
SwiftUILearning/Components/SegmentController - Week 4/View/SegmentControllerView.swift
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,38 @@ | ||
// | ||
// SegmentControllerView.swift | ||
// SwiftUILearning | ||
// | ||
// Created by Shikalgar, Shahrukh on 21/07/20. | ||
// Copyright © 2020 Shahrukh Shikalgar. All rights reserved. | ||
// | ||
|
||
import SwiftUI | ||
|
||
// MARK: - Struct for SegmentControllerView | ||
/// View for SegmentControllerView | ||
struct SegmentControllerView: View { | ||
// MARK: - Variables | ||
private let viewModel = SegmentControllerViewModel() | ||
|
||
// MARK: - View | ||
/// Body for View | ||
var body: some View { | ||
List { | ||
ForEach(self.viewModel.contentViewItems, id: \.self) { item in | ||
NavigationLink(destination: self.viewModel.getDestinationView(type: item.contentType ?? "")) { | ||
Text("\(item.contentType ?? "") - Segment Controller") | ||
} | ||
} | ||
} | ||
.listStyle(GroupedListStyle()) | ||
.navigationBarTitle(Text("Segment Controll"), displayMode: .inline) | ||
} | ||
} | ||
|
||
// MARK: - SegmentControllerView_Previews | ||
/// Preview provider for SegmentControllerView | ||
struct SegmentControllerView_Previews: PreviewProvider { | ||
static var previews: some View { | ||
SegmentControllerView() | ||
} | ||
} |
Oops, something went wrong.