Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
stephencelis committed Oct 25, 2023
1 parent 96b1bfc commit 456a3fd
Show file tree
Hide file tree
Showing 19 changed files with 1,245 additions and 2 deletions.

Large diffs are not rendered by default.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>IDEDidComputeMac32BitWarning</key>
<true/>
</dict>
</plist>
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1500"
version = "1.7">
<BuildAction
parallelizeBuildables = "YES"
buildImplicitDependencies = "YES">
<BuildActionEntries>
<BuildActionEntry
buildForTesting = "YES"
buildForRunning = "YES"
buildForProfiling = "YES"
buildForArchiving = "YES"
buildForAnalyzing = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "2AD14E1B2ACDC3EC0015EB20"
BuildableName = "ObservationExplorations.app"
BlueprintName = "ObservationExplorations"
ReferencedContainer = "container:ObservationExplorations.xcodeproj">
</BuildableReference>
</BuildActionEntry>
</BuildActionEntries>
</BuildAction>
<TestAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
shouldUseLaunchSchemeArgsEnv = "YES">
<TestPlans>
<TestPlanReference
reference = "container:ObservationExplorationsTests/ObservationExplorations.xctestplan"
default = "YES">
</TestPlanReference>
</TestPlans>
<Testables>
<TestableReference
skipped = "NO"
parallelizable = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "2AD14E2B2ACDC3ED0015EB20"
BuildableName = "ObservationExplorationsTests.xctest"
BlueprintName = "ObservationExplorationsTests"
ReferencedContainer = "container:ObservationExplorations.xcodeproj">
</BuildableReference>
</TestableReference>
<TestableReference
skipped = "NO"
parallelizable = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "2AD14E352ACDC3ED0015EB20"
BuildableName = "ObservationExplorationsUITests.xctest"
BlueprintName = "ObservationExplorationsUITests"
ReferencedContainer = "container:ObservationExplorations.xcodeproj">
</BuildableReference>
</TestableReference>
</Testables>
</TestAction>
<LaunchAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
launchStyle = "0"
useCustomWorkingDirectory = "NO"
ignoresPersistentStateOnLaunch = "NO"
debugDocumentVersioning = "YES"
debugServiceExtension = "internal"
allowLocationSimulation = "YES">
<BuildableProductRunnable
runnableDebuggingMode = "0">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "2AD14E1B2ACDC3EC0015EB20"
BuildableName = "ObservationExplorations.app"
BlueprintName = "ObservationExplorations"
ReferencedContainer = "container:ObservationExplorations.xcodeproj">
</BuildableReference>
</BuildableProductRunnable>
</LaunchAction>
<ProfileAction
buildConfiguration = "Release"
shouldUseLaunchSchemeArgsEnv = "YES"
savedToolIdentifier = ""
useCustomWorkingDirectory = "NO"
debugDocumentVersioning = "YES">
<BuildableProductRunnable
runnableDebuggingMode = "0">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "2AD14E1B2ACDC3EC0015EB20"
BuildableName = "ObservationExplorations.app"
BlueprintName = "ObservationExplorations"
ReferencedContainer = "container:ObservationExplorations.xcodeproj">
</BuildableReference>
</BuildableProductRunnable>
</ProfileAction>
<AnalyzeAction
buildConfiguration = "Debug">
</AnalyzeAction>
<ArchiveAction
buildConfiguration = "Release"
revealArchiveInOrganizer = "YES">
</ArchiveAction>
</Scheme>
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
import SwiftUI

@Observable
class AppModel {
let tab1 = CounterModel()
let tab2 = CounterModel()
let tab3 = ListModel()
}

struct AppView: View {
let model: AppModel

var body: some View {
let _ = Self._printChanges()

TabView {
NavigationStack {
CounterView(model: self.model.tab1)
.navigationTitle(Text("Counter 1"))
}
.badge(self.model.tab1.count)
.tabItem { Text("Counter 1") }

NavigationStack {
CounterView(model: self.model.tab2)
.navigationTitle(Text("Counter 2"))
}
.badge(self.model.tab2.count)
.tabItem { Text("Counter 2") }

NavigationStack {
ListView(model: self.model.tab3)
.navigationTitle(Text("Counter 3"))
}
//.badge(self.model.tab3.counters.count)
.badge(self.model.tab3.counters.first?.count ?? 0)
.tabItem { Text("Counter 3") }
}
}
}

#Preview {
AppView(model: AppModel())
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
import Combine
import SwiftUI

class AppModel_ObservableObject: ObservableObject {
@Published var tab1 = CounterModel_ObservableObject()
@Published var tab2 = CounterModel_ObservableObject()
@Published var tab3 = CounterModel_ObservableObject()

private var cancellables: Set<AnyCancellable> = []

init() {
self.tab1.$count.sink { [weak self] _ in
self?.objectWillChange.send()
}
.store(in: &self.cancellables)
self.tab2.objectWillChange.sink { [weak self] in
self?.objectWillChange.send()
}
.store(in: &self.cancellables)
self.tab3.objectWillChange.sink { [weak self] in
self?.objectWillChange.send()
}
.store(in: &self.cancellables)
}
}

struct AppView_ObservableObject: View {
@ObservedObject var model: AppModel_ObservableObject


var body: some View {
let _ = Self._printChanges()

TabView {
NavigationStack {
CounterView_ObservableObject(model: self.model.tab1)
.navigationTitle(Text("Counter 1"))
}
.badge(self.model.tab1.count)
.tabItem { Text("Counter 1") }

NavigationStack {
CounterView_ObservableObject(model: self.model.tab2)
.navigationTitle(Text("Counter 2"))
}
.tabItem { Text("Counter 2") }

NavigationStack {
CounterView_ObservableObject(model: self.model.tab3)
.navigationTitle(Text("Counter 3"))
}
.tabItem { Text("Counter 3") }
}
}
}

#Preview {
AppView_ObservableObject(model: AppModel_ObservableObject())
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"colors" : [
{
"idiom" : "universal"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"images" : [
{
"idiom" : "universal",
"platform" : "ios",
"size" : "1024x1024"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"info" : {
"author" : "xcode",
"version" : 1
}
}
Loading

0 comments on commit 456a3fd

Please sign in to comment.