Skip to content

Commit

Permalink
[DEV][Added Empty View]
Browse files Browse the repository at this point in the history
  • Loading branch information
developersancho committed Mar 12, 2022
1 parent e7e5154 commit f367ccc
Show file tree
Hide file tree
Showing 6 changed files with 59 additions and 17 deletions.
16 changes: 16 additions & 0 deletions SwiftRorty.iOS.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@
E26BD3A327D01629006CA548 /* DetailHeaderView.swift in Sources */ = {isa = PBXBuildFile; fileRef = E26BD3A227D01629006CA548 /* DetailHeaderView.swift */; };
E26BD3A527D01769006CA548 /* DetailContentView.swift in Sources */ = {isa = PBXBuildFile; fileRef = E26BD3A427D01769006CA548 /* DetailContentView.swift */; };
E27D2FF027DBE28E00A9B5B8 /* ViewExtension.swift in Sources */ = {isa = PBXBuildFile; fileRef = E27D2FEF27DBE28E00A9B5B8 /* ViewExtension.swift */; };
E27D2FF227DC21C200A9B5B8 /* EmptyStateViewModifier.swift in Sources */ = {isa = PBXBuildFile; fileRef = E27D2FF127DC21C200A9B5B8 /* EmptyStateViewModifier.swift */; };
E27D2FF527DC238B00A9B5B8 /* empty.json in Resources */ = {isa = PBXBuildFile; fileRef = E27D2FF427DC238B00A9B5B8 /* empty.json */; };
E28A38BF27C94730005DD497 /* DtoExtension.swift in Sources */ = {isa = PBXBuildFile; fileRef = E28A38BE27C94730005DD497 /* DtoExtension.swift */; };
E2900B9627D3F6080055AD96 /* CheckboxToggleStyle.swift in Sources */ = {isa = PBXBuildFile; fileRef = E2900B9527D3F6080055AD96 /* CheckboxToggleStyle.swift */; };
E2900B9827D3F6290055AD96 /* VerticalToggleStyle.swift in Sources */ = {isa = PBXBuildFile; fileRef = E2900B9727D3F6290055AD96 /* VerticalToggleStyle.swift */; };
Expand Down Expand Up @@ -167,6 +169,8 @@
E26BD3A227D01629006CA548 /* DetailHeaderView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DetailHeaderView.swift; sourceTree = "<group>"; };
E26BD3A427D01769006CA548 /* DetailContentView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DetailContentView.swift; sourceTree = "<group>"; };
E27D2FEF27DBE28E00A9B5B8 /* ViewExtension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ViewExtension.swift; sourceTree = "<group>"; };
E27D2FF127DC21C200A9B5B8 /* EmptyStateViewModifier.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = EmptyStateViewModifier.swift; sourceTree = "<group>"; };
E27D2FF427DC238B00A9B5B8 /* empty.json */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.json; path = empty.json; sourceTree = "<group>"; };
E28A38BE27C94730005DD497 /* DtoExtension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DtoExtension.swift; sourceTree = "<group>"; };
E2900B9527D3F6080055AD96 /* CheckboxToggleStyle.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CheckboxToggleStyle.swift; sourceTree = "<group>"; };
E2900B9727D3F6290055AD96 /* VerticalToggleStyle.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = VerticalToggleStyle.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -274,6 +278,7 @@
E2291D3127A5E908006D3FD8 /* SwiftRorty.iOS */ = {
isa = PBXGroup;
children = (
E27D2FF327DC237A00A9B5B8 /* lottie */,
E222E80027D693A900831125 /* languages */,
E2AF0A3F27CD88EB0012EE85 /* extensions */,
E232FA1527CD63AB0073FCC8 /* SwiftRorty-iOS-Info.plist */,
Expand Down Expand Up @@ -525,10 +530,19 @@
E2900B9527D3F6080055AD96 /* CheckboxToggleStyle.swift */,
E2900B9727D3F6290055AD96 /* VerticalToggleStyle.swift */,
E2900B9927D3F74A0055AD96 /* ColoredToggleStyle.swift */,
E27D2FF127DC21C200A9B5B8 /* EmptyStateViewModifier.swift */,
);
path = component;
sourceTree = "<group>";
};
E27D2FF327DC237A00A9B5B8 /* lottie */ = {
isa = PBXGroup;
children = (
E27D2FF427DC238B00A9B5B8 /* empty.json */,
);
path = lottie;
sourceTree = "<group>";
};
E28A38C027C94B19005DD497 /* network_2 */ = {
isa = PBXGroup;
children = (
Expand Down Expand Up @@ -773,6 +787,7 @@
E2291D3727A5E909006D3FD8 /* Assets.xcassets in Resources */,
E232FA1027CD56780073FCC8 /* Raleway-Medium.ttf in Resources */,
E232FA1127CD56780073FCC8 /* Raleway-Bold.ttf in Resources */,
E27D2FF527DC238B00A9B5B8 /* empty.json in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down Expand Up @@ -963,6 +978,7 @@
E2291D6C27A5F33F006D3FD8 /* CharactersScreen.swift in Sources */,
E2D5A98F27C97CEC0017DA32 /* URLRequest.swift in Sources */,
E2991ABB27AC771E00BF4B9A /* CharacterInfo.swift in Sources */,
E27D2FF227DC21C200A9B5B8 /* EmptyStateViewModifier.swift in Sources */,
E28A38BF27C94730005DD497 /* DtoExtension.swift in Sources */,
E2291D3327A5E908006D3FD8 /* SwiftRorty_iOSApp.swift in Sources */,
E2900B9C27D3FF720055AD96 /* UITabBarControllerExtension.swift in Sources */,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,21 +68,5 @@
landmarkType = "7">
</BreakpointContent>
</BreakpointProxy>
<BreakpointProxy
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
<BreakpointContent
uuid = "6D67F390-A476-4E19-86C2-BFAA3C105EF8"
shouldBeEnabled = "No"
ignoreCount = "0"
continueAfterRunningActions = "No"
filePath = "SwiftRorty.iOS/presentation/features/favorites/FavoritesScreen.swift"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "36"
endingLineNumber = "36"
landmarkName = "body"
landmarkType = "24">
</BreakpointContent>
</BreakpointProxy>
</Breakpoints>
</Bucket>
30 changes: 30 additions & 0 deletions SwiftRorty.iOS/component/EmptyStateViewModifier.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
//
// EmptyStateViewModifier.swift
// SwiftRorty.iOS
//
// Created by developersancho on 12.03.2022.
//

import Foundation
import SwiftUI

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))
}
}
1 change: 1 addition & 0 deletions SwiftRorty.iOS/languages/en.lproj/Localizable.strings
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,5 @@
"text_gender" = "Gender";
"text_last_know_location" = "Last Know Location";
"text_location" = "Location";
"text_no_data_found" = "No suitable data found.";

1 change: 1 addition & 0 deletions SwiftRorty.iOS/lottie/empty.json

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,17 @@ struct FavoritesScreen: View {
FavoriteRow(dto: character)
})
}
}.padding(10)
}
.padding(10)
.emptyState(viewModel.favorites.isEmpty) {
LazyVStack {
LottieView(name: "empty", loopMode: .loop)
.frame(width: 250, height: 250)
.padding(.init(top: 20, leading: 0, bottom: 10, trailing: 0))
Spacer()
Text(LocalizedStringKey("text_no_data_found")).fontTemplate(AppFontTemplate.heading)
}
}
}
.background(Color.Background)
.navigationBarTitleDisplayMode(.inline)
Expand Down

0 comments on commit f367ccc

Please sign in to comment.