mirror of
https://github.com/Dimillian/IceCubesApp.git
synced 2025-02-18 02:35:15 +00:00
Basic splitView on iPad + Disable macOS for now
This commit is contained in:
parent
aada2e2cd3
commit
73f3fef738
5 changed files with 71 additions and 29 deletions
|
@ -446,7 +446,9 @@
|
||||||
PRODUCT_BUNDLE_IDENTIFIER = com.thomasricouard.IceCubesApp;
|
PRODUCT_BUNDLE_IDENTIFIER = com.thomasricouard.IceCubesApp;
|
||||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||||
SDKROOT = auto;
|
SDKROOT = auto;
|
||||||
SUPPORTED_PLATFORMS = "iphoneos iphonesimulator macosx";
|
SUPPORTED_PLATFORMS = "iphoneos iphonesimulator";
|
||||||
|
SUPPORTS_MACCATALYST = NO;
|
||||||
|
SUPPORTS_MAC_DESIGNED_FOR_IPHONE_IPAD = NO;
|
||||||
SWIFT_EMIT_LOC_STRINGS = YES;
|
SWIFT_EMIT_LOC_STRINGS = YES;
|
||||||
SWIFT_VERSION = 5.0;
|
SWIFT_VERSION = 5.0;
|
||||||
TARGETED_DEVICE_FAMILY = "1,2";
|
TARGETED_DEVICE_FAMILY = "1,2";
|
||||||
|
@ -492,7 +494,9 @@
|
||||||
PRODUCT_BUNDLE_IDENTIFIER = com.thomasricouard.IceCubesApp;
|
PRODUCT_BUNDLE_IDENTIFIER = com.thomasricouard.IceCubesApp;
|
||||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||||
SDKROOT = auto;
|
SDKROOT = auto;
|
||||||
SUPPORTED_PLATFORMS = "iphoneos iphonesimulator macosx";
|
SUPPORTED_PLATFORMS = "iphoneos iphonesimulator";
|
||||||
|
SUPPORTS_MACCATALYST = NO;
|
||||||
|
SUPPORTS_MAC_DESIGNED_FOR_IPHONE_IPAD = NO;
|
||||||
SWIFT_EMIT_LOC_STRINGS = YES;
|
SWIFT_EMIT_LOC_STRINGS = YES;
|
||||||
SWIFT_VERSION = 5.0;
|
SWIFT_VERSION = 5.0;
|
||||||
TARGETED_DEVICE_FAMILY = "1,2";
|
TARGETED_DEVICE_FAMILY = "1,2";
|
||||||
|
|
|
@ -17,33 +17,16 @@ struct IceCubesApp: App {
|
||||||
@StateObject private var quickLook = QuickLook()
|
@StateObject private var quickLook = QuickLook()
|
||||||
@StateObject private var theme = Theme()
|
@StateObject private var theme = Theme()
|
||||||
|
|
||||||
@State private var selectedTab: Tab = .timeline
|
@State private var selectedTab: Tab? = .timeline
|
||||||
@State private var popToRootTab: Tab = .other
|
@State private var popToRootTab: Tab = .other
|
||||||
|
|
||||||
|
private var availableTabs: [Tab] {
|
||||||
|
appAccountsManager.currentClient.isAuth ? Tab.loggedInTabs() : Tab.loggedOutTab()
|
||||||
|
}
|
||||||
|
|
||||||
var body: some Scene {
|
var body: some Scene {
|
||||||
WindowGroup {
|
WindowGroup {
|
||||||
TabView(selection: .init(get: {
|
appView
|
||||||
selectedTab
|
|
||||||
}, set: { newTab in
|
|
||||||
if newTab == selectedTab {
|
|
||||||
/// Stupid hack to trigger onChange binding in tab views.
|
|
||||||
popToRootTab = .other
|
|
||||||
DispatchQueue.main.asyncAfter(deadline: .now() + 0.01) {
|
|
||||||
popToRootTab = selectedTab
|
|
||||||
}
|
|
||||||
}
|
|
||||||
selectedTab = newTab
|
|
||||||
})) {
|
|
||||||
ForEach(appAccountsManager.currentClient.isAuth ? Tab.loggedInTabs() : Tab.loggedOutTab()) { tab in
|
|
||||||
tab.makeContentView(popToRootTab: $popToRootTab)
|
|
||||||
.tabItem {
|
|
||||||
tab.label
|
|
||||||
}
|
|
||||||
.tag(tab)
|
|
||||||
.badge(tab == .notifications ? watcher.unreadNotificationsCount : 0)
|
|
||||||
.toolbarBackground(theme.primaryBackgroundColor.opacity(0.50), for: .tabBar)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
.tint(theme.tintColor)
|
.tint(theme.tintColor)
|
||||||
.onAppear {
|
.onAppear {
|
||||||
setNewClientsInEnv(client: appAccountsManager.currentClient)
|
setNewClientsInEnv(client: appAccountsManager.currentClient)
|
||||||
|
@ -73,6 +56,56 @@ struct IceCubesApp: App {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ViewBuilder
|
||||||
|
private var appView: some View {
|
||||||
|
if UIDevice.current.userInterfaceIdiom == .pad || UIDevice.current.userInterfaceIdiom == .mac {
|
||||||
|
splitView
|
||||||
|
} else {
|
||||||
|
tabBarView
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private var tabBarView: some View {
|
||||||
|
TabView(selection: .init(get: {
|
||||||
|
selectedTab
|
||||||
|
}, set: { newTab in
|
||||||
|
if newTab == selectedTab {
|
||||||
|
/// Stupid hack to trigger onChange binding in tab views.
|
||||||
|
popToRootTab = .other
|
||||||
|
DispatchQueue.main.asyncAfter(deadline: .now() + 0.01) {
|
||||||
|
if let selectedTab {
|
||||||
|
popToRootTab = selectedTab
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
selectedTab = newTab
|
||||||
|
})) {
|
||||||
|
ForEach(availableTabs) { tab in
|
||||||
|
tab.makeContentView(popToRootTab: $popToRootTab)
|
||||||
|
.tabItem {
|
||||||
|
tab.label
|
||||||
|
}
|
||||||
|
.tag(tab)
|
||||||
|
.badge(tab == .notifications ? watcher.unreadNotificationsCount : 0)
|
||||||
|
.toolbarBackground(theme.primaryBackgroundColor.opacity(0.50), for: .tabBar)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private var splitView: some View {
|
||||||
|
NavigationSplitView {
|
||||||
|
List(availableTabs, selection: $selectedTab) { tab in
|
||||||
|
NavigationLink(value: tab) {
|
||||||
|
tab.label
|
||||||
|
}
|
||||||
|
}
|
||||||
|
.scrollContentBackground(.hidden)
|
||||||
|
.background(theme.secondaryBackgroundColor)
|
||||||
|
} detail: {
|
||||||
|
selectedTab?.makeContentView(popToRootTab: $popToRootTab)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private func setNewClientsInEnv(client: Client) {
|
private func setNewClientsInEnv(client: Client) {
|
||||||
currentAccount.setClient(client: client)
|
currentAccount.setClient(client: client)
|
||||||
currentInstance.setClient(client: client)
|
currentInstance.setClient(client: client)
|
||||||
|
|
|
@ -18,7 +18,7 @@ struct SettingsTabs: View {
|
||||||
@State private var isThemeSelectorPresented = false
|
@State private var isThemeSelectorPresented = false
|
||||||
|
|
||||||
var body: some View {
|
var body: some View {
|
||||||
NavigationStack {
|
NavigationStack(path: $routeurPath.path) {
|
||||||
Form {
|
Form {
|
||||||
appSection
|
appSection
|
||||||
accountsSection
|
accountsSection
|
||||||
|
|
|
@ -4,7 +4,7 @@ import Account
|
||||||
import Explore
|
import Explore
|
||||||
import SwiftUI
|
import SwiftUI
|
||||||
|
|
||||||
enum Tab: Int, Identifiable {
|
enum Tab: Int, Identifiable, Hashable {
|
||||||
case timeline, notifications, explore, account, settings, other
|
case timeline, notifications, explore, account, settings, other
|
||||||
|
|
||||||
var id: Int {
|
var id: Int {
|
||||||
|
|
|
@ -104,7 +104,9 @@ public struct StatusMediaPreviewView: View {
|
||||||
private func makeFeaturedImagePreview(attachement: MediaAttachement) -> some View {
|
private func makeFeaturedImagePreview(attachement: MediaAttachement) -> some View {
|
||||||
switch attachement.supportedType {
|
switch attachement.supportedType {
|
||||||
case .image:
|
case .image:
|
||||||
if let size = size(for: attachement) {
|
if let size = size(for: attachement),
|
||||||
|
UIDevice.current.userInterfaceIdiom != .pad,
|
||||||
|
UIDevice.current.userInterfaceIdiom != .mac {
|
||||||
let avatarColumnWidth = theme.avatarPosition == .leading ? AvatarView.Size.status.size.width + .statusColumnsSpacing : 0
|
let avatarColumnWidth = theme.avatarPosition == .leading ? AvatarView.Size.status.size.width + .statusColumnsSpacing : 0
|
||||||
let availableWidth = UIScreen.main.bounds.width - (.layoutPadding * 2) - avatarColumnWidth
|
let availableWidth = UIScreen.main.bounds.width - (.layoutPadding * 2) - avatarColumnWidth
|
||||||
let newSize = imageSize(from: size,
|
let newSize = imageSize(from: size,
|
||||||
|
@ -142,12 +144,15 @@ public struct StatusMediaPreviewView: View {
|
||||||
image
|
image
|
||||||
.resizable()
|
.resizable()
|
||||||
.aspectRatio(contentMode: .fill)
|
.aspectRatio(contentMode: .fill)
|
||||||
|
.frame(maxHeight: imageMaxHeight)
|
||||||
|
.frame(maxWidth: imageMaxHeight)
|
||||||
.cornerRadius(4)
|
.cornerRadius(4)
|
||||||
},
|
},
|
||||||
placeholder: {
|
placeholder: {
|
||||||
RoundedRectangle(cornerRadius: 4)
|
RoundedRectangle(cornerRadius: 4)
|
||||||
.fill(Color.gray)
|
.fill(Color.gray)
|
||||||
.frame(height: imageMaxHeight)
|
.frame(maxHeight: imageMaxHeight)
|
||||||
|
.frame(maxWidth: imageMaxHeight)
|
||||||
.shimmering()
|
.shimmering()
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue