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
import Combine | |
final class RepoViewModel: ObservableObject { | |
@Published var isLoading = true | |
@Published var repos = [Repo]() { | |
didSet { | |
didChange.send(self) | |
} | |
} | |
private let didChange = PassthroughSubject<RepoViewModel, Never>() |
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
var body: some View { | |
NavigationView{ | |
List(reposArray, id: \.name){ model in | |
RepoCell(repoModel: model) | |
.shadow(color: .gray, radius: 4, x: 4, y: 4) | |
.padding(8.0) | |
} | |
.navigationBarTitle(Text("🔥HOT REPOS🔥 ")) | |
.onAppear(perform: loadData) | |
/// removing separators from the list |
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
var body: some View { | |
// We set all elements in a Vertical Stack | |
VStack(alignment: .center, spacing: 0.0){ | |
Text(repoModel.name) | |
.font(.headline) | |
.foregroundColor(Color.gitHubText) // Custom color | |
.padding() | |
Text(repoModel.description) | |
.font(.subheadline) | |
.fontWeight(.medium) |
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
import SwiftUI | |
struct RepoCell: View { | |
@State var repoModel: Repo | |
static var imagePlaceHolder = UIImage(named: "image_placeholder") | |
var body: some View { | |
Text("New Cell") | |
} | |
} |
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
import SwiftUI | |
struct ContentView: View { | |
@ObservedObject var repoViewModel = RepoViewModel() | |
var body: some View { | |
NavigationView{ | |
if repoViewModel.isLoading { | |
Loader() |