Skip to content

Commit

Permalink
Merge branch 'feature/empty-state' into develop
Browse files Browse the repository at this point in the history
This resolves #68

Signed-off-by: Peter Friese <[email protected]>
  • Loading branch information
peterfriese committed Nov 12, 2021
2 parents 0dd0b72 + 352d919 commit 2d77c64
Show file tree
Hide file tree
Showing 4 changed files with 162 additions and 0 deletions.
22 changes: 22 additions & 0 deletions code/frontend/MakeItSo/MakeItSo.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@

/* Begin PBXBuildFile section */
881EF5BD272DC399004761E5 /* View+Focus.swift in Sources */ = {isa = PBXBuildFile; fileRef = 881EF5BC272DC399004761E5 /* View+Focus.swift */; };
887B6FAD273ED4180028263D /* EmptyStateView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 887B6FA9273ED4180028263D /* EmptyStateView.swift */; };
887B6FAE273ED4180028263D /* EmptyStateView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 887B6FA9273ED4180028263D /* EmptyStateView.swift */; };
88FEECDA27275ABD00ED368C /* MakeItSoApp.swift in Sources */ = {isa = PBXBuildFile; fileRef = 88FEECCA27275ABC00ED368C /* MakeItSoApp.swift */; };
88FEECDB27275ABD00ED368C /* MakeItSoApp.swift in Sources */ = {isa = PBXBuildFile; fileRef = 88FEECCA27275ABC00ED368C /* MakeItSoApp.swift */; };
88FEECDE27275ABD00ED368C /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 88FEECCC27275ABD00ED368C /* Assets.xcassets */; };
Expand All @@ -24,6 +26,7 @@

/* Begin PBXFileReference section */
881EF5BC272DC399004761E5 /* View+Focus.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "View+Focus.swift"; sourceTree = "<group>"; };
887B6FA9273ED4180028263D /* EmptyStateView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = EmptyStateView.swift; sourceTree = "<group>"; };
88FEECCA27275ABC00ED368C /* MakeItSoApp.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MakeItSoApp.swift; sourceTree = "<group>"; };
88FEECCC27275ABD00ED368C /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; };
88FEECD127275ABD00ED368C /* MakeItSo.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = MakeItSo.app; sourceTree = BUILT_PRODUCTS_DIR; };
Expand Down Expand Up @@ -61,6 +64,22 @@
path = Extensions;
sourceTree = "<group>";
};
887B6FA6273ED4180028263D /* Common */ = {
isa = PBXGroup;
children = (
887B6FA7273ED4180028263D /* Views */,
);
path = Common;
sourceTree = "<group>";
};
887B6FA7273ED4180028263D /* Views */ = {
isa = PBXGroup;
children = (
887B6FA9273ED4180028263D /* EmptyStateView.swift */,
);
path = Views;
sourceTree = "<group>";
};
88FEECC427275ABC00ED368C = {
isa = PBXGroup;
children = (
Expand All @@ -73,6 +92,7 @@
88FEECC927275ABC00ED368C /* Shared */ = {
isa = PBXGroup;
children = (
887B6FA6273ED4180028263D /* Common */,
881EF5BB272DC366004761E5 /* Extensions */,
88FEECEB2727FEC100ED368C /* Features */,
88FEECCA27275ABC00ED368C /* MakeItSoApp.swift */,
Expand Down Expand Up @@ -241,6 +261,7 @@
files = (
88FEECF02727FEFF00ED368C /* Task.swift in Sources */,
88FEECFA27280F3D00ED368C /* TaskListRowView.swift in Sources */,
887B6FAD273ED4180028263D /* EmptyStateView.swift in Sources */,
88FEECDA27275ABD00ED368C /* MakeItSoApp.swift in Sources */,
881EF5BD272DC399004761E5 /* View+Focus.swift in Sources */,
88FEECF32728044100ED368C /* TasksListView.swift in Sources */,
Expand All @@ -257,6 +278,7 @@
88FEECDB27275ABD00ED368C /* MakeItSoApp.swift in Sources */,
88FEECF42728044100ED368C /* TasksListView.swift in Sources */,
88FEECF82728072D00ED368C /* TasksListViewModel.swift in Sources */,
887B6FAE273ED4180028263D /* EmptyStateView.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1320"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
buildImplicitDependencies = "YES">
<BuildActionEntries>
<BuildActionEntry
buildForTesting = "YES"
buildForRunning = "YES"
buildForProfiling = "YES"
buildForArchiving = "YES"
buildForAnalyzing = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "88FEECD027275ABD00ED368C"
BuildableName = "MakeItSo.app"
BlueprintName = "MakeItSo (iOS)"
ReferencedContainer = "container:MakeItSo.xcodeproj">
</BuildableReference>
</BuildActionEntry>
</BuildActionEntries>
</BuildAction>
<TestAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
shouldUseLaunchSchemeArgsEnv = "YES">
<Testables>
</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 = "88FEECD027275ABD00ED368C"
BuildableName = "MakeItSo.app"
BlueprintName = "MakeItSo (iOS)"
ReferencedContainer = "container:MakeItSo.xcodeproj">
</BuildableReference>
</BuildableProductRunnable>
</LaunchAction>
<ProfileAction
buildConfiguration = "Release"
shouldUseLaunchSchemeArgsEnv = "YES"
savedToolIdentifier = ""
useCustomWorkingDirectory = "NO"
debugDocumentVersioning = "YES">
<BuildableProductRunnable
runnableDebuggingMode = "0">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "88FEECD027275ABD00ED368C"
BuildableName = "MakeItSo.app"
BlueprintName = "MakeItSo (iOS)"
ReferencedContainer = "container:MakeItSo.xcodeproj">
</BuildableReference>
</BuildableProductRunnable>
</ProfileAction>
<AnalyzeAction
buildConfiguration = "Debug">
</AnalyzeAction>
<ArchiveAction
buildConfiguration = "Release"
revealArchiveInOrganizer = "YES">
</ArchiveAction>
</Scheme>
57 changes: 57 additions & 0 deletions code/frontend/MakeItSo/Shared/Common/Views/EmptyStateView.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
//
// EmptyStateView.swift
// MakeItSo (iOS)
//
// Created by Peter Friese on 12.11.21.
// Copyright © 2021 Google LLC. All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http:https://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

import SwiftUI

extension View {
func debug() -> Self {
print(Mirror(reflecting: self).subjectType)
return self
}
}

struct EmptyStateViewModifier<EmptyContent>: ViewModifier where EmptyContent: View {
var isEmpty: Bool
let emptyContent: () -> EmptyContent

func body(content: Content) -> some View {
if isEmpty {
emptyContent()
}
else {
content
}
}
}

extension View {
func emptyState<EmptyContent>(_ isEmpty: Bool,
emptyContent: @escaping () -> EmptyContent) -> some View where EmptyContent: View {
modifier(EmptyStateViewModifier(isEmpty: isEmpty, emptyContent: emptyContent))
}
}

struct EmptyStateView_Previews: PreviewProvider {
static var previews: some View {
Label("Content", systemImage: "heart")
.emptyState(true) {
Text("We don't have any content, sorry 😔")
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,11 @@ struct TasksListView: View {
}
}
}
.emptyState(!$viewModel.tasks.isEmpty) {
Text("No Reminders")
.font(.title3)
.foregroundColor(Color.secondary)
}
.sync($viewModel.focusedTask, $focusedTask)
.animation(.default, value: viewModel.tasks)
.listStyle(.plain)
Expand Down

0 comments on commit 2d77c64

Please sign in to comment.