Nested ZStack modifiers in progress/empty modifiers (#876)
Merge into a single modifier because they are used together.
This commit is contained in:
parent
55bb2e79c9
commit
b08243949c
|
@ -114,8 +114,11 @@ private struct ContainerModifier: ViewModifier {
|
||||||
func body(content: Content) -> some View {
|
func body(content: Content) -> some View {
|
||||||
debugChanges()
|
debugChanges()
|
||||||
return content
|
return content
|
||||||
.themeProgress(if: !profileManager.isReady)
|
.themeProgress(
|
||||||
.themeEmptyContent(if: profileManager.isReady && !profileManager.hasProfiles, message: Strings.Views.Profiles.Folders.noProfiles)
|
if: !profileManager.isReady,
|
||||||
|
isEmpty: !profileManager.hasProfiles,
|
||||||
|
emptyMessage: Strings.Views.Profiles.Folders.noProfiles
|
||||||
|
)
|
||||||
.searchable(text: $search)
|
.searchable(text: $search)
|
||||||
.onChange(of: search) {
|
.onChange(of: search) {
|
||||||
profileManager.search(byName: $0)
|
profileManager.search(byName: $0)
|
||||||
|
|
|
@ -65,8 +65,11 @@ struct MigrateView: View {
|
||||||
.disabled(model.step != .fetched)
|
.disabled(model.step != .fetched)
|
||||||
}
|
}
|
||||||
.themeForm()
|
.themeForm()
|
||||||
.themeProgress(if: model.step == .fetching)
|
.themeProgress(
|
||||||
.themeEmptyContent(if: model.step == .fetched && model.profiles.isEmpty, message: "Nothing to migrate")
|
if: model.step == .fetching,
|
||||||
|
isEmpty: model.profiles.isEmpty,
|
||||||
|
emptyMessage: "Nothing to migrate"
|
||||||
|
)
|
||||||
.themeAnimation(on: model, category: .profiles)
|
.themeAnimation(on: model, category: .profiles)
|
||||||
.navigationTitle(title)
|
.navigationTitle(title)
|
||||||
.toolbar(content: toolbarContent)
|
.toolbar(content: toolbarContent)
|
||||||
|
|
|
@ -35,6 +35,9 @@ extension View {
|
||||||
}
|
}
|
||||||
|
|
||||||
public func withMockEnvironment() -> some View {
|
public func withMockEnvironment() -> some View {
|
||||||
withEnvironment(from: .mock, theme: Theme())
|
task {
|
||||||
|
try? await AppContext.mock.profileManager.observeLocal()
|
||||||
|
}
|
||||||
|
.withEnvironment(from: .mock, theme: Theme())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -163,8 +163,8 @@ extension View {
|
||||||
modifier(ThemeProgressViewModifier(isProgressing: isProgressing))
|
modifier(ThemeProgressViewModifier(isProgressing: isProgressing))
|
||||||
}
|
}
|
||||||
|
|
||||||
public func themeEmptyContent(if isEmpty: Bool, message: String) -> some View {
|
public func themeProgress(if isProgressing: Bool, isEmpty: Bool, emptyMessage: String) -> some View {
|
||||||
modifier(ThemeEmptyContentModifier(isEmpty: isEmpty, message: message))
|
modifier(ThemeProgressViewModifier(isProgressing: isProgressing, isEmpty: isEmpty, emptyMessage: emptyMessage))
|
||||||
}
|
}
|
||||||
|
|
||||||
#if !os(tvOS)
|
#if !os(tvOS)
|
||||||
|
@ -370,31 +370,20 @@ struct ThemeAnimationModifier<T>: ViewModifier where T: Equatable {
|
||||||
struct ThemeProgressViewModifier: ViewModifier {
|
struct ThemeProgressViewModifier: ViewModifier {
|
||||||
let isProgressing: Bool
|
let isProgressing: Bool
|
||||||
|
|
||||||
|
var isEmpty: Bool?
|
||||||
|
|
||||||
|
var emptyMessage: String?
|
||||||
|
|
||||||
func body(content: Content) -> some View {
|
func body(content: Content) -> some View {
|
||||||
ZStack {
|
ZStack {
|
||||||
|
content
|
||||||
|
.opaque(!isProgressing && isEmpty != true)
|
||||||
|
|
||||||
if isProgressing {
|
if isProgressing {
|
||||||
ThemeProgressView()
|
ThemeProgressView()
|
||||||
}
|
} else if let isEmpty, let emptyMessage, isEmpty {
|
||||||
content
|
Text(emptyMessage)
|
||||||
.opaque(!isProgressing)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
struct ThemeEmptyContentModifier: ViewModifier {
|
|
||||||
let isEmpty: Bool
|
|
||||||
|
|
||||||
let message: String
|
|
||||||
|
|
||||||
func body(content: Content) -> some View {
|
|
||||||
ZStack {
|
|
||||||
content
|
|
||||||
.opaque(!isEmpty)
|
|
||||||
|
|
||||||
if isEmpty {
|
|
||||||
Text(message)
|
|
||||||
.themeEmptyMessage()
|
.themeEmptyMessage()
|
||||||
.opaque(isEmpty)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue