From 843f346f85d24c08934b40305f653742b64ff7d6 Mon Sep 17 00:00:00 2001 From: WindowsMEMZ Date: Sun, 14 Apr 2024 17:22:30 +0800 Subject: [PATCH] feat: Large suggestion view, fix: storage may crash --- DarockBili.xcodeproj/project.pbxproj | 36 ++--- Localizable.xcstrings | 25 ++-- MeowBili/Extension/UIExt.swift | 43 ++++++ MeowBili/InMain/MainView.swift | 207 +++++++++++++++------------ MeowBili/Others/SettingsView.swift | 190 ++++++++++++------------ 5 files changed, 294 insertions(+), 207 deletions(-) diff --git a/DarockBili.xcodeproj/project.pbxproj b/DarockBili.xcodeproj/project.pbxproj index 2cd2edf38..abfcb1a44 100644 --- a/DarockBili.xcodeproj/project.pbxproj +++ b/DarockBili.xcodeproj/project.pbxproj @@ -1619,7 +1619,7 @@ isa = XCBuildConfiguration; buildSettings = { CODE_SIGN_STYLE = Automatic; - CURRENT_PROJECT_VERSION = 1108; + CURRENT_PROJECT_VERSION = 1130; DEVELOPMENT_TEAM = B57D8PP775; GENERATE_INFOPLIST_FILE = YES; INFOPLIST_FILE = SafariExtension/Info.plist; @@ -1650,7 +1650,7 @@ isa = XCBuildConfiguration; buildSettings = { CODE_SIGN_STYLE = Automatic; - CURRENT_PROJECT_VERSION = 1108; + CURRENT_PROJECT_VERSION = 1130; DEVELOPMENT_TEAM = B57D8PP775; GENERATE_INFOPLIST_FILE = YES; INFOPLIST_FILE = SafariExtension/Info.plist; @@ -1747,7 +1747,7 @@ CLANG_ENABLE_MODULES = YES; CODE_SIGN_ENTITLEMENTS = MeowBili/MeowBiliAlternative.entitlements; CODE_SIGN_STYLE = Automatic; - CURRENT_PROJECT_VERSION = 1108; + CURRENT_PROJECT_VERSION = 1130; DEVELOPMENT_ASSET_PATHS = "\"MeowBili/Preview Content\""; DEVELOPMENT_TEAM = B38QUJMY47; ENABLE_PREVIEWS = YES; @@ -1792,7 +1792,7 @@ ASSETCATALOG_COMPILER_APPICON_NAME = AppIconWatch; ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor; CODE_SIGN_STYLE = Automatic; - CURRENT_PROJECT_VERSION = 1108; + CURRENT_PROJECT_VERSION = 1130; DEVELOPMENT_ASSET_PATHS = "\"MeowBili/Preview\\ Content\""; DEVELOPMENT_TEAM = B38QUJMY47; ENABLE_PREVIEWS = YES; @@ -1832,7 +1832,7 @@ ASSETCATALOG_COMPILER_INCLUDE_ALL_APPICON_ASSETS = NO; CODE_SIGN_ENTITLEMENTS = "MeowBili/MeowBili Vision App.entitlements"; CODE_SIGN_STYLE = Automatic; - CURRENT_PROJECT_VERSION = 1108; + CURRENT_PROJECT_VERSION = 1130; DEVELOPMENT_ASSET_PATHS = "\"MeowBili/Preview Content\""; DEVELOPMENT_TEAM = B57D8PP775; ENABLE_PREVIEWS = YES; @@ -1868,7 +1868,7 @@ CODE_SIGN_ENTITLEMENTS = "MeowBili/MeowBili Mac App.entitlements"; CODE_SIGN_STYLE = Automatic; COMBINE_HIDPI_IMAGES = YES; - CURRENT_PROJECT_VERSION = 1108; + CURRENT_PROJECT_VERSION = 1130; DEVELOPMENT_ASSET_PATHS = "\"MeowBili/Preview Content\""; DEVELOPMENT_TEAM = B57D8PP775; ENABLE_HARDENED_RUNTIME = YES; @@ -1897,7 +1897,7 @@ isa = XCBuildConfiguration; buildSettings = { CODE_SIGN_STYLE = Automatic; - CURRENT_PROJECT_VERSION = 1108; + CURRENT_PROJECT_VERSION = 1130; DEVELOPMENT_TEAM = B57D8PP775; GENERATE_INFOPLIST_FILE = YES; IPHONEOS_DEPLOYMENT_TARGET = 16.0; @@ -1921,7 +1921,7 @@ isa = XCBuildConfiguration; buildSettings = { CODE_SIGN_STYLE = Automatic; - CURRENT_PROJECT_VERSION = 1108; + CURRENT_PROJECT_VERSION = 1130; DEVELOPMENT_TEAM = B38QUJMY47; GENERATE_INFOPLIST_FILE = YES; INFOPLIST_FILE = SafariExtension/Info.plist; @@ -1988,7 +1988,7 @@ ASSETCATALOG_COMPILER_INCLUDE_ALL_APPICON_ASSETS = NO; CODE_SIGN_ENTITLEMENTS = "MeowBili/MeowBili Vision App.entitlements"; CODE_SIGN_STYLE = Automatic; - CURRENT_PROJECT_VERSION = 1108; + CURRENT_PROJECT_VERSION = 1130; DEVELOPMENT_ASSET_PATHS = "\"MeowBili/Preview Content\""; DEVELOPMENT_TEAM = B57D8PP775; ENABLE_PREVIEWS = YES; @@ -2023,7 +2023,7 @@ ASSETCATALOG_COMPILER_INCLUDE_ALL_APPICON_ASSETS = NO; CODE_SIGN_ENTITLEMENTS = "MeowBili/MeowBili Vision App.entitlements"; CODE_SIGN_STYLE = Automatic; - CURRENT_PROJECT_VERSION = 1108; + CURRENT_PROJECT_VERSION = 1130; DEVELOPMENT_ASSET_PATHS = "\"MeowBili/Preview Content\""; DEVELOPMENT_TEAM = B57D8PP775; ENABLE_PREVIEWS = YES; @@ -2060,7 +2060,7 @@ CLANG_ENABLE_MODULES = YES; CODE_SIGN_ENTITLEMENTS = MeowBili/MeowBili.entitlements; CODE_SIGN_STYLE = Automatic; - CURRENT_PROJECT_VERSION = 1108; + CURRENT_PROJECT_VERSION = 1130; DEVELOPMENT_ASSET_PATHS = "\"MeowBili/Preview Content\""; DEVELOPMENT_TEAM = B57D8PP775; ENABLE_PREVIEWS = YES; @@ -2107,7 +2107,7 @@ CLANG_ENABLE_MODULES = YES; CODE_SIGN_ENTITLEMENTS = MeowBili/MeowBili.entitlements; CODE_SIGN_STYLE = Automatic; - CURRENT_PROJECT_VERSION = 1108; + CURRENT_PROJECT_VERSION = 1130; DEVELOPMENT_ASSET_PATHS = "\"MeowBili/Preview Content\""; DEVELOPMENT_TEAM = B57D8PP775; ENABLE_PREVIEWS = YES; @@ -2152,7 +2152,7 @@ ASSETCATALOG_COMPILER_APPICON_NAME = AppIconWatch; ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor; CODE_SIGN_STYLE = Automatic; - CURRENT_PROJECT_VERSION = 1108; + CURRENT_PROJECT_VERSION = 1130; DEVELOPMENT_ASSET_PATHS = "\"MeowBili/Preview\\ Content\""; DEVELOPMENT_TEAM = B57D8PP775; ENABLE_PREVIEWS = YES; @@ -2188,7 +2188,7 @@ ASSETCATALOG_COMPILER_APPICON_NAME = AppIconWatch; ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor; CODE_SIGN_STYLE = Automatic; - CURRENT_PROJECT_VERSION = 1108; + CURRENT_PROJECT_VERSION = 1130; DEVELOPMENT_ASSET_PATHS = "\"MeowBili/Preview\\ Content\""; DEVELOPMENT_TEAM = B57D8PP775; ENABLE_PREVIEWS = YES; @@ -2228,7 +2228,7 @@ CODE_SIGN_ENTITLEMENTS = "MeowBili/MeowBili Mac App.entitlements"; CODE_SIGN_STYLE = Automatic; COMBINE_HIDPI_IMAGES = YES; - CURRENT_PROJECT_VERSION = 1108; + CURRENT_PROJECT_VERSION = 1130; DEVELOPMENT_ASSET_PATHS = "\"MeowBili/Preview Content\""; DEVELOPMENT_TEAM = B57D8PP775; ENABLE_HARDENED_RUNTIME = YES; @@ -2261,7 +2261,7 @@ CODE_SIGN_ENTITLEMENTS = "MeowBili/MeowBili Mac App.entitlements"; CODE_SIGN_STYLE = Automatic; COMBINE_HIDPI_IMAGES = YES; - CURRENT_PROJECT_VERSION = 1108; + CURRENT_PROJECT_VERSION = 1130; DEVELOPMENT_ASSET_PATHS = "\"MeowBili/Preview Content\""; DEVELOPMENT_TEAM = B57D8PP775; ENABLE_HARDENED_RUNTIME = YES; @@ -2290,7 +2290,7 @@ isa = XCBuildConfiguration; buildSettings = { CODE_SIGN_STYLE = Automatic; - CURRENT_PROJECT_VERSION = 1108; + CURRENT_PROJECT_VERSION = 1130; DEVELOPMENT_TEAM = B57D8PP775; GENERATE_INFOPLIST_FILE = YES; IPHONEOS_DEPLOYMENT_TARGET = 16.0; @@ -2313,7 +2313,7 @@ isa = XCBuildConfiguration; buildSettings = { CODE_SIGN_STYLE = Automatic; - CURRENT_PROJECT_VERSION = 1108; + CURRENT_PROJECT_VERSION = 1130; DEVELOPMENT_TEAM = B57D8PP775; GENERATE_INFOPLIST_FILE = YES; IPHONEOS_DEPLOYMENT_TARGET = 16.0; diff --git a/Localizable.xcstrings b/Localizable.xcstrings index 6806b51ff..742e3c0c1 100644 --- a/Localizable.xcstrings +++ b/Localizable.xcstrings @@ -8255,6 +8255,9 @@ }, "分析与改进" : { + }, + "列表视图" : { + }, "加群248036605查看群公告以申请解封" : { @@ -8599,6 +8602,9 @@ } } } + }, + "大图视图" : { + }, "如不希望显示来自 Darock 的推荐,可前往%@关闭" : { @@ -8664,15 +8670,8 @@ } } }, - "已使用 %@ MB/%@ GB" : { - "localizations" : { - "zh-Hans" : { - "stringUnit" : { - "state" : "new", - "value" : "已使用 %1$@ MB/%2$@ GB" - } - } - } + "已使用 %@ MB" : { + }, "已选择的图片" : { "localizations" : { @@ -8885,6 +8884,12 @@ } } } + }, + "推荐视图" : { + + }, + "推荐视图样式" : { + }, "搜索" : { @@ -9261,7 +9266,7 @@ } } }, - "缓存" : { + "缓存数据" : { }, "编辑" : { diff --git a/MeowBili/Extension/UIExt.swift b/MeowBili/Extension/UIExt.swift index c42b63fa8..25c5dd10d 100644 --- a/MeowBili/Extension/UIExt.swift +++ b/MeowBili/Extension/UIExt.swift @@ -541,6 +541,49 @@ struct SegmentedPicker: View { } #endif +@ViewBuilder +func LargeVideoCard(_ videoDetails: [String: String]) -> some View { + #if os(watchOS) + NavigationLink(destination: { VideoDetailView(videoDetails: videoDetails) }, label: { + VStack { + WebImage(url: URL(string: videoDetails["Pic"]! + "@400w")!, options: [.progressiveLoad, .scaleDownLargeImages]) + .placeholder { + RoundedRectangle(cornerRadius: 7) + .frame(width: WKInterfaceDevice.current().screenBounds.width - 20, height: 80) + .foregroundColor(Color(hex: 0x3D3D3D)) + .redacted(reason: .placeholder) + } + .resizable() + .cornerRadius(7) + .scaledToFit() + .frame(width: WKInterfaceDevice.current().screenBounds.width - 20) + HStack { + Text(videoDetails["Title"]!) + .font(.system(size: 14, weight: .bold)) + .lineLimit(2) + .multilineTextAlignment(.leading) + Spacer() + } + HStack { + Image(systemName: "play.circle") + Text(videoDetails["View"]!.shorter()) + .offset(x: -3) + Image(systemName: "person") + Text(videoDetails["UP"]!) + .offset(x: -3) + Spacer() + } + .lineLimit(1) + .font(.system(size: 11)) + .foregroundColor(.gray) + } + }) + .buttonBorderShape(.roundedRectangle(radius: 14)) + #else + VideoCard(videoDetails) + #endif +} + // swiftlint:disable unused_closure_parameter #if !os(visionOS) extension Indicator where T == ProgressView { diff --git a/MeowBili/InMain/MainView.swift b/MeowBili/InMain/MainView.swift index 607d2fb93..2a3e549f4 100644 --- a/MeowBili/InMain/MainView.swift +++ b/MeowBili/InMain/MainView.swift @@ -168,6 +168,7 @@ struct MainView: View { @AppStorage("IsShowNetworkFixing") var isShowNetworkFixing = true @AppStorage("IsShowVideoSuggestionsFromDarock") var isShowVideoSuggestionsFromDarock = true @AppStorage("IsTipDarockSuggestions") var isTipDarockSuggestions = true + @AppStorage("IsLargeSuggestionStyle") var isLargeSuggestionStyle = false @State var videos = [[String: String]]() @State var notice = "" @State var isNetworkFixPresented = false @@ -182,110 +183,122 @@ struct MainView: View { @State var darockSuggestions = [[String: String]]() var body: some View { ZStack { - List { - Section { - if debug { - Button(action: { - tipWithText("Test", symbol: "hammer.fill") - }, label: { - Text("Home.debug") - }) - #if os(watchOS) - NavigationLink(destination: { WatchUIDebugView() }, label: { - Text("UIDebug") - }) - #endif - } - if notice != "" { - NavigationLink(destination: { NoticeView() }, label: { - Text(notice) - .bold() - }) - } - if newMajorVer != "" && newBuildVer != "" { - let nowMajorVer = Bundle.main.infoDictionary?["CFBundleShortVersionString"] as! String - let nowBuildVer = Bundle.main.infoDictionary?["CFBundleVersion"] as! String - if (nowMajorVer < newMajorVer || Int(nowBuildVer) ?? 1 < Int(newBuildVer) ?? 1) && updateTipIgnoreVersion != "\(newMajorVer)\(newBuildVer)" { - VStack { - Text("Home.update.\(newMajorVer).\(newBuildVer)") - if isShowDisableNewVerTip { - Text("Home.update.skip") - .font(.system(size: 12)) - .foregroundColor(.gray) + LargeFixedForm { + List { + Section { + if debug { + Button(action: { + tipWithText("Test", symbol: "hammer.fill") + }, label: { + Text("Home.debug") + }) + #if os(watchOS) + NavigationLink(destination: { WatchUIDebugView() }, label: { + Text("UIDebug") + }) + #endif + } + if notice != "" { + NavigationLink(destination: { NoticeView() }, label: { + Text(notice) + .bold() + }) + } + if newMajorVer != "" && newBuildVer != "" { + let nowMajorVer = Bundle.main.infoDictionary?["CFBundleShortVersionString"] as! String + let nowBuildVer = Bundle.main.infoDictionary?["CFBundleVersion"] as! String + if (nowMajorVer < newMajorVer || Int(nowBuildVer) ?? 1 < Int(newBuildVer) ?? 1) && updateTipIgnoreVersion != "\(newMajorVer)\(newBuildVer)" { + VStack { + Text("Home.update.\(newMajorVer).\(newBuildVer)") + if isShowDisableNewVerTip { + Text("Home.update.skip") + .font(.system(size: 12)) + .foregroundColor(.gray) + } } - } - .onTapGesture { - if isShowDisableNewVerTip { - updateTipIgnoreVersion = "\(newMajorVer)\(newBuildVer)" - } else { - isShowDisableNewVerTip = true + .onTapGesture { + if isShowDisableNewVerTip { + updateTipIgnoreVersion = "\(newMajorVer)\(newBuildVer)" + } else { + isShowDisableNewVerTip = true + } } } } } - } - #if os(watchOS) - if isShowSearchButton { - Section { - NavigationLink(destination: { SearchMainView() }, label: { - HStack { - Image(systemName: "magnifyingglass") - Text("Home.search") - } - .foregroundColor(.gray) - }) - } - } - #endif - if isShowVideoSuggestionsFromDarock && !darockSuggestions.isEmpty { - Section { - ForEach(0.. some View) -> some View { + #if os(watchOS) + if isLargeSuggestionStyle { + Form { + content() + } + .scrollIndicators(.never) + } else { + content() + } + #else + content() + #endif + } } enum FestivalType { diff --git a/MeowBili/Others/SettingsView.swift b/MeowBili/Others/SettingsView.swift index 974d4f860..83a9e9a02 100644 --- a/MeowBili/Others/SettingsView.swift +++ b/MeowBili/Others/SettingsView.swift @@ -33,6 +33,7 @@ struct SettingsView: View { @AppStorage("DedeUserID__ckMd5") var dedeUserID__ckMd5 = "" @AppStorage("SESSDATA") var sessdata = "" @AppStorage("bili_jct") var biliJct = "" + @AppStorage("IsLargeSuggestionStyle") var isLargeSuggestionStyle = false @State var isLogoutAlertPresented = false var body: some View { List { @@ -221,6 +222,18 @@ struct SettingsView: View { Text("Settings.player") } }) + NavigationLink(destination: { SuggestionViewSettingsView().navigationTitle("推荐视图") }, label: { + HStack { + ZStack { + Color.blue + .frame(width: 20, height: 20) + .clipShape(Circle()) + Image(systemName: isLargeSuggestionStyle ? "text.below.photo" : "rectangle.grid.1x2") + .font(.system(size: isLargeSuggestionStyle ? 10 : 12)) + } + Text("推荐视图") + } + }) NavigationLink(destination: { NetworkSettingsView().navigationTitle("Settings.internet") }, label: { HStack { ZStack { @@ -439,6 +452,19 @@ struct PlayerSettingsView: View { } } +struct SuggestionViewSettingsView: View { + @AppStorage("IsLargeSuggestionStyle") var isLargeSuggestionStyle = false + var body: some View { + List { + Picker("推荐视图样式", selection: $isLargeSuggestionStyle) { + Label("列表视图", systemImage: "rectangle.grid.1x2").tag(false) + Label("大图视图", systemImage: "text.below.photo").tag(true) + } + .pickerStyle(.inline) + } + } +} + struct NetworkSettingsView: View { @AppStorage("IsTipDarockSuggestions") var isTipDarockSuggestions = true @AppStorage("IsShowNetworkFixing") var isShowNetworkFixing = true @@ -588,7 +614,6 @@ struct StorageSettingsView: View { @State var docSize: UInt64 = 0 @State var tmpSize: UInt64 = 0 @State var bundleSize: UInt64 = 0 - @State var sizeAvailable: UInt64 = 0 @State var isClearingCache = false @State var videoMetadatas = [[String: String]]() @State var vRootPath = "" @@ -599,7 +624,7 @@ struct StorageSettingsView: View { Section { VStack { HStack { - Text("已使用 \(bytesToMegabytes(bytes: docSize + tmpSize + bundleSize) ~ 2) MB/\((bytesToMegabytes(bytes: sizeAvailable + docSize + tmpSize + bundleSize) / 1024) ~ 1) GB") + Text("已使用 \(bytesToMegabytes(bytes: docSize + tmpSize + bundleSize) ~ 2) MB") .font(.system(size: 13)) .foregroundColor(.gray) Spacer() @@ -611,10 +636,8 @@ struct StorageSettingsView: View { .foregroundStyle(by: .value("", "Purple")) BarMark(x: .value("", tmpSize)) .foregroundStyle(by: .value("", "Primary")) - BarMark(x: .value("", sizeAvailable)) - .foregroundStyle(by: .value("", "Secondary")) } - .chartForegroundStyleScale(["Gray": .gray, "Purple": .purple, "Primary": .primary, "Secondary": .secondary]) + .chartForegroundStyleScale(["Gray": .gray, "Purple": .purple, "Primary": .primary, "Secondary": Color(hex: 0x333333)]) .chartXAxis(.hidden) .chartLegend(.hidden) .cornerRadius(2) @@ -643,7 +666,7 @@ struct StorageSettingsView: View { Circle() .fill(Color.primary) .frame(width: 10, height: 10) - Text("缓存") + Text("缓存数据") .font(.system(size: 14)) .foregroundColor(.gray) Spacer() @@ -701,74 +724,6 @@ struct StorageSettingsView: View { } } Section { - NavigationLink(destination: { - List { - Section { - HStack { - ZStack { - Color.gray - .frame(width: 20, height: 20) - .clipShape(Circle()) - Image(systemName: "ellipsis.circle") - .font(.system(size: 12)) - } - Spacer() - .frame(width: 5) - VStack { - HStack { - Text("缓存") - Spacer() - } - HStack { - Text("\(bytesToMegabytes(bytes: tmpSize) ~ 2) MB") - .font(.system(size: 15)) - .foregroundColor(.gray) - Spacer() - } - } - } - } - Section { - if !isClearingCache { - Button(action: { - DispatchQueue(label: "com.darock.DarockBili.storage-clear-cache", qos: .userInitiated).async { - isClearingCache = true - try? FileManager.default.removeItem(atPath: NSTemporaryDirectory()) - isClearingCache = false - } - }, label: { - Text("清除缓存") - }) - } else { - ProgressView() - } - } - } - }, label: { - HStack { - ZStack { - Color.gray - .frame(width: 20, height: 20) - .clipShape(Circle()) - Image(systemName: "ellipsis.circle") - .font(.system(size: 12)) - } - Spacer() - .frame(width: 5) - VStack { - HStack { - Text("缓存") - Spacer() - } - HStack { - Text("\(bytesToMegabytes(bytes: tmpSize) ~ 2) MB") - .font(.system(size: 15)) - .foregroundColor(.gray) - Spacer() - } - } - } - }) NavigationLink(destination: { List { Section { @@ -822,6 +777,76 @@ struct StorageSettingsView: View { } } }) + if bytesToMegabytes(bytes: tmpSize) > 0.2 { + NavigationLink(destination: { + List { + Section { + HStack { + ZStack { + Color.gray + .frame(width: 20, height: 20) + .clipShape(Circle()) + Image(systemName: "ellipsis.circle") + .font(.system(size: 12)) + } + Spacer() + .frame(width: 5) + VStack { + HStack { + Text("缓存数据") + Spacer() + } + HStack { + Text("\(bytesToMegabytes(bytes: tmpSize) ~ 2) MB") + .font(.system(size: 15)) + .foregroundColor(.gray) + Spacer() + } + } + } + } + Section { + if !isClearingCache { + Button(action: { + DispatchQueue(label: "com.darock.DarockBili.storage-clear-cache", qos: .userInitiated).async { + isClearingCache = true + try? FileManager.default.removeItem(atPath: NSTemporaryDirectory()) + isClearingCache = false + } + }, label: { + Text("清除缓存") + }) + } else { + ProgressView() + } + } + } + }, label: { + HStack { + ZStack { + Color.gray + .frame(width: 20, height: 20) + .clipShape(Circle()) + Image(systemName: "ellipsis.circle") + .font(.system(size: 12)) + } + Spacer() + .frame(width: 5) + VStack { + HStack { + Text("缓存数据") + Spacer() + } + HStack { + Text("\(bytesToMegabytes(bytes: tmpSize) ~ 2) MB") + .font(.system(size: 15)) + .foregroundColor(.gray) + Spacer() + } + } + } + }) + } } } else { HStack { @@ -840,7 +865,6 @@ struct StorageSettingsView: View { docSize = folderSize(atPath: NSHomeDirectory() + "/Documents") ?? 0 tmpSize = folderSize(atPath: NSTemporaryDirectory()) ?? 0 bundleSize = folderSize(atPath: Bundle.main.bundlePath) ?? 0 - sizeAvailable = deviceRemainingFreeSpaceInBytes() ?? 32 * 1024 * 1024 * 1024 // Video sizes vRootPath = String(AppFileManager(path: "dlds").GetPath("").path) let files = AppFileManager(path: "dlds").GetRoot() ?? [[String: String]]() @@ -870,7 +894,7 @@ struct StorageSettingsView: View { } } } - videoMetadatas.sort { Int($0["Size"] ?? "0")! < Int($1["Size"] ?? "0")! } + videoMetadatas.sort { UInt64($0["Size"] ?? "0")! > UInt64($1["Size"] ?? "0")! } isLoading = false } @@ -904,20 +928,6 @@ struct StorageSettingsView: View { let megabytes = Double(bytes) / (1024 * 1024) return megabytes } - func deviceRemainingFreeSpaceInBytes() -> UInt64? { - let fileURL = URL(fileURLWithPath: NSHomeDirectory() as String) - do { - let values = try fileURL.resourceValues(forKeys: [.volumeAvailableCapacityKey]) - if let capacity = values.volumeAvailableCapacity { - return UInt64(capacity) - } else { - print("Capacity is unavailable") - } - } catch { - print("Error retrieving capacity: \(error.localizedDescription)") - } - return nil - } } struct SleepTimeView: View {