Skip to content
This repository has been archived by the owner on Dec 28, 2024. It is now read-only.

Commit

Permalink
Repo // Clang-format.
Browse files Browse the repository at this point in the history
  • Loading branch information
ShikiSuen committed Dec 28, 2024
1 parent 45cfef0 commit e10f111
Show file tree
Hide file tree
Showing 25 changed files with 252 additions and 240 deletions.
1 change: 0 additions & 1 deletion Common/UserDefaultKeys.swift
Original file line number Diff line number Diff line change
@@ -1 +0,0 @@

6 changes: 4 additions & 2 deletions Common/View Modifier/DismissableSheet.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import SwiftUI

struct DismissableSheet<Item>: ViewModifier where Item: Identifiable {
@Binding var sheet: Item?

var title = "sys.done"
var todoOnDismiss: () -> Void

Expand Down Expand Up @@ -46,6 +47,7 @@ extension View {

struct DismissableBoolSheet: ViewModifier {
@Binding var isSheetShow: Bool

var title: String = "sys.done"
var todoOnDismiss: () -> Void

Expand Down Expand Up @@ -129,9 +131,9 @@ struct SheetCaller<D: View, L: View>: View {

@State private var sansFinishButton: Bool

@State private var isSheetShown = false

@ViewBuilder private let destination: () -> D

@ViewBuilder private let label: () -> L

@State private var isSheetShown = false
}
10 changes: 5 additions & 5 deletions Features/CharacterInventory/CharacterInventoryView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -164,15 +164,15 @@ struct CharacterInventoryView: View {
case star4 = "app.characters.filter.4star"
}

private let data: MiHoYoAPI.CharacterInventory
private let isMiyousheUID: Bool

@State private var allAvatarListDisplayType: AllAvatarListDisplayType = .all
@State private var expanded: Bool = false
@State private var containerSize: CGSize = .init(width: 320, height: 320)
@StateObject private var orientation = DeviceOrientation()
@Environment(\.dismiss) private var dismiss

private let data: MiHoYoAPI.CharacterInventory
private let isMiyousheUID: Bool

private var characterStats: LocalizedStringKey {
let aaa = data.avatarList.count
let bbb = data.avatarList.filter { $0.rarity == 5 }.count
Expand Down Expand Up @@ -329,10 +329,10 @@ struct AvatarListItem: View {

// MARK: Private

@State private var condensed: Bool

private let avatar: MiHoYoAPI.CharacterInventory.HYAvatar
private let limited: Bool

@State private var condensed: Bool

@Default(.useRealCharacterNames) private var useRealName: Bool
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,14 @@ import SwiftUI

struct GIStyleRectangularWidgetView: View {
@Environment(\.colorScheme) var colorScheme

let entry: GIStyleEntry

var actualColorScheme: ColorScheme {
guard entry.configuration.textColor != .primary else { return colorScheme }
return entry.configuration.textColor == .white ? .light : .dark
}

var body: some View {
Group {
switch entry.dailyNoteResult {
Expand All @@ -36,11 +42,6 @@ struct GIStyleRectangularWidgetView: View {
.edgesIgnoringSafeArea(.all)
.environment(\.colorScheme, actualColorScheme)
}

var actualColorScheme: ColorScheme {
guard entry.configuration.textColor != .primary else { return colorScheme }
return entry.configuration.textColor == .white ? .light : .dark
}
}

// MARK: - WidgetGIStyleSuccessView
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,14 @@ import SwiftUI

struct GIStyleSquareWidgetView: View {
@Environment(\.colorScheme) var colorScheme

let entry: GIStyleEntry

var actualColorScheme: ColorScheme {
guard entry.configuration.textColor != .primary else { return colorScheme }
return entry.configuration.textColor == .white ? .light : .dark
}

var body: some View {
Group {
switch entry.dailyNoteResult {
Expand All @@ -37,11 +43,6 @@ struct GIStyleSquareWidgetView: View {
.edgesIgnoringSafeArea(.all)
.environment(\.colorScheme, actualColorScheme)
}

var actualColorScheme: ColorScheme {
guard entry.configuration.textColor != .primary else { return colorScheme }
return entry.configuration.textColor == .white ? .light : .dark
}
}

// MARK: - WidgetGIStyleSuccessView
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ struct LockscreenTimelineProvider: IntentTimelineProvider, HasDefaultAccount {
in context: Context,
completion: @escaping (Timeline<LockscreenEntry>) -> Void
) {
Task {
Task { @MainActor in
var entries: [Entry] = []

let account: Account? = {
Expand Down
4 changes: 2 additions & 2 deletions Features/Daily Note/View/InAppDailyNoteCardView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,10 @@ struct InAppDailyNoteCardView: View {

// MARK: Private

private let refreshSubject: PassthroughSubject<Void, Never>

@StateObject private var dailyNoteViewModel: DailyNoteViewModel

private let refreshSubject: PassthroughSubject<Void, Never>

private var account: Account {
dailyNoteViewModel.account
}
Expand Down
25 changes: 13 additions & 12 deletions Features/Gacha/View/AccountGachaDetailView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -104,17 +104,6 @@ private struct GachaItemDetail: View {

// MARK: Internal

var body: some View {
if !filteredGachaItemsWithDrawCount.isEmpty {
ForEach(filteredGachaItemsWithDrawCount, id: \.0.id) { item, drawCount in
GachaItemBar(item: item, drawCount: drawCount, showTime: showTime)
}
} else {
Text("gacha.account_detail.detail.no_data")
.foregroundColor(.secondary)
}
}

var filteredGachaItemsWithDrawCount: [(GachaItemMO, Int)] {
/// 补记:这里已经用 Query Predicate 筛检过了,所以 drawCounts 计算结果无误。
let drawCounts = calculateGachaItemsDrawCount(gachaItemsResult)
Expand All @@ -131,11 +120,23 @@ private struct GachaItemDetail: View {
}
}

var body: some View {
if !filteredGachaItemsWithDrawCount.isEmpty {
ForEach(filteredGachaItemsWithDrawCount, id: \.0.id) { item, drawCount in
GachaItemBar(item: item, drawCount: drawCount, showTime: showTime)
}
} else {
Text("gacha.account_detail.detail.no_data")
.foregroundColor(.secondary)
}
}

// MARK: Private

@FetchRequest private var gachaItemsResult: FetchedResults<GachaItemMO>

private var showTime: Bool

@FetchRequest private var gachaItemsResult: FetchedResults<GachaItemMO>
private let rankFilter: RankFilter
}

Expand Down
19 changes: 10 additions & 9 deletions Features/Gacha/View/AccountGachaView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -90,14 +90,6 @@ private struct GachaSmallChart: View {
}
}

var body: some View {
if fiveStarItems.isEmpty {
Text("gacha.account_detail.small_chart.no_data")
} else {
chart()
}
}

var colors: [Color] {
fiveStarItems.map { _, count in
switch count {
Expand All @@ -111,6 +103,14 @@ private struct GachaSmallChart: View {
}
}

var body: some View {
if fiveStarItems.isEmpty {
Text("gacha.account_detail.small_chart.no_data")
} else {
chart()
}
}

@ViewBuilder
func chart() -> some View {
ScrollView(.horizontal) {
Expand Down Expand Up @@ -265,10 +265,11 @@ private struct GachaStatisticSectionView: View {
return fmt
}()

@FetchRequest private var gachaItemsResult: FetchedResults<GachaItemMO>

private let gachaType: GachaType

@Default(.useGuestGachaEvaluator) private var useGuestGachaEvaluator: Bool
@FetchRequest private var gachaItemsResult: FetchedResults<GachaItemMO>

private var itemsWithDrawCount: [(GachaItemMO, drawCount: Int)] {
Array(zip(gachaItemsResult, calculateGachaItemsDrawCount(gachaItemsResult)))
Expand Down
12 changes: 6 additions & 6 deletions Features/Gacha/View/GachaChartView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -89,13 +89,13 @@ private struct GachaItemChart: View {

private typealias ItemPair = (GachaItemMO, count: Int)

@FetchRequest private var gachaItemsResult: FetchedResults<GachaItemMO>

@Default(.useGuestGachaEvaluator) private var useGuestGachaEvaluator: Bool
@Default(.useRealCharacterNames) private var useRealCharacterNames: Bool

private let gachaType: GachaType

@FetchRequest private var gachaItemsResult: FetchedResults<GachaItemMO>

private var items: [ItemPair] {
Array(zip(gachaItemsResult, calculateGachaItemsDrawCount(gachaItemsResult)))
}
Expand All @@ -104,10 +104,6 @@ private struct GachaItemChart: View {
useGuestGachaEvaluator ? "UI_EmotionIcon5" : "Pom-Pom_Sticker_32"
}

private func extract5Stars(_ source: [ItemPair]) -> [ItemPair] {
source.filter { $0.0.rank == .five }
}

@ViewBuilder
private func subChart(
givenItems: [ItemPair],
Expand Down Expand Up @@ -148,6 +144,10 @@ private struct GachaItemChart: View {
.chartLegend(.hidden)
}

private func extract5Stars(_ source: [ItemPair]) -> [ItemPair] {
source.filter { $0.0.rank == .five }
}

private func matchedItems(
among source: [ItemPair],
with value: String
Expand Down
60 changes: 30 additions & 30 deletions Features/Gacha/View/SRGF/ExportGachaView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -123,8 +123,6 @@ struct ExportGachaView: View {

@State private var isSucceedAlertShown: Bool = false
@State private var isFailureAlertShown: Bool = false
private let compactLayout: Bool

@Environment(\.managedObjectContext) private var viewContext
@Environment(\.dismiss) private var dismiss

Expand All @@ -140,6 +138,8 @@ struct ExportGachaView: View {
@State private var uigfJson: UIGFv4?
@State private var currentFormat: UIGFFormat = .uigfv4

private let compactLayout: Bool

private var currentDocument: GachaDocument? {
switch currentFormat {
case .uigfv4: uigfJson?.asDocument
Expand Down Expand Up @@ -192,6 +192,34 @@ struct ExportGachaView: View {
}
}

@ViewBuilder
private func accountPicker() -> some View {
Picker("app.gacha.account.select.title", selection: $params.uid) {
Group {
ForEach(accountPickerPairs, id: \.tag) { value, tag in
Text(value).tag(tag)
}
}
}
}

@ViewBuilder
private func postAlertMessage() -> some View {
switch alert {
case let .succeed(url): Text("gacha.export.fileSavedTo:\(url)")
case let .failure(message): Text(verbatim: "⚠︎ \(message)")
case nil: EmptyView()
}
}

@ViewBuilder
private func exportButton() -> some View {
Button("app.gacha.data.export.button") {
exportButtonClicked(format: currentFormat)
}
.disabled(params.uid == nil && currentFormat == .srgfv1)
}

private func exportButtonClicked(format: UIGFFormat) {
switch format {
case .uigfv4:
Expand Down Expand Up @@ -233,17 +261,6 @@ struct ExportGachaView: View {
}
}

@ViewBuilder
private func accountPicker() -> some View {
Picker("app.gacha.account.select.title", selection: $params.uid) {
Group {
ForEach(accountPickerPairs, id: \.tag) { value, tag in
Text(value).tag(tag)
}
}
}
}

private func firstAccount(uid: String) -> Account? {
accounts.first(where: { $0.uid! == uid })
}
Expand All @@ -256,23 +273,6 @@ struct ExportGachaView: View {
alert = .failure(message: failure.localizedDescription)
}
}

@ViewBuilder
private func postAlertMessage() -> some View {
switch alert {
case let .succeed(url): Text("gacha.export.fileSavedTo:\(url)")
case let .failure(message): Text(verbatim: "⚠︎ \(message)")
case nil: EmptyView()
}
}

@ViewBuilder
private func exportButton() -> some View {
Button("app.gacha.data.export.button") {
exportButtonClicked(format: currentFormat)
}
.disabled(params.uid == nil && currentFormat == .srgfv1)
}
}

extension ExportGachaView {
Expand Down
3 changes: 3 additions & 0 deletions Features/Gacha/View/SRGF/ImportGachaView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -474,6 +474,7 @@ private struct PopFileButton: View {

private struct StatusView<V: View>: View {
@Binding var status: ImportStatus

@ViewBuilder var pendingForImportView: () -> V

var body: some View {
Expand All @@ -496,6 +497,7 @@ private struct StatusView<V: View>: View {

private struct FailureView: View {
@Binding var status: ImportStatus

let errorMessage: String

var body: some View {
Expand All @@ -512,6 +514,7 @@ private struct FailureView: View {

private struct SucceedView: View {
@Binding var status: ImportStatus

let infoMsgs: [ImportSucceedInfo]

var body: some View {
Expand Down
Loading

0 comments on commit e10f111

Please sign in to comment.