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

Commit

Permalink
Fix // fix error cause by resolve conflict & others (#16)
Browse files Browse the repository at this point in the history
* fix: merge conflict bug

* code: delete unused codes

* code: mark TODOs

* fix: replace UserDefault using SwiftyUserDefaults

* fix: delete unused code

* proj: apply xcode recommended setting
  • Loading branch information
CanglongCl authored May 5, 2023
1 parent 9e98048 commit ff904e5
Show file tree
Hide file tree
Showing 6 changed files with 91 additions and 216 deletions.
11 changes: 6 additions & 5 deletions Common Tools/ReviewHandler.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import Foundation
import StoreKit
import SwiftUI
import SwiftyUserDefaults

class ReviewHandler {
// MARK: Lifecycle
Expand All @@ -27,11 +28,11 @@ class ReviewHandler {

static func requestReview() {
#if DEBUG
UserDefaults.standard.set(nil, forKey: "lastVersionPromptedForReviewKey")
Defaults[\.lastVersionPromptedForReview] = nil
#endif
DispatchQueue.main.async {
// Keep track of the most recent app version that prompts the user for a review.
let lastVersionPromptedForReview = UserDefaults.standard.string(forKey: "lastVersionPromptedForReviewKey")
let lastVersionPromptedForReview = Defaults[\.lastVersionPromptedForReview]

// Get the current bundle version for the app.
let infoDictionaryKey = kCFBundleVersionKey as String
Expand All @@ -43,15 +44,14 @@ class ReviewHandler {
.first(where: { $0.activationState == .foregroundActive
}) as? UIWindowScene {
SKStoreReviewController.requestReview(in: windowScene)
UserDefaults.standard.set(currentVersion, forKey: "lastVersionPromptedForReviewKey")
Defaults[\.lastVersionPromptedForReview] = currentVersion
}
}
}
}

static func requestReviewIfNotRequestedElseNavigateToAppStore() {
let lastVersionPromptedForReview = UserDefaults.standard
.string(forKey: "lastVersionPromptedForReviewKey")
let lastVersionPromptedForReview = Defaults[\.lastVersionPromptedForReview]
let infoDictionaryKey = kCFBundleVersionKey as String
guard let currentVersion = Bundle.main
.object(forInfoDictionaryKey: infoDictionaryKey) as? String
Expand All @@ -60,6 +60,7 @@ class ReviewHandler {
if currentVersion != lastVersionPromptedForReview {
ReviewHandler.requestReview()
} else {
// TODO: update AppID after upload to App Store Connect
guard let writeReviewURL =
URL(string: "https://apps.apple.com/app/id1635319193?action=write-review")
else { fatalError("Expected a valid URL") }
Expand Down
7 changes: 7 additions & 0 deletions Common Tools/UserDefaultKeys.swift
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,13 @@ extension DefaultsKeys {
var example: DefaultsKey<String> { .init("example", defaultValue: "Hello World!") }

// MARK: - In app
var lastVersionPromptedForReview: DefaultsKey<String?> {
.init("lastVersionPromptedForReview")
}

var isPolicyShown: DefaultsKey<Bool> {
.init("isPolicyShown", defaultValue: false)
}

// MARK: - For widgets
}
132 changes: 61 additions & 71 deletions Features/Daily Note/View/InAppDailyNoteCardView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,7 @@ struct InAppDailyNoteCardView: View {
Section {
switch dailyNoteViewModel.dailyNote {
case .loading, .pending:
HStack {
Spacer()
ProgressView()
Spacer()
}
ProgressView()
case let .finished(result):
switch result {
case let .success(note):
Expand Down Expand Up @@ -63,85 +59,79 @@ private struct NoteView: View {
var isDispatchDetailShow = false

var body: some View {
Section {
VStack {
HStack {
Text("sys.label.trailblaze").bold()
Spacer()
VStack {
HStack {
Text("sys.label.trailblaze").bold()
Spacer()
}
HStack(alignment: .bottom) {
let iconFrame: CGFloat = 30
Image("Item_Trailblaze_Power")
.resizable()
.scaledToFit()
.frame(height: iconFrame)
HStack(alignment: .bottom, spacing: 0) {
Text("\(note.staminaInformation.currentStamina)")
.font(.title)
+ Text("/\(note.staminaInformation.maxStamina)")
.font(.caption)
}
HStack(alignment: .bottom) {
let iconFrame: CGFloat = 30
Image("Item_Trailblaze_Power")
.resizable()
.scaledToFit()
.frame(height: iconFrame)
HStack(alignment: .bottom, spacing: 0) {
Text("\(note.staminaInformation.currentStamina)")
.font(.title)
+ Text("/\(note.staminaInformation.maxStamina)")
.font(.caption)
}
Spacer()
VStack(alignment: .trailing) {
Text(expedition.finishedTime, style: .time)
Text(dateComponentsFormatter.string(from: expedition.remainingTime) ?? "")
}
.font(.caption2)
Spacer()
VStack(alignment: .trailing) {
Text(note.staminaInformation.fullTime, style: .time)
Text(note.staminaInformation.fullTime, style: .relative)
}
.font(.caption2)
}
VStack {
HStack {
Text("sys.label.dispatch").bold()
Spacer()
let onGoingExpeditionNumber = note.expeditionInformation.onGoingExpeditionNumber
let totalExpeditionNumber = note.expeditionInformation.totalExpeditionNumber
Text("\(onGoingExpeditionNumber)/\(totalExpeditionNumber)")
}
.onTapGesture {
withAnimation(.linear) {
isDispatchDetailShow.toggle()
}
}
VStack {
HStack {
Text("sys.label.dispatch").bold()
Spacer()
let onGoingExpeditionNumber = note.expeditionInformation.onGoingExpeditionNumber
let totalExpeditionNumber = note.expeditionInformation.totalExpeditionNumber
Text("\(onGoingExpeditionNumber)/\(totalExpeditionNumber)")
}
.onTapGesture {
withAnimation(.linear) {
isDispatchDetailShow.toggle()
}
}
if isDispatchDetailShow {
VStack {
ForEach(note.expeditionInformation.expeditions, id: \.name) { expedition in
HStack {
VStack(alignment: .leading) {
HStack {
let imageFrame: CGFloat = 40
ForEach(expedition.avatarIconURLs, id: \.self) { url in
AsyncImage(url: url) { image in
image.resizable().scaledToFit()
} placeholder: {
ProgressView()
}
.frame(height: imageFrame)
}
if isDispatchDetailShow {
VStack {
ForEach(note.expeditionInformation.expeditions, id: \.name) { expedition in
HStack {
VStack(alignment: .leading) {
HStack {
let imageFrame: CGFloat = 40
ForEach(expedition.avatarIconURLs, id: \.self) { url in
AsyncImage(url: url) { image in
image.resizable().scaledToFit()
} placeholder: {
ProgressView()
}
.frame(height: imageFrame)
}
Text("\(expedition.name)")
.font(.footnote)
.foregroundColor(.secondary)
}
Spacer()
VStack(alignment: .trailing) {
Text(expedition.finishedTime, style: .time)
Text(dateComponentsFormatter.string(from: expedition.remainingTime) ?? "")
}
Text("\(expedition.name)")
.font(.footnote)
.foregroundColor(.secondary)
}
.onTapGesture {
withAnimation(.linear) {
isDispatchDetailShow.toggle()
}
Spacer()
VStack(alignment: .trailing) {
Text(expedition.finishedTime, style: .time)
Text(dateComponentsFormatter.string(from: expedition.remainingTime) ?? "")
}
}
.onTapGesture {
withAnimation(.linear) {
isDispatchDetailShow.toggle()
}
}
}
.listRowSeparator(.hidden)
}
} header: {
if let name = account.name {
Text(name)
}
.listRowSeparator(.hidden)
}
}
}
Expand Down
28 changes: 10 additions & 18 deletions HSRPizzaHelper.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@
objects = {

/* Begin PBXBuildFile section */
BF06C4A02A04A89C00EE9120 /* AboutView.swift in Sources */ = {isa = PBXBuildFile; fileRef = BF06C49F2A04A89C00EE9120 /* AboutView.swift */; };
BF06C4A22A04A90500EE9120 /* ThanksView.swift in Sources */ = {isa = PBXBuildFile; fileRef = BF06C4A12A04A90500EE9120 /* ThanksView.swift */; };
BF06C4A52A04D42900EE9120 /* WebViews.swift in Sources */ = {isa = PBXBuildFile; fileRef = BF06C4A42A04D42900EE9120 /* WebViews.swift */; };
BF06C4A82A04FD1F00EE9120 /* ReviewHandler.swift in Sources */ = {isa = PBXBuildFile; fileRef = BF06C4A72A04FD1F00EE9120 /* ReviewHandler.swift */; };
BF14CFA82A049ADB00E437C6 /* Localizable.strings in Resources */ = {isa = PBXBuildFile; fileRef = BF14CFAA2A049ADB00E437C6 /* Localizable.strings */; };
Expand All @@ -22,6 +20,8 @@
EA32764D2A03851F00774126 /* Background.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = EA32764C2A03851F00774126 /* Background.xcassets */; };
EA32764F2A03852C00774126 /* Icon.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = EA32764E2A03852C00774126 /* Icon.xcassets */; };
EA37AEB42A02CDB900E4AADA /* SwifterSwift in Frameworks */ = {isa = PBXBuildFile; productRef = EA37AEB32A02CDB900E4AADA /* SwifterSwift */; };
EA60BE5D2A05053200CBF10B /* AboutView.swift in Sources */ = {isa = PBXBuildFile; fileRef = EA60BE5B2A05053200CBF10B /* AboutView.swift */; };
EA60BE5E2A05053200CBF10B /* ThanksView.swift in Sources */ = {isa = PBXBuildFile; fileRef = EA60BE5C2A05053200CBF10B /* ThanksView.swift */; };
EA742BF72A020A3300ACB8E4 /* CreateAccountSheetView.swift in Sources */ = {isa = PBXBuildFile; fileRef = EA742BF62A020A3300ACB8E4 /* CreateAccountSheetView.swift */; };
EA742BF92A020B8700ACB8E4 /* GetCookieWebView.swift in Sources */ = {isa = PBXBuildFile; fileRef = EA742BF82A020B8700ACB8E4 /* GetCookieWebView.swift */; };
EA742BFC2A0238C500ACB8E4 /* AppConfig.swift in Sources */ = {isa = PBXBuildFile; fileRef = EA742BFB2A0238C500ACB8E4 /* AppConfig.swift */; };
Expand Down Expand Up @@ -49,8 +49,6 @@
/* End PBXBuildFile section */

/* Begin PBXFileReference section */
BF06C49F2A04A89C00EE9120 /* AboutView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AboutView.swift; sourceTree = "<group>"; };
BF06C4A12A04A90500EE9120 /* ThanksView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ThanksView.swift; sourceTree = "<group>"; };
BF06C4A42A04D42900EE9120 /* WebViews.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = WebViews.swift; sourceTree = "<group>"; };
BF06C4A72A04FD1F00EE9120 /* ReviewHandler.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ReviewHandler.swift; sourceTree = "<group>"; };
BF14CFA92A049ADB00E437C6 /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/Localizable.strings; sourceTree = "<group>"; };
Expand All @@ -65,6 +63,8 @@
EA2C06542A04ACE200A328E6 /* EditAccountSheetView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = EditAccountSheetView.swift; sourceTree = "<group>"; };
EA32764C2A03851F00774126 /* Background.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Background.xcassets; sourceTree = "<group>"; };
EA32764E2A03852C00774126 /* Icon.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Icon.xcassets; sourceTree = "<group>"; };
EA60BE5B2A05053200CBF10B /* AboutView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AboutView.swift; sourceTree = "<group>"; };
EA60BE5C2A05053200CBF10B /* ThanksView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ThanksView.swift; sourceTree = "<group>"; };
EA742BF62A020A3300ACB8E4 /* CreateAccountSheetView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CreateAccountSheetView.swift; sourceTree = "<group>"; };
EA742BF82A020B8700ACB8E4 /* GetCookieWebView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = GetCookieWebView.swift; sourceTree = "<group>"; };
EA742BFB2A0238C500ACB8E4 /* AppConfig.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppConfig.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -108,15 +108,6 @@
/* End PBXFrameworksBuildPhase section */

/* Begin PBXGroup section */
BF06C49E2A04A88300EE9120 /* SysViews */ = {
isa = PBXGroup;
children = (
BF06C49F2A04A89C00EE9120 /* AboutView.swift */,
BF06C4A12A04A90500EE9120 /* ThanksView.swift */,
);
path = SysViews;
sourceTree = "<group>";
};
BF06C4A32A04D41A00EE9120 /* PublicViews */ = {
isa = PBXGroup;
children = (
Expand Down Expand Up @@ -151,8 +142,8 @@
EA14BF932A04C59C002EDBB4 /* View */ = {
isa = PBXGroup;
children = (
BF06C49F2A04A89C00EE9120 /* AboutView.swift */,
BF06C4A12A04A90500EE9120 /* ThanksView.swift */,
EA60BE5B2A05053200CBF10B /* AboutView.swift */,
EA60BE5C2A05053200CBF10B /* ThanksView.swift */,
);
path = View;
sourceTree = "<group>";
Expand Down Expand Up @@ -331,7 +322,6 @@
isa = PBXGroup;
children = (
BF06C4A32A04D41A00EE9120 /* PublicViews */,
BF06C49E2A04A88300EE9120 /* SysViews */,
EADA63762A0201B200BF070F /* HomeView.swift */,
EAE37EBE2A0206AC00154432 /* SettingView.swift */,
);
Expand Down Expand Up @@ -470,8 +460,8 @@
EAE37EC12A0206BC00154432 /* ManageAccountsView.swift in Sources */,
EA742BFC2A0238C500ACB8E4 /* AppConfig.swift in Sources */,
EAE519892A01738600EF23B7 /* Persistence.swift in Sources */,
EA60BE5E2A05053200CBF10B /* ThanksView.swift in Sources */,
EAE519C52A01787000EF23B7 /* AccountViewModel.swift in Sources */,
BF06C4A02A04A89C00EE9120 /* AboutView.swift in Sources */,
BF06C4A52A04D42900EE9120 /* WebViews.swift in Sources */,
EAE37EBD2A02035300154432 /* Account+Server.swift in Sources */,
EAE519CE2A017BD300EF23B7 /* FetchStatus.swift in Sources */,
Expand All @@ -482,7 +472,6 @@
EA742BF92A020B8700ACB8E4 /* GetCookieWebView.swift in Sources */,
EA2C06522A04AC5A00A328E6 /* TestAccountView.swift in Sources */,
EAE519822A01738600EF23B7 /* ContentView.swift in Sources */,
BF06C4A22A04A90500EE9120 /* ThanksView.swift in Sources */,
EADA63752A01FF8B00BF070F /* DailyNoteViewModel.swift in Sources */,
EA2C06552A04ACE200A328E6 /* EditAccountSheetView.swift in Sources */,
EA742BFE2A0238FC00ACB8E4 /* UserDefaultKeys.swift in Sources */,
Expand All @@ -491,6 +480,7 @@
EA2C064D2A04A0CA00A328E6 /* Account+CoreDataProperties.swift in Sources */,
EAE519802A01738600EF23B7 /* HSRPizzaHelperApp.swift in Sources */,
BF06C4A82A04FD1F00EE9120 /* ReviewHandler.swift in Sources */,
EA60BE5D2A05053200CBF10B /* AboutView.swift in Sources */,
EAE37EBF2A0206AC00154432 /* SettingView.swift in Sources */,
EA9D024C2A04BE3800796516 /* AccountDetailView.swift in Sources */,
EAE519C72A01788F00EF23B7 /* Account.swift in Sources */,
Expand Down Expand Up @@ -518,6 +508,7 @@
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES;
CLANG_ANALYZER_NONNULL = YES;
CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE;
CLANG_CXX_LANGUAGE_STANDARD = "gnu++20";
Expand Down Expand Up @@ -578,6 +569,7 @@
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES;
CLANG_ANALYZER_NONNULL = YES;
CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE;
CLANG_CXX_LANGUAGE_STANDARD = "gnu++20";
Expand Down
Loading

0 comments on commit ff904e5

Please sign in to comment.