mirror of
https://github.com/Dimillian/IceCubesApp.git
synced 2024-09-27 22:11:56 +00:00
New Routeur
This commit is contained in:
parent
202bf06dc6
commit
567cb4cc47
23 changed files with 321 additions and 81 deletions
|
@ -7,22 +7,31 @@
|
||||||
objects = {
|
objects = {
|
||||||
|
|
||||||
/* Begin PBXBuildFile section */
|
/* Begin PBXBuildFile section */
|
||||||
|
9F24EEB829360C330042359D /* Preview Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 9F24EEB729360C330042359D /* Preview Assets.xcassets */; };
|
||||||
|
9F24EEBB293619210042359D /* Routeur in Frameworks */ = {isa = PBXBuildFile; productRef = 9F24EEBA293619210042359D /* Routeur */; };
|
||||||
9F295540292B6C3400E0E81B /* Timeline in Frameworks */ = {isa = PBXBuildFile; productRef = 9F29553F292B6C3400E0E81B /* Timeline */; };
|
9F295540292B6C3400E0E81B /* Timeline in Frameworks */ = {isa = PBXBuildFile; productRef = 9F29553F292B6C3400E0E81B /* Timeline */; };
|
||||||
|
9F398AA62935FE8A00A889F2 /* AppRouteur.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9F398AA52935FE8A00A889F2 /* AppRouteur.swift */; };
|
||||||
|
9F398AA92935FFDB00A889F2 /* Account in Frameworks */ = {isa = PBXBuildFile; productRef = 9F398AA82935FFDB00A889F2 /* Account */; };
|
||||||
|
9F398AAB2935FFDB00A889F2 /* Models in Frameworks */ = {isa = PBXBuildFile; productRef = 9F398AAA2935FFDB00A889F2 /* Models */; };
|
||||||
|
9F398AB329360A4C00A889F2 /* TimelineTabView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9F398AB229360A4C00A889F2 /* TimelineTabView.swift */; };
|
||||||
9FBFE63D292A715500C250E9 /* IceCubesAppApp.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9FBFE63C292A715500C250E9 /* IceCubesAppApp.swift */; };
|
9FBFE63D292A715500C250E9 /* IceCubesAppApp.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9FBFE63C292A715500C250E9 /* IceCubesAppApp.swift */; };
|
||||||
9FBFE641292A715600C250E9 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 9FBFE640292A715600C250E9 /* Assets.xcassets */; };
|
9FBFE641292A715600C250E9 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 9FBFE640292A715600C250E9 /* Assets.xcassets */; };
|
||||||
9FBFE645292A715600C250E9 /* Preview Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 9FBFE644292A715600C250E9 /* Preview Assets.xcassets */; };
|
|
||||||
9FBFE64E292A72BD00C250E9 /* Network in Frameworks */ = {isa = PBXBuildFile; productRef = 9FBFE64D292A72BD00C250E9 /* Network */; };
|
9FBFE64E292A72BD00C250E9 /* Network in Frameworks */ = {isa = PBXBuildFile; productRef = 9FBFE64D292A72BD00C250E9 /* Network */; };
|
||||||
/* End PBXBuildFile section */
|
/* End PBXBuildFile section */
|
||||||
|
|
||||||
/* Begin PBXFileReference section */
|
/* Begin PBXFileReference section */
|
||||||
|
9F24EEB729360C330042359D /* Preview Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = "Preview Assets.xcassets"; sourceTree = "<group>"; };
|
||||||
|
9F24EEB92936185B0042359D /* Routeur */ = {isa = PBXFileReference; lastKnownFileType = wrapper; name = Routeur; path = Packages/Routeur; sourceTree = "<group>"; };
|
||||||
9F29553D292B67B600E0E81B /* Network */ = {isa = PBXFileReference; lastKnownFileType = wrapper; name = Network; path = Packages/Network; sourceTree = "<group>"; };
|
9F29553D292B67B600E0E81B /* Network */ = {isa = PBXFileReference; lastKnownFileType = wrapper; name = Network; path = Packages/Network; sourceTree = "<group>"; };
|
||||||
9F29553E292B6AF600E0E81B /* Timeline */ = {isa = PBXFileReference; lastKnownFileType = wrapper; name = Timeline; path = Packages/Timeline; sourceTree = "<group>"; };
|
9F29553E292B6AF600E0E81B /* Timeline */ = {isa = PBXFileReference; lastKnownFileType = wrapper; name = Timeline; path = Packages/Timeline; sourceTree = "<group>"; };
|
||||||
9F398AA32935F90100A889F2 /* Models */ = {isa = PBXFileReference; lastKnownFileType = wrapper; name = Models; path = Packages/Models; sourceTree = "<group>"; };
|
9F398AA32935F90100A889F2 /* Models */ = {isa = PBXFileReference; lastKnownFileType = wrapper; name = Models; path = Packages/Models; sourceTree = "<group>"; };
|
||||||
|
9F398AA52935FE8A00A889F2 /* AppRouteur.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppRouteur.swift; sourceTree = "<group>"; };
|
||||||
|
9F398AAC2936005300A889F2 /* Account */ = {isa = PBXFileReference; lastKnownFileType = wrapper; name = Account; path = Packages/Account; sourceTree = "<group>"; };
|
||||||
|
9F398AB229360A4C00A889F2 /* TimelineTabView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TimelineTabView.swift; sourceTree = "<group>"; };
|
||||||
9FBFE639292A715500C250E9 /* IceCubesApp.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = IceCubesApp.app; sourceTree = BUILT_PRODUCTS_DIR; };
|
9FBFE639292A715500C250E9 /* IceCubesApp.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = IceCubesApp.app; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||||
9FBFE63C292A715500C250E9 /* IceCubesAppApp.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = IceCubesAppApp.swift; sourceTree = "<group>"; };
|
9FBFE63C292A715500C250E9 /* IceCubesAppApp.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = IceCubesAppApp.swift; sourceTree = "<group>"; };
|
||||||
9FBFE640292A715600C250E9 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; };
|
9FBFE640292A715600C250E9 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; };
|
||||||
9FBFE642292A715600C250E9 /* IceCubesApp.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = IceCubesApp.entitlements; sourceTree = "<group>"; };
|
9FBFE642292A715600C250E9 /* IceCubesApp.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = IceCubesApp.entitlements; sourceTree = "<group>"; };
|
||||||
9FBFE644292A715600C250E9 /* Preview Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = "Preview Assets.xcassets"; sourceTree = "<group>"; };
|
|
||||||
/* End PBXFileReference section */
|
/* End PBXFileReference section */
|
||||||
|
|
||||||
/* Begin PBXFrameworksBuildPhase section */
|
/* Begin PBXFrameworksBuildPhase section */
|
||||||
|
@ -30,7 +39,10 @@
|
||||||
isa = PBXFrameworksBuildPhase;
|
isa = PBXFrameworksBuildPhase;
|
||||||
buildActionMask = 2147483647;
|
buildActionMask = 2147483647;
|
||||||
files = (
|
files = (
|
||||||
|
9F398AA92935FFDB00A889F2 /* Account in Frameworks */,
|
||||||
9FBFE64E292A72BD00C250E9 /* Network in Frameworks */,
|
9FBFE64E292A72BD00C250E9 /* Network in Frameworks */,
|
||||||
|
9F398AAB2935FFDB00A889F2 /* Models in Frameworks */,
|
||||||
|
9F24EEBB293619210042359D /* Routeur in Frameworks */,
|
||||||
9F295540292B6C3400E0E81B /* Timeline in Frameworks */,
|
9F295540292B6C3400E0E81B /* Timeline in Frameworks */,
|
||||||
);
|
);
|
||||||
runOnlyForDeploymentPostprocessing = 0;
|
runOnlyForDeploymentPostprocessing = 0;
|
||||||
|
@ -38,14 +50,35 @@
|
||||||
/* End PBXFrameworksBuildPhase section */
|
/* End PBXFrameworksBuildPhase section */
|
||||||
|
|
||||||
/* Begin PBXGroup section */
|
/* Begin PBXGroup section */
|
||||||
|
9F398AB429360A5800A889F2 /* App */ = {
|
||||||
|
isa = PBXGroup;
|
||||||
|
children = (
|
||||||
|
9FBFE63C292A715500C250E9 /* IceCubesAppApp.swift */,
|
||||||
|
9F398AA52935FE8A00A889F2 /* AppRouteur.swift */,
|
||||||
|
9F398AB229360A4C00A889F2 /* TimelineTabView.swift */,
|
||||||
|
);
|
||||||
|
path = App;
|
||||||
|
sourceTree = "<group>";
|
||||||
|
};
|
||||||
|
9F398AB529360A6100A889F2 /* Resources */ = {
|
||||||
|
isa = PBXGroup;
|
||||||
|
children = (
|
||||||
|
9F24EEB729360C330042359D /* Preview Assets.xcassets */,
|
||||||
|
9FBFE640292A715600C250E9 /* Assets.xcassets */,
|
||||||
|
);
|
||||||
|
path = Resources;
|
||||||
|
sourceTree = "<group>";
|
||||||
|
};
|
||||||
9FBFE630292A715500C250E9 = {
|
9FBFE630292A715500C250E9 = {
|
||||||
isa = PBXGroup;
|
isa = PBXGroup;
|
||||||
children = (
|
children = (
|
||||||
9FBFE63B292A715500C250E9 /* IceCubesApp */,
|
9FBFE63B292A715500C250E9 /* IceCubesApp */,
|
||||||
9FBFE63A292A715500C250E9 /* Products */,
|
9FBFE63A292A715500C250E9 /* Products */,
|
||||||
9FBFE64C292A72BD00C250E9 /* Frameworks */,
|
9FBFE64C292A72BD00C250E9 /* Frameworks */,
|
||||||
|
9F398AAC2936005300A889F2 /* Account */,
|
||||||
9F398AA32935F90100A889F2 /* Models */,
|
9F398AA32935F90100A889F2 /* Models */,
|
||||||
9F29553E292B6AF600E0E81B /* Timeline */,
|
9F29553E292B6AF600E0E81B /* Timeline */,
|
||||||
|
9F24EEB92936185B0042359D /* Routeur */,
|
||||||
9F29553D292B67B600E0E81B /* Network */,
|
9F29553D292B67B600E0E81B /* Network */,
|
||||||
);
|
);
|
||||||
sourceTree = "<group>";
|
sourceTree = "<group>";
|
||||||
|
@ -61,22 +94,13 @@
|
||||||
9FBFE63B292A715500C250E9 /* IceCubesApp */ = {
|
9FBFE63B292A715500C250E9 /* IceCubesApp */ = {
|
||||||
isa = PBXGroup;
|
isa = PBXGroup;
|
||||||
children = (
|
children = (
|
||||||
9FBFE63C292A715500C250E9 /* IceCubesAppApp.swift */,
|
9F398AB429360A5800A889F2 /* App */,
|
||||||
9FBFE640292A715600C250E9 /* Assets.xcassets */,
|
|
||||||
9FBFE642292A715600C250E9 /* IceCubesApp.entitlements */,
|
9FBFE642292A715600C250E9 /* IceCubesApp.entitlements */,
|
||||||
9FBFE643292A715600C250E9 /* Preview Content */,
|
9F398AB529360A6100A889F2 /* Resources */,
|
||||||
);
|
);
|
||||||
path = IceCubesApp;
|
path = IceCubesApp;
|
||||||
sourceTree = "<group>";
|
sourceTree = "<group>";
|
||||||
};
|
};
|
||||||
9FBFE643292A715600C250E9 /* Preview Content */ = {
|
|
||||||
isa = PBXGroup;
|
|
||||||
children = (
|
|
||||||
9FBFE644292A715600C250E9 /* Preview Assets.xcassets */,
|
|
||||||
);
|
|
||||||
path = "Preview Content";
|
|
||||||
sourceTree = "<group>";
|
|
||||||
};
|
|
||||||
9FBFE64C292A72BD00C250E9 /* Frameworks */ = {
|
9FBFE64C292A72BD00C250E9 /* Frameworks */ = {
|
||||||
isa = PBXGroup;
|
isa = PBXGroup;
|
||||||
children = (
|
children = (
|
||||||
|
@ -103,6 +127,9 @@
|
||||||
packageProductDependencies = (
|
packageProductDependencies = (
|
||||||
9FBFE64D292A72BD00C250E9 /* Network */,
|
9FBFE64D292A72BD00C250E9 /* Network */,
|
||||||
9F29553F292B6C3400E0E81B /* Timeline */,
|
9F29553F292B6C3400E0E81B /* Timeline */,
|
||||||
|
9F398AA82935FFDB00A889F2 /* Account */,
|
||||||
|
9F398AAA2935FFDB00A889F2 /* Models */,
|
||||||
|
9F24EEBA293619210042359D /* Routeur */,
|
||||||
);
|
);
|
||||||
productName = IceCubesApp;
|
productName = IceCubesApp;
|
||||||
productReference = 9FBFE639292A715500C250E9 /* IceCubesApp.app */;
|
productReference = 9FBFE639292A715500C250E9 /* IceCubesApp.app */;
|
||||||
|
@ -146,7 +173,7 @@
|
||||||
isa = PBXResourcesBuildPhase;
|
isa = PBXResourcesBuildPhase;
|
||||||
buildActionMask = 2147483647;
|
buildActionMask = 2147483647;
|
||||||
files = (
|
files = (
|
||||||
9FBFE645292A715600C250E9 /* Preview Assets.xcassets in Resources */,
|
9F24EEB829360C330042359D /* Preview Assets.xcassets in Resources */,
|
||||||
9FBFE641292A715600C250E9 /* Assets.xcassets in Resources */,
|
9FBFE641292A715600C250E9 /* Assets.xcassets in Resources */,
|
||||||
);
|
);
|
||||||
runOnlyForDeploymentPostprocessing = 0;
|
runOnlyForDeploymentPostprocessing = 0;
|
||||||
|
@ -158,6 +185,8 @@
|
||||||
isa = PBXSourcesBuildPhase;
|
isa = PBXSourcesBuildPhase;
|
||||||
buildActionMask = 2147483647;
|
buildActionMask = 2147483647;
|
||||||
files = (
|
files = (
|
||||||
|
9F398AB329360A4C00A889F2 /* TimelineTabView.swift in Sources */,
|
||||||
|
9F398AA62935FE8A00A889F2 /* AppRouteur.swift in Sources */,
|
||||||
9FBFE63D292A715500C250E9 /* IceCubesAppApp.swift in Sources */,
|
9FBFE63D292A715500C250E9 /* IceCubesAppApp.swift in Sources */,
|
||||||
);
|
);
|
||||||
runOnlyForDeploymentPostprocessing = 0;
|
runOnlyForDeploymentPostprocessing = 0;
|
||||||
|
@ -282,7 +311,7 @@
|
||||||
CODE_SIGN_ENTITLEMENTS = IceCubesApp/IceCubesApp.entitlements;
|
CODE_SIGN_ENTITLEMENTS = IceCubesApp/IceCubesApp.entitlements;
|
||||||
CODE_SIGN_STYLE = Automatic;
|
CODE_SIGN_STYLE = Automatic;
|
||||||
CURRENT_PROJECT_VERSION = 1;
|
CURRENT_PROJECT_VERSION = 1;
|
||||||
DEVELOPMENT_ASSET_PATHS = "\"IceCubesApp/Preview Content\"";
|
DEVELOPMENT_ASSET_PATHS = "\"IceCubesApp/Resources\"";
|
||||||
DEVELOPMENT_TEAM = Z6P74P6T99;
|
DEVELOPMENT_TEAM = Z6P74P6T99;
|
||||||
ENABLE_HARDENED_RUNTIME = YES;
|
ENABLE_HARDENED_RUNTIME = YES;
|
||||||
ENABLE_PREVIEWS = YES;
|
ENABLE_PREVIEWS = YES;
|
||||||
|
@ -320,7 +349,7 @@
|
||||||
CODE_SIGN_ENTITLEMENTS = IceCubesApp/IceCubesApp.entitlements;
|
CODE_SIGN_ENTITLEMENTS = IceCubesApp/IceCubesApp.entitlements;
|
||||||
CODE_SIGN_STYLE = Automatic;
|
CODE_SIGN_STYLE = Automatic;
|
||||||
CURRENT_PROJECT_VERSION = 1;
|
CURRENT_PROJECT_VERSION = 1;
|
||||||
DEVELOPMENT_ASSET_PATHS = "\"IceCubesApp/Preview Content\"";
|
DEVELOPMENT_ASSET_PATHS = "\"IceCubesApp/Resources\"";
|
||||||
DEVELOPMENT_TEAM = Z6P74P6T99;
|
DEVELOPMENT_TEAM = Z6P74P6T99;
|
||||||
ENABLE_HARDENED_RUNTIME = YES;
|
ENABLE_HARDENED_RUNTIME = YES;
|
||||||
ENABLE_PREVIEWS = YES;
|
ENABLE_PREVIEWS = YES;
|
||||||
|
@ -374,10 +403,22 @@
|
||||||
/* End XCConfigurationList section */
|
/* End XCConfigurationList section */
|
||||||
|
|
||||||
/* Begin XCSwiftPackageProductDependency section */
|
/* Begin XCSwiftPackageProductDependency section */
|
||||||
|
9F24EEBA293619210042359D /* Routeur */ = {
|
||||||
|
isa = XCSwiftPackageProductDependency;
|
||||||
|
productName = Routeur;
|
||||||
|
};
|
||||||
9F29553F292B6C3400E0E81B /* Timeline */ = {
|
9F29553F292B6C3400E0E81B /* Timeline */ = {
|
||||||
isa = XCSwiftPackageProductDependency;
|
isa = XCSwiftPackageProductDependency;
|
||||||
productName = Timeline;
|
productName = Timeline;
|
||||||
};
|
};
|
||||||
|
9F398AA82935FFDB00A889F2 /* Account */ = {
|
||||||
|
isa = XCSwiftPackageProductDependency;
|
||||||
|
productName = Account;
|
||||||
|
};
|
||||||
|
9F398AAA2935FFDB00A889F2 /* Models */ = {
|
||||||
|
isa = XCSwiftPackageProductDependency;
|
||||||
|
productName = Models;
|
||||||
|
};
|
||||||
9FBFE64D292A72BD00C250E9 /* Network */ = {
|
9FBFE64D292A72BD00C250E9 /* Network */ = {
|
||||||
isa = XCSwiftPackageProductDependency;
|
isa = XCSwiftPackageProductDependency;
|
||||||
productName = Network;
|
productName = Network;
|
||||||
|
|
17
IceCubesApp/App/AppRouteur.swift
Normal file
17
IceCubesApp/App/AppRouteur.swift
Normal file
|
@ -0,0 +1,17 @@
|
||||||
|
import SwiftUI
|
||||||
|
import Timeline
|
||||||
|
import Account
|
||||||
|
import Routeur
|
||||||
|
|
||||||
|
extension View {
|
||||||
|
func withAppRouteur() -> some View {
|
||||||
|
self.navigationDestination(for: RouteurDestinations.self) { destination in
|
||||||
|
switch destination {
|
||||||
|
case let .accountDetail(id):
|
||||||
|
AccountView(accountId: id)
|
||||||
|
case let .statusDetail(id):
|
||||||
|
StatusDetailView(statusId: id)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
41
IceCubesApp/App/IceCubesAppApp.swift
Normal file
41
IceCubesApp/App/IceCubesAppApp.swift
Normal file
|
@ -0,0 +1,41 @@
|
||||||
|
import SwiftUI
|
||||||
|
import Timeline
|
||||||
|
import Network
|
||||||
|
import Shared
|
||||||
|
|
||||||
|
@main
|
||||||
|
struct IceCubesAppApp: App {
|
||||||
|
@State private var tabs: [String] = ["mastodon.social"]
|
||||||
|
@State private var isServerSelectDisplayed: Bool = false
|
||||||
|
@State private var newServerURL: String = ""
|
||||||
|
|
||||||
|
var body: some Scene {
|
||||||
|
WindowGroup {
|
||||||
|
TabView {
|
||||||
|
ForEach(tabs, id: \.self) { tab in
|
||||||
|
TimelineTabView(tab: tab)
|
||||||
|
.tabItem {
|
||||||
|
Label(tab, systemImage: "globe")
|
||||||
|
}
|
||||||
|
.toolbar {
|
||||||
|
ToolbarItem(placement: .navigationBarTrailing) {
|
||||||
|
Button {
|
||||||
|
isServerSelectDisplayed.toggle()
|
||||||
|
} label: {
|
||||||
|
Image(systemName: "globe")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
.alert("Connect to another server", isPresented: $isServerSelectDisplayed) {
|
||||||
|
TextField(tab, text: $newServerURL)
|
||||||
|
Button("Connect", action: {
|
||||||
|
tabs.append(newServerURL)
|
||||||
|
newServerURL = ""
|
||||||
|
})
|
||||||
|
Button("Cancel", role: .cancel, action: {})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
16
IceCubesApp/App/TimelineTabView.swift
Normal file
16
IceCubesApp/App/TimelineTabView.swift
Normal file
|
@ -0,0 +1,16 @@
|
||||||
|
import SwiftUI
|
||||||
|
import Timeline
|
||||||
|
import Routeur
|
||||||
|
|
||||||
|
struct TimelineTabView: View {
|
||||||
|
let tab: String
|
||||||
|
@StateObject private var routeurPath = RouterPath()
|
||||||
|
|
||||||
|
var body: some View {
|
||||||
|
NavigationStack(path: $routeurPath.path) {
|
||||||
|
TimelineView(client: .init(server: tab))
|
||||||
|
.withAppRouteur()
|
||||||
|
}
|
||||||
|
.environmentObject(routeurPath)
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,42 +0,0 @@
|
||||||
import SwiftUI
|
|
||||||
import Timeline
|
|
||||||
import Network
|
|
||||||
|
|
||||||
@main
|
|
||||||
struct IceCubesAppApp: App {
|
|
||||||
@State private var tabs: [String] = ["mastodon.social"]
|
|
||||||
@State private var isServerSelectDisplayed: Bool = false
|
|
||||||
@State private var newServerURL: String = ""
|
|
||||||
|
|
||||||
var body: some Scene {
|
|
||||||
WindowGroup {
|
|
||||||
TabView {
|
|
||||||
ForEach(tabs, id: \.self) { tab in
|
|
||||||
NavigationStack {
|
|
||||||
TimelineView(client: .init(server: tab))
|
|
||||||
.toolbar {
|
|
||||||
ToolbarItem(placement: .navigationBarTrailing) {
|
|
||||||
Button {
|
|
||||||
isServerSelectDisplayed.toggle()
|
|
||||||
} label: {
|
|
||||||
Image(systemName: "globe")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
.alert("Connect to another server", isPresented: $isServerSelectDisplayed) {
|
|
||||||
TextField(tab, text: $newServerURL)
|
|
||||||
Button("Connect", action: {
|
|
||||||
tabs.append(newServerURL)
|
|
||||||
newServerURL = ""
|
|
||||||
})
|
|
||||||
Button("Cancel", role: .cancel, action: {})
|
|
||||||
}
|
|
||||||
}
|
|
||||||
.tabItem {
|
|
||||||
Label(tab, systemImage: "globe")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
9
Packages/Account/.gitignore
vendored
Normal file
9
Packages/Account/.gitignore
vendored
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
.DS_Store
|
||||||
|
/.build
|
||||||
|
/Packages
|
||||||
|
/*.xcodeproj
|
||||||
|
xcuserdata/
|
||||||
|
DerivedData/
|
||||||
|
.swiftpm/config/registries.json
|
||||||
|
.swiftpm/xcode/package.xcworkspace/contents.xcworkspacedata
|
||||||
|
.netrc
|
31
Packages/Account/Package.swift
Normal file
31
Packages/Account/Package.swift
Normal file
|
@ -0,0 +1,31 @@
|
||||||
|
// swift-tools-version: 5.7
|
||||||
|
// The swift-tools-version declares the minimum version of Swift required to build this package.
|
||||||
|
|
||||||
|
import PackageDescription
|
||||||
|
|
||||||
|
let package = Package(
|
||||||
|
name: "Account",
|
||||||
|
platforms: [
|
||||||
|
.iOS(.v16),
|
||||||
|
],
|
||||||
|
products: [
|
||||||
|
.library(
|
||||||
|
name: "Account",
|
||||||
|
targets: ["Account"]),
|
||||||
|
],
|
||||||
|
dependencies: [
|
||||||
|
.package(name: "Network", path: "../Network"),
|
||||||
|
.package(name: "Models", path: "../Models"),
|
||||||
|
],
|
||||||
|
targets: [
|
||||||
|
.target(
|
||||||
|
name: "Account",
|
||||||
|
dependencies: [
|
||||||
|
.product(name: "Network", package: "Network"),
|
||||||
|
.product(name: "Models", package: "Models")
|
||||||
|
]),
|
||||||
|
.testTarget(
|
||||||
|
name: "AccountTests",
|
||||||
|
dependencies: ["Account"]),
|
||||||
|
]
|
||||||
|
)
|
3
Packages/Account/README.md
Normal file
3
Packages/Account/README.md
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
# Account
|
||||||
|
|
||||||
|
A description of this package.
|
14
Packages/Account/Sources/Account/AccountView.swift
Normal file
14
Packages/Account/Sources/Account/AccountView.swift
Normal file
|
@ -0,0 +1,14 @@
|
||||||
|
import SwiftUI
|
||||||
|
import Models
|
||||||
|
|
||||||
|
public struct AccountView: View {
|
||||||
|
private let accountId: String
|
||||||
|
|
||||||
|
public init(accountId: String) {
|
||||||
|
self.accountId = accountId
|
||||||
|
}
|
||||||
|
|
||||||
|
public var body: some View {
|
||||||
|
Text("Account id \(accountId)")
|
||||||
|
}
|
||||||
|
}
|
11
Packages/Account/Tests/AccountTests/AccountTests.swift
Normal file
11
Packages/Account/Tests/AccountTests/AccountTests.swift
Normal file
|
@ -0,0 +1,11 @@
|
||||||
|
import XCTest
|
||||||
|
@testable import Account
|
||||||
|
|
||||||
|
final class AccountTests: XCTestCase {
|
||||||
|
func testExample() throws {
|
||||||
|
// This is an example of a functional test case.
|
||||||
|
// Use XCTAssert and related functions to verify your tests produce the correct
|
||||||
|
// results.
|
||||||
|
XCTAssertEqual(Account().text, "Hello, World!")
|
||||||
|
}
|
||||||
|
}
|
9
Packages/Routeur/.gitignore
vendored
Normal file
9
Packages/Routeur/.gitignore
vendored
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
.DS_Store
|
||||||
|
/.build
|
||||||
|
/Packages
|
||||||
|
/*.xcodeproj
|
||||||
|
xcuserdata/
|
||||||
|
DerivedData/
|
||||||
|
.swiftpm/config/registries.json
|
||||||
|
.swiftpm/xcode/package.xcworkspace/contents.xcworkspacedata
|
||||||
|
.netrc
|
25
Packages/Routeur/Package.swift
Normal file
25
Packages/Routeur/Package.swift
Normal file
|
@ -0,0 +1,25 @@
|
||||||
|
// swift-tools-version: 5.7
|
||||||
|
// The swift-tools-version declares the minimum version of Swift required to build this package.
|
||||||
|
|
||||||
|
import PackageDescription
|
||||||
|
|
||||||
|
let package = Package(
|
||||||
|
name: "Routeur",
|
||||||
|
platforms: [
|
||||||
|
.iOS(.v16),
|
||||||
|
],
|
||||||
|
products: [
|
||||||
|
.library(
|
||||||
|
name: "Routeur",
|
||||||
|
targets: ["Routeur"]),
|
||||||
|
],
|
||||||
|
dependencies: [],
|
||||||
|
targets: [
|
||||||
|
.target(
|
||||||
|
name: "Routeur",
|
||||||
|
dependencies: []),
|
||||||
|
.testTarget(
|
||||||
|
name: "RouteurTests",
|
||||||
|
dependencies: ["Routeur"]),
|
||||||
|
]
|
||||||
|
)
|
3
Packages/Routeur/README.md
Normal file
3
Packages/Routeur/README.md
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
# Routeur
|
||||||
|
|
||||||
|
A description of this package.
|
17
Packages/Routeur/Sources/Routeur/Routeur.swift
Normal file
17
Packages/Routeur/Sources/Routeur/Routeur.swift
Normal file
|
@ -0,0 +1,17 @@
|
||||||
|
import Foundation
|
||||||
|
import SwiftUI
|
||||||
|
|
||||||
|
public enum RouteurDestinations: Hashable {
|
||||||
|
case accountDetail(id: String)
|
||||||
|
case statusDetail(id: String)
|
||||||
|
}
|
||||||
|
|
||||||
|
public class RouterPath: ObservableObject {
|
||||||
|
@Published public var path: [RouteurDestinations] = []
|
||||||
|
|
||||||
|
public init() {}
|
||||||
|
|
||||||
|
public func navigate(to: RouteurDestinations) {
|
||||||
|
path.append(to)
|
||||||
|
}
|
||||||
|
}
|
11
Packages/Routeur/Tests/RouteurTests/RouteurTests.swift
Normal file
11
Packages/Routeur/Tests/RouteurTests/RouteurTests.swift
Normal file
|
@ -0,0 +1,11 @@
|
||||||
|
import XCTest
|
||||||
|
@testable import Routeur
|
||||||
|
|
||||||
|
final class RouteurTests: XCTestCase {
|
||||||
|
func testExample() throws {
|
||||||
|
// This is an example of a functional test case.
|
||||||
|
// Use XCTAssert and related functions to verify your tests produce the correct
|
||||||
|
// results.
|
||||||
|
XCTAssertEqual(Routeur().text, "Hello, World!")
|
||||||
|
}
|
||||||
|
}
|
|
@ -16,13 +16,15 @@ let package = Package(
|
||||||
dependencies: [
|
dependencies: [
|
||||||
.package(name: "Network", path: "../Network"),
|
.package(name: "Network", path: "../Network"),
|
||||||
.package(name: "Models", path: "../Models"),
|
.package(name: "Models", path: "../Models"),
|
||||||
|
.package(name: "Routeur", path: "../Routeur"),
|
||||||
],
|
],
|
||||||
targets: [
|
targets: [
|
||||||
.target(
|
.target(
|
||||||
name: "Timeline",
|
name: "Timeline",
|
||||||
dependencies: [
|
dependencies: [
|
||||||
.product(name: "Network", package: "Network"),
|
.product(name: "Network", package: "Network"),
|
||||||
.product(name: "Models", package: "Models")
|
.product(name: "Models", package: "Models"),
|
||||||
|
.product(name: "Routeur", package: "Routeur")
|
||||||
]),
|
]),
|
||||||
.testTarget(
|
.testTarget(
|
||||||
name: "TimelineTests",
|
name: "TimelineTests",
|
||||||
|
|
|
@ -0,0 +1,13 @@
|
||||||
|
import SwiftUI
|
||||||
|
|
||||||
|
public struct StatusDetailView: View {
|
||||||
|
private let statusId: String
|
||||||
|
|
||||||
|
public init(statusId: String) {
|
||||||
|
self.statusId = statusId
|
||||||
|
}
|
||||||
|
|
||||||
|
public var body: some View {
|
||||||
|
Text("Status id \(statusId)")
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,12 +1,34 @@
|
||||||
import SwiftUI
|
import SwiftUI
|
||||||
import Models
|
import Models
|
||||||
|
import Routeur
|
||||||
|
|
||||||
struct StatusRowView: View {
|
struct StatusRowView: View {
|
||||||
|
@EnvironmentObject private var routeurPath: RouterPath
|
||||||
|
|
||||||
let status: Status
|
let status: Status
|
||||||
|
|
||||||
var body: some View {
|
var body: some View {
|
||||||
VStack(alignment: .leading) {
|
VStack(alignment: .leading) {
|
||||||
HStack(alignment: .top) {
|
HStack(alignment: .top) {
|
||||||
|
Button {
|
||||||
|
routeurPath.navigate(to: .accountDetail(id: status.account.id))
|
||||||
|
} label: {
|
||||||
|
accountView
|
||||||
|
}.buttonStyle(.plain)
|
||||||
|
|
||||||
|
Spacer()
|
||||||
|
Text(status.createdAtFormatted)
|
||||||
|
.font(.footnote)
|
||||||
|
.foregroundColor(.gray)
|
||||||
|
}
|
||||||
|
NavigationLink(value: RouteurDestinations.statusDetail(id: status.id)) {
|
||||||
|
Text(try! AttributedString(markdown: status.contentAsMarkdown))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@ViewBuilder
|
||||||
|
private var accountView: some View {
|
||||||
AsyncImage(
|
AsyncImage(
|
||||||
url: status.account.avatar,
|
url: status.account.avatar,
|
||||||
content: { image in
|
content: { image in
|
||||||
|
@ -27,12 +49,5 @@ struct StatusRowView: View {
|
||||||
.font(.footnote)
|
.font(.footnote)
|
||||||
.foregroundColor(.gray)
|
.foregroundColor(.gray)
|
||||||
}
|
}
|
||||||
Spacer()
|
|
||||||
Text(status.createdAtFormatted)
|
|
||||||
.font(.footnote)
|
|
||||||
.foregroundColor(.gray)
|
|
||||||
}
|
|
||||||
Text(try! AttributedString(markdown: status.contentAsMarkdown))
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,6 +3,7 @@ import Network
|
||||||
|
|
||||||
public struct TimelineView: View {
|
public struct TimelineView: View {
|
||||||
@StateObject private var viewModel: TimelineViewModel
|
@StateObject private var viewModel: TimelineViewModel
|
||||||
|
@State private var didAppear = false
|
||||||
|
|
||||||
public init(client: Client) {
|
public init(client: Client) {
|
||||||
_viewModel = StateObject(wrappedValue: TimelineViewModel(client: client))
|
_viewModel = StateObject(wrappedValue: TimelineViewModel(client: client))
|
||||||
|
@ -36,7 +37,10 @@ public struct TimelineView: View {
|
||||||
.navigationTitle("Public Timeline: \(viewModel.serverName)")
|
.navigationTitle("Public Timeline: \(viewModel.serverName)")
|
||||||
.navigationBarTitleDisplayMode(.inline)
|
.navigationBarTitleDisplayMode(.inline)
|
||||||
.task {
|
.task {
|
||||||
|
if !didAppear {
|
||||||
await viewModel.refreshTimeline()
|
await viewModel.refreshTimeline()
|
||||||
|
didAppear = true
|
||||||
|
}
|
||||||
}
|
}
|
||||||
.refreshable {
|
.refreshable {
|
||||||
await viewModel.refreshTimeline()
|
await viewModel.refreshTimeline()
|
||||||
|
|
Loading…
Reference in a new issue