Skip to content

Commit

Permalink
Added SwiftUIPagingHelper for better interation with SwiftUI
Browse files Browse the repository at this point in the history
  • Loading branch information
AshuTyagi16 committed Jan 15, 2024
1 parent b6ac797 commit 2d8de74
Show file tree
Hide file tree
Showing 24 changed files with 592 additions and 84 deletions.
1 change: 0 additions & 1 deletion .idea/gradle.xml

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

69 changes: 69 additions & 0 deletions IosApp/Ios.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,12 @@
6D94E8EE2B542BBA0037911E /* Shimmer in Frameworks */ = {isa = PBXBuildFile; productRef = 6D94E8ED2B542BBA0037911E /* Shimmer */; };
6D94E8F02B542FA20037911E /* HomePageScreen.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6D94E8EF2B542FA20037911E /* HomePageScreen.swift */; };
6D94E8F32B5431590037911E /* Kingfisher in Frameworks */ = {isa = PBXBuildFile; productRef = 6D94E8F22B5431590037911E /* Kingfisher */; };
6D94E8F72B543B6C0037911E /* PlaylistDetailScreen.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6D94E8F62B543B6C0037911E /* PlaylistDetailScreen.swift */; };
6D94E9002B5466270037911E /* FlowStacks in Frameworks */ = {isa = PBXBuildFile; productRef = 6D94E8FF2B5466270037911E /* FlowStacks */; };
6D94E9022B5466340037911E /* Routes.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6D94E9012B5466340037911E /* Routes.swift */; };
6D94E9052B559C900037911E /* ListLoadingItem.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6D94E9042B559C900037911E /* ListLoadingItem.swift */; };
6D94E9072B559DA30037911E /* ListErrorItem.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6D94E9062B559DA30037911E /* ListErrorItem.swift */; };
6D94E90A2B55A5ED0037911E /* ViewExtensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6D94E9092B55A5ED0037911E /* ViewExtensions.swift */; };
6DDF6A3A2B51C61C00B523D6 /* IosApp.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6DDF6A392B51C61C00B523D6 /* IosApp.swift */; };
6DDF6A3E2B51C61E00B523D6 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 6DDF6A3D2B51C61E00B523D6 /* Assets.xcassets */; };
6DDF6A412B51C61E00B523D6 /* Preview Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 6DDF6A402B51C61E00B523D6 /* Preview Assets.xcassets */; };
Expand Down Expand Up @@ -42,6 +48,11 @@
5BB434876916D96227FF05D9 /* Pods_Ios.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_Ios.framework; sourceTree = BUILT_PRODUCTS_DIR; };
6D94E8EA2B5429E70037911E /* HomeScreenLoadingPlaceholder.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HomeScreenLoadingPlaceholder.swift; sourceTree = "<group>"; };
6D94E8EF2B542FA20037911E /* HomePageScreen.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HomePageScreen.swift; sourceTree = "<group>"; };
6D94E8F62B543B6C0037911E /* PlaylistDetailScreen.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PlaylistDetailScreen.swift; sourceTree = "<group>"; };
6D94E9012B5466340037911E /* Routes.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Routes.swift; sourceTree = "<group>"; };
6D94E9042B559C900037911E /* ListLoadingItem.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ListLoadingItem.swift; sourceTree = "<group>"; };
6D94E9062B559DA30037911E /* ListErrorItem.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ListErrorItem.swift; sourceTree = "<group>"; };
6D94E9092B55A5ED0037911E /* ViewExtensions.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ViewExtensions.swift; sourceTree = "<group>"; };
6DDF6A362B51C61C00B523D6 /* Ios.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Ios.app; sourceTree = BUILT_PRODUCTS_DIR; };
6DDF6A392B51C61C00B523D6 /* IosApp.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = IosApp.swift; sourceTree = "<group>"; };
6DDF6A3D2B51C61E00B523D6 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; };
Expand All @@ -62,6 +73,7 @@
6D94E8F32B5431590037911E /* Kingfisher in Frameworks */,
6D94E8EE2B542BBA0037911E /* Shimmer in Frameworks */,
96872C2BEB48581621465B15 /* Pods_Ios.framework in Frameworks */,
6D94E9002B5466270037911E /* FlowStacks in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down Expand Up @@ -99,6 +111,40 @@
path = ui;
sourceTree = "<group>";
};
6D94E8F42B543B240037911E /* feature-playlist-detail */ = {
isa = PBXGroup;
children = (
6D94E8F52B543B300037911E /* ui */,
);
path = "feature-playlist-detail";
sourceTree = "<group>";
};
6D94E8F52B543B300037911E /* ui */ = {
isa = PBXGroup;
children = (
6D94E8F62B543B6C0037911E /* PlaylistDetailScreen.swift */,
);
path = ui;
sourceTree = "<group>";
};
6D94E9032B559C860037911E /* core-ui */ = {
isa = PBXGroup;
children = (
6D94E9082B55A5D90037911E /* extensions */,
6D94E9042B559C900037911E /* ListLoadingItem.swift */,
6D94E9062B559DA30037911E /* ListErrorItem.swift */,
);
path = "core-ui";
sourceTree = "<group>";
};
6D94E9082B55A5D90037911E /* extensions */ = {
isa = PBXGroup;
children = (
6D94E9092B55A5ED0037911E /* ViewExtensions.swift */,
);
path = extensions;
sourceTree = "<group>";
};
6DDF6A2D2B51C61C00B523D6 = {
isa = PBXGroup;
children = (
Expand All @@ -124,10 +170,13 @@
6DDF6A382B51C61C00B523D6 /* Ios */ = {
isa = PBXGroup;
children = (
6D94E9032B559C860037911E /* core-ui */,
6D94E8F42B543B240037911E /* feature-playlist-detail */,
6D94E8E72B5429A80037911E /* feature-homepage */,
6DDF6A392B51C61C00B523D6 /* IosApp.swift */,
6DDF6A3D2B51C61E00B523D6 /* Assets.xcassets */,
6DDF6A3F2B51C61E00B523D6 /* Preview Content */,
6D94E9012B5466340037911E /* Routes.swift */,
);
path = Ios;
sourceTree = "<group>";
Expand Down Expand Up @@ -194,6 +243,7 @@
packageProductDependencies = (
6D94E8ED2B542BBA0037911E /* Shimmer */,
6D94E8F22B5431590037911E /* Kingfisher */,
6D94E8FF2B5466270037911E /* FlowStacks */,
);
productName = Ios;
productReference = 6DDF6A362B51C61C00B523D6 /* Ios.app */;
Expand Down Expand Up @@ -270,6 +320,7 @@
packageReferences = (
6D94E8EC2B542BB90037911E /* XCRemoteSwiftPackageReference "SwiftUI-Shimmer" */,
6D94E8F12B5431590037911E /* XCRemoteSwiftPackageReference "Kingfisher" */,
6D94E8FE2B5466270037911E /* XCRemoteSwiftPackageReference "FlowStacks" */,
);
productRefGroup = 6DDF6A372B51C61C00B523D6 /* Products */;
projectDirPath = "";
Expand Down Expand Up @@ -338,9 +389,14 @@
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
6D94E9022B5466340037911E /* Routes.swift in Sources */,
6D94E8F02B542FA20037911E /* HomePageScreen.swift in Sources */,
6D94E90A2B55A5ED0037911E /* ViewExtensions.swift in Sources */,
6D94E8EB2B5429E70037911E /* HomeScreenLoadingPlaceholder.swift in Sources */,
6D94E9072B559DA30037911E /* ListErrorItem.swift in Sources */,
6D94E8F72B543B6C0037911E /* PlaylistDetailScreen.swift in Sources */,
6DDF6A3A2B51C61C00B523D6 /* IosApp.swift in Sources */,
6D94E9052B559C900037911E /* ListLoadingItem.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down Expand Up @@ -692,6 +748,14 @@
minimumVersion = 7.10.2;
};
};
6D94E8FE2B5466270037911E /* XCRemoteSwiftPackageReference "FlowStacks" */ = {
isa = XCRemoteSwiftPackageReference;
repositoryURL = "https://github.com/johnpatrickmorgan/FlowStacks";
requirement = {
kind = upToNextMajorVersion;
minimumVersion = 0.3.8;
};
};
/* End XCRemoteSwiftPackageReference section */

/* Begin XCSwiftPackageProductDependency section */
Expand All @@ -705,6 +769,11 @@
package = 6D94E8F12B5431590037911E /* XCRemoteSwiftPackageReference "Kingfisher" */;
productName = Kingfisher;
};
6D94E8FF2B5466270037911E /* FlowStacks */ = {
isa = XCSwiftPackageProductDependency;
package = 6D94E8FE2B5466270037911E /* XCRemoteSwiftPackageReference "FlowStacks" */;
productName = FlowStacks;
};
/* End XCSwiftPackageProductDependency section */
};
rootObject = 6DDF6A2E2B51C61C00B523D6 /* Project object */;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
{
"pins" : [
{
"identity" : "flowstacks",
"kind" : "remoteSourceControl",
"location" : "https://github.com/johnpatrickmorgan/FlowStacks",
"state" : {
"revision" : "9629bd329146d4ba476bfdb50d293acbf8ba3f5d",
"version" : "0.3.8"
}
},
{
"identity" : "kingfisher",
"kind" : "remoteSourceControl",
"location" : "https://github.com/onevcat/Kingfisher.git",
"state" : {
"revision" : "3ec0ab0bca4feb56e8b33e289c9496e89059dd08",
"version" : "7.10.2"
}
},
{
"identity" : "swiftui-shimmer",
"kind" : "remoteSourceControl",
"location" : "https://github.com/markiv/SwiftUI-Shimmer",
"state" : {
"revision" : "1f3a620e4abe890d00008cb2af7023d810b433a7",
"version" : "1.4.0"
}
}
],
"version" : 2
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<key>Ios.xcscheme_^#shared#^_</key>
<dict>
<key>orderHint</key>
<integer>2</integer>
<integer>3</integer>
</dict>
</dict>
</dict>
Expand Down
9 changes: 9 additions & 0 deletions IosApp/Ios.xcworkspace/xcshareddata/swiftpm/Package.resolved
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
{
"pins" : [
{
"identity" : "flowstacks",
"kind" : "remoteSourceControl",
"location" : "https://github.com/johnpatrickmorgan/FlowStacks",
"state" : {
"revision" : "9629bd329146d4ba476bfdb50d293acbf8ba3f5d",
"version" : "0.3.8"
}
},
{
"identity" : "kingfisher",
"kind" : "remoteSourceControl",
Expand Down
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -505,5 +505,21 @@
</Locations>
</BreakpointContent>
</BreakpointProxy>
<BreakpointProxy
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
<BreakpointContent
uuid = "9F1BF7C1-5DDE-4D93-A31B-2CD91755FD52"
shouldBeEnabled = "Yes"
ignoreCount = "0"
continueAfterRunningActions = "No"
filePath = "Ios/feature-playlist-detail/ui/PlaylistDetailScreen.swift"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "89"
endingLineNumber = "89"
landmarkName = "body"
landmarkType = "24">
</BreakpointContent>
</BreakpointProxy>
</Breakpoints>
</Bucket>
7 changes: 7 additions & 0 deletions IosApp/Ios/IosApp.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,25 @@
//

import SwiftUI
import FlowStacks
import shared

@main
struct IosApp: App {

@State private var routes: Routes<AppRoute> = []

init() {
KoinInitializerKt.doInitKoin()
}

var body: some Scene {
WindowGroup {
HomePageScreen()
.showing($routes, embedInNavigationView: true) { route, _ in
route.getView()
.hideNavigationBar()
}
}
}
}
44 changes: 44 additions & 0 deletions IosApp/Ios/Routes.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
//
// Routes.swift
// Ios
//
// Created by Ashu Tyagi on 15/01/24.
//

import Foundation
import SwiftUI

enum AppRoute: Equatable {
static func == (lhs: AppRoute, rhs: AppRoute) -> Bool {
return lhs.key == rhs.key
}

case PlaylistDetail(
playlistId: String
)

case AlbumDetail(
albumId: String
)

var key: String {
switch self {
case .PlaylistDetail:
return "PlaylistDetail"
case .AlbumDetail:
return "AlbumDetail"
}
}
}

extension AppRoute {
@ViewBuilder
func getView() -> some View {
switch self {
case.PlaylistDetail(playlistId: let playlistId):
PlaylistDetailScreen(playlisId: playlistId)
case .AlbumDetail(albumId: let albumId):
EmptyView()
}
}
}
46 changes: 46 additions & 0 deletions IosApp/Ios/core-ui/ListErrorItem.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
//
// ListErrorItem.swift
// Ios
//
// Created by Ashu Tyagi on 15/01/24.
//

import Foundation
import SwiftUI

struct ListErrorItem: View {

var errorMessage: String
var onRetryClicked : () -> Void = {}

var body: some View {
VStack(spacing: 0) {

Text(errorMessage)
.foregroundColor(Color.white)
.font(.system(size: 14, weight: .semibold))
.padding(.vertical, 10)

Button(action: {
onRetryClicked()
}) {
Text("Retry")
.foregroundColor(Color.black)
.font(.system(size: 14, weight: .semibold))
.padding(.all, 8)
}
.background(Color.white)
.cornerRadius(12)
}
.padding(.all, 12)
.frame(maxWidth: .infinity)
}
}

#Preview {
ListErrorItem(
errorMessage: "Som error occurred",
onRetryClicked: {}
)
.background(Color.black)
}
24 changes: 24 additions & 0 deletions IosApp/Ios/core-ui/ListLoadingItem.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
//
// ListLoadingItem.swift
// Ios
//
// Created by Ashu Tyagi on 15/01/24.
//

import Foundation
import SwiftUI

struct ListLoadingItem: View {

var body: some View {
VStack(alignment: .center, spacing: 0) {
Text("Loading...")
.foregroundColor(.white)
.padding(.vertical, 6)
ProgressView()
.progressViewStyle(CircularProgressViewStyle(tint: Color.white))
.padding(.all, 10)

}
}
}
Loading

0 comments on commit 2d8de74

Please sign in to comment.