Compare commits

...

1 Commits

Author SHA1 Message Date
= 7d9e69f473 add Cat Screen and navigate from gesture 2024-03-11 18:50:42 +03:00
8 changed files with 139 additions and 2 deletions

BIN
.DS_Store vendored

Binary file not shown.

View File

@ -7,6 +7,8 @@
objects = {
/* Begin PBXBuildFile section */
2AC2AEF22B9F53D300CD717D /* Kities.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2AC2AEF12B9F53D300CD717D /* Kities.swift */; };
2AC2AEF52B9F584F00CD717D /* SDWebImageSwiftUI in Frameworks */ = {isa = PBXBuildFile; productRef = 2AC2AEF42B9F584F00CD717D /* SDWebImageSwiftUI */; };
2AD701EB2B9EAA970058791B /* commentsApp.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2AD701EA2B9EAA970058791B /* commentsApp.swift */; };
2AD701ED2B9EAA970058791B /* ContentView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2AD701EC2B9EAA970058791B /* ContentView.swift */; };
2AD701EF2B9EAA990058791B /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 2AD701EE2B9EAA990058791B /* Assets.xcassets */; };
@ -18,6 +20,7 @@
/* End PBXBuildFile section */
/* Begin PBXFileReference section */
2AC2AEF12B9F53D300CD717D /* Kities.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Kities.swift; sourceTree = "<group>"; };
2AD701E72B9EAA970058791B /* comments.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = comments.app; sourceTree = BUILT_PRODUCTS_DIR; };
2AD701EA2B9EAA970058791B /* commentsApp.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = commentsApp.swift; sourceTree = "<group>"; };
2AD701EC2B9EAA970058791B /* ContentView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ContentView.swift; sourceTree = "<group>"; };
@ -32,6 +35,7 @@
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
2AC2AEF52B9F584F00CD717D /* SDWebImageSwiftUI in Frameworks */,
2AD701FA2B9EAB540058791B /* Alamofire in Frameworks */,
2AF729782B9F060200B4C04E /* DynamicColor in Frameworks */,
2AD701FC2B9EAB540058791B /* AlamofireDynamic in Frameworks */,
@ -60,6 +64,7 @@
2AD701E92B9EAA970058791B /* comments */ = {
isa = PBXGroup;
children = (
2AC2AEF12B9F53D300CD717D /* Kities.swift */,
2AF729752B9EDA0B00B4C04E /* Info.plist */,
2AD701EA2B9EAA970058791B /* commentsApp.swift */,
2AD701EC2B9EAA970058791B /* ContentView.swift */,
@ -98,6 +103,7 @@
2AD701F92B9EAB540058791B /* Alamofire */,
2AD701FB2B9EAB540058791B /* AlamofireDynamic */,
2AF729772B9F060200B4C04E /* DynamicColor */,
2AC2AEF42B9F584F00CD717D /* SDWebImageSwiftUI */,
);
productName = comments;
productReference = 2AD701E72B9EAA970058791B /* comments.app */;
@ -130,6 +136,7 @@
packageReferences = (
2AD701F82B9EAB520058791B /* XCRemoteSwiftPackageReference "Alamofire" */,
2AF729762B9F060100B4C04E /* XCRemoteSwiftPackageReference "DynamicColor" */,
2AC2AEF32B9F584F00CD717D /* XCRemoteSwiftPackageReference "SDWebImageSwiftUI" */,
);
productRefGroup = 2AD701E82B9EAA970058791B /* Products */;
projectDirPath = "";
@ -157,6 +164,7 @@
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
2AC2AEF22B9F53D300CD717D /* Kities.swift in Sources */,
2AD701FE2B9EAFF00058791B /* Api.swift in Sources */,
2AD701ED2B9EAA970058791B /* ContentView.swift in Sources */,
2AD701EB2B9EAA970058791B /* commentsApp.swift in Sources */,
@ -369,6 +377,14 @@
/* End XCConfigurationList section */
/* Begin XCRemoteSwiftPackageReference section */
2AC2AEF32B9F584F00CD717D /* XCRemoteSwiftPackageReference "SDWebImageSwiftUI" */ = {
isa = XCRemoteSwiftPackageReference;
repositoryURL = "https://github.com/SDWebImage/SDWebImageSwiftUI";
requirement = {
kind = upToNextMajorVersion;
minimumVersion = 3.0.0;
};
};
2AD701F82B9EAB520058791B /* XCRemoteSwiftPackageReference "Alamofire" */ = {
isa = XCRemoteSwiftPackageReference;
repositoryURL = "https://github.com/Alamofire/Alamofire";
@ -388,6 +404,11 @@
/* End XCRemoteSwiftPackageReference section */
/* Begin XCSwiftPackageProductDependency section */
2AC2AEF42B9F584F00CD717D /* SDWebImageSwiftUI */ = {
isa = XCSwiftPackageProductDependency;
package = 2AC2AEF32B9F584F00CD717D /* XCRemoteSwiftPackageReference "SDWebImageSwiftUI" */;
productName = SDWebImageSwiftUI;
};
2AD701F92B9EAB540058791B /* Alamofire */ = {
isa = XCSwiftPackageProductDependency;
package = 2AD701F82B9EAB520058791B /* XCRemoteSwiftPackageReference "Alamofire" */;

View File

@ -17,6 +17,24 @@
"revision" : "d9beca13ca85baa50ee29832d0db5129fba69630",
"version" : "5.0.1"
}
},
{
"identity" : "sdwebimage",
"kind" : "remoteSourceControl",
"location" : "https://github.com/SDWebImage/SDWebImage.git",
"state" : {
"revision" : "73b9397cfbd902f606572964055464903b1d84c6",
"version" : "5.19.0"
}
},
{
"identity" : "sdwebimageswiftui",
"kind" : "remoteSourceControl",
"location" : "https://github.com/SDWebImage/SDWebImageSwiftUI",
"state" : {
"revision" : "e057a3cda6aabfa94eda0f604518f76c5efe8ca1",
"version" : "3.0.0"
}
}
],
"version" : 2

View File

@ -20,5 +20,37 @@
landmarkType = "7">
</BreakpointContent>
</BreakpointProxy>
<BreakpointProxy
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
<BreakpointContent
uuid = "8E4BB86A-A28C-44AB-ADB4-A59ED7DDC3AC"
shouldBeEnabled = "No"
ignoreCount = "0"
continueAfterRunningActions = "No"
filePath = "comments/ContentView.swift"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "143"
endingLineNumber = "143"
landmarkName = "DetailedCardView"
landmarkType = "14">
</BreakpointContent>
</BreakpointProxy>
<BreakpointProxy
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
<BreakpointContent
uuid = "23C31929-321F-447B-B75D-114222BE0A65"
shouldBeEnabled = "No"
ignoreCount = "0"
continueAfterRunningActions = "No"
filePath = "comments/Kities.swift"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "40"
endingLineNumber = "40"
landmarkName = "body"
landmarkType = "24">
</BreakpointContent>
</BreakpointProxy>
</Breakpoints>
</Bucket>

View File

@ -28,7 +28,7 @@
<key>comments.xcscheme_^#shared#^_</key>
<dict>
<key>orderHint</key>
<integer>1</integer>
<integer>0</integer>
</dict>
</dict>
</dict>

View File

@ -49,6 +49,8 @@ struct BalanceView: View {
}
}
struct Cat: Hashable {}
struct ContentView: View {
@State var posts: [PostStruct] = []
@ -57,7 +59,9 @@ struct ContentView: View {
ZStack{
Color.bg.ignoresSafeArea()
VStack {
Image(.logo)
NavigationLink(value: Cat()) {
Image(.logo)
}
BalanceView().padding(.bottom, 24)
CardsView()
@ -69,6 +73,9 @@ struct ContentView: View {
DetailedCardView(card: card)
.navigationBarHidden(true)
})
.navigationDestination(for: Cat.self, destination: {cat in
KityView()
})
.navigationBarHidden(true)
}
}}

59
comments/Kities.swift Normal file
View File

@ -0,0 +1,59 @@
//
// Kities.swift
// comments
//
// Created by Георгий Сигалев on 11.03.2024.
//
import Foundation
import SwiftUI
import Alamofire
import SDWebImage
import SDWebImageSwiftUI
struct CatResponse: Identifiable, Decodable {
var id: String
var url: String
var width: Int
var height: Int
}
func fetchKities() async -> CatResponse? {
let result = await AF.request("https://api.thecatapi.com/v1/images/search").serializingDecodable([CatResponse].self).result
var data: [CatResponse] = []
do {
try data = result.get()
} catch {
return nil
}
return data[0]
}
struct KityView: View {
@State var url: String?
@Environment(\.dismiss) private var dismiss
@ViewBuilder
var body: some View{
VStack {
if url != nil {
WebImage(url: URL(string: url!))
}
else {
Text("Загрузка...")
}
}.task {
guard let cat = (await fetchKities()) else {
dismiss()
return
}
self.url = cat.url
}
}
}