Skip to content

Commit be0db68

Browse files
committed
Merge branch 'release/1.0.4'
2 parents eb95be3 + 14ab9fc commit be0db68

File tree

8 files changed

+359
-265
lines changed

8 files changed

+359
-265
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,10 @@
11
# swiftui-navigation-stack Changelog
22

3+
## 1.0.4
4+
- Code cleaning.
5+
- Improved documentation.
6+
- NavigationStack has now a depth property.
7+
- Added MacOS and WatchOS deployment target to Podspec.
8+
39
## 1.0.3
410
- Fixed Package.swift: the watchOS platform was missing.

LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
MIT License
22

3-
Copyright (c) 2020 BioBeats Inc.
3+
Copyright (c) 2020 Matteo Puccinelli.
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the "Software"), to deal

NavigationStack.podspec

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Pod::Spec.new do |s|
22
s.name = 'NavigationStack'
3-
s.version = '1.0.2'
3+
s.version = '1.0.4'
44
s.summary = 'An alternative SwiftUI NavigationView.'
55

66
s.description = <<-DESC
@@ -15,6 +15,8 @@ Pod::Spec.new do |s|
1515

1616

1717
s.ios.deployment_target = '13.0'
18+
s.osx.deployment_target = '10.15'
19+
s.watchos.deployment_target = '6.0'
1820
s.swift_version = '5.0'
1921
s.source_files = 'Sources/NavigationStack/**/*'
2022

README.md

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ enum ViewDestinations {
137137
}
138138

139139
struct MyHome: View {
140-
@ObservedObject private var viewModel = ViewModel()
140+
@ObservedObject var viewModel: ViewModel
141141
@State private var isSelected: ViewDestinations? = .noDestination
142142

143143
var body: some View {
@@ -172,7 +172,7 @@ Inside the `NavigationStackView` you have access to the navigation stack as an `
172172

173173
```swift
174174
struct MyHome: View {
175-
@ObservedObject private var viewModel = ViewModel()
175+
@ObservedObject var viewModel: ViewModel
176176
@EnvironmentObject private var navigationStack: NavigationStack
177177

178178
var body: some View {
@@ -196,7 +196,7 @@ It's not mandatory, but if you want to come back to a specific view at some poin
196196
```swift
197197
struct MyHome: View {
198198
private static let childID = "childID"
199-
@ObservedObject private var viewModel = ViewModel()
199+
@ObservedObject var viewModel: ViewModel
200200
@EnvironmentObject private var navigationStack: NavigationStack
201201

202202
var body: some View {
@@ -263,7 +263,7 @@ struct ChildView: View {
263263

264264
```swift
265265
struct ChildView: View {
266-
@ObservedObject private var viewModel = ViewModel()
266+
@ObservedObject var viewModel: ViewModel
267267
@EnvironmentObject private var navigationStack: NavigationStack
268268

269269
var body: some View {
@@ -433,20 +433,15 @@ This time the transition animation involves the whole screen:
433433

434434
## Issues
435435

436-
- SwiftUI resets all the properties of a view marked with `@State` every time the view is removed from a view hierarchy. For the `NavigationStackView` this is a problem because when I come back to a previous view (with a pop operation) I want all my view controls to be as I left them before (for example I want my `TextField`s to contain the text I previously typed in). It seems that the solution to this problem is using the `.id` modifier specifying an id for the views I don't want SwiftUI to reset. According to the Apple documentation the `.id` modifier:
437-
438-
> Summary
439-
> Generates a uniquely identified view that can be inserted or removed.
440-
441-
but again, it seems that this API is currently not working as expected (take a look at this interesting post: https://swiftui-lab.com/swiftui-id/). In order to workaround this problem, then, you have to use `@ObservableObject` when you need to make some state persist between push/pop operations. For example:
436+
- SwiftUI resets all the properties of a view marked with `@State` every time the view is removed from a view hierarchy. For the `NavigationStackView` this is a problem because when I come back to a previous view (with a pop operation) I want all my view controls to be as I left them before (for example I want my `TextField`s to contain the text I previously typed in). In order to workaround this problem you have to use `@ObservableObject` when you need to make some state persist between push/pop operations. For example:
442437

443438
```swift
444439
class ViewModel: ObservableObject {
445440
@Published var text = ""
446441
}
447442

448443
struct MyView: View {
449-
@ObservedObject var viewModel = ViewModel()
444+
@ObservedObject var viewModel: ViewModel
450445

451446
var body: some View {
452447
VStack {
@@ -461,4 +456,4 @@ struct MyView: View {
461456

462457
### Other
463458

464-
SwiftUI is really new, there are some bugs in the framework (or unexpected behaviours) and several API not yet documented. Please, report any issue may arise and feel free to suggest any improvement or changing to this first implementation of a navigation stack.
459+
SwiftUI is really new, there are some unexpected behaviours and several API not yet documented. Please, report any issue may arise and feel free to suggest any improvement or changing to this implementation of a navigation stack.

0 commit comments

Comments
 (0)