Skip to content

Commit

Permalink
Several fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
liang2kl committed Jun 6, 2021
1 parent 15ce3ed commit 3c11bd7
Show file tree
Hide file tree
Showing 20 changed files with 47 additions and 71 deletions.
57 changes: 24 additions & 33 deletions Source/Hollow.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -73,15 +73,6 @@
"version": "1.8.1"
}
},
{
"package": "Introspect",
"repositoryURL": "https://github.com/siteline/SwiftUI-Introspect.git",
"state": {
"branch": null,
"revision": "2e09be8af614401bc9f87d40093ec19ce56ccaf2",
"version": "0.1.3"
}
},
{
"package": "WaterfallGrid",
"repositoryURL": "https://github.com/paololeonardi/WaterfallGrid.git",
Expand Down
4 changes: 1 addition & 3 deletions Source/Hollow/App/HollowApp.swift
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,6 @@ struct HollowApp: App {
}
// Set larger size category for macOS
.conditionalSizeCategory()
// // Inject the app model into the environment
// .environmentObject(appModel)
// Set the color scheme when appear
.onAppear {
IntegrationUtilities.setCustomColorScheme()
Expand All @@ -44,7 +42,7 @@ struct HollowApp: App {
NotificationCenter.default.publisher(for: UIApplication.didBecomeActiveNotification),
perform: { _ in
appDelegate.fetchConfig()
if appModel.widgetReloadCount % 3 == 0 {
if appModel.widgetReloadCount % 3 == 1 {
WidgetCenter.shared.reloadAllTimelines()
appModel.widgetReloadCount += 1
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -332,7 +332,7 @@ struct PushNotificationSettingsView: View {
})
}

class ViewModel: ObservableObject, AppModelEnvironment {
class ViewModel: ObservableObject, HollowErrorHandler {
@Published var isLoading = false
@Published var notificationType = Defaults[.notificationTypeCache]
@Published var tempNotificationType = Defaults[.notificationTypeCache]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@

import SwiftUI
import Defaults
import Introspect

struct HollowTextView: View {
var text: String
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@

import SwiftUI
import Defaults
import Introspect

struct HollowDetailView: View {
@ObservedObject var store: HollowDetailStore
Expand Down Expand Up @@ -129,7 +128,6 @@ struct HollowDetailView: View {
}

}
.introspectTableView(customize: { $0.backgroundColor = nil })
.background(Color.hollowCardBackground)
.coordinateSpace(name: "detail.scrollview")
.buttonStyle(BorderlessButtonStyle())
Expand Down
2 changes: 0 additions & 2 deletions Source/Hollow/View/Hierarchy/Main/MainView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,6 @@ struct MainView: View {

let overlayTransition = AnyTransition.asymmetric(insertion: .opacity, removal: .scaleAndOpacity)
@Namespace var namespace

@Environment(\.colorScheme) var colorScheme

var body: some View {
ZStack {
Expand Down
6 changes: 5 additions & 1 deletion Source/Hollow/View/Integration/IntegrationUtilities.swift
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ struct IntegrationUtilities {
store = detailVC.store
}
} else {
if let detailVC = topViewController() as? HollowDetailViewController {
if let detailVC = getDetailVC() {
store = detailVC.store
}
}
Expand Down Expand Up @@ -158,4 +158,8 @@ extension IntegrationUtilities {
vc.view.backgroundColor = nil
navigationVC.pushViewController(vc, animated: true)
}

static private func getDetailVC() -> HollowDetailViewController? {
return (topViewController() as? UINavigationController)?.topViewController as? HollowDetailViewController
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//
// AppModelEnvironment.swift
// HollowErrorHandler.swift
// Hollow
//
// Created by liang2kl on 2021/2/15.
Expand All @@ -10,9 +10,9 @@ import SwiftUI
import Defaults

/// Protocol for a view model which protentially modify the shared `AppModel` instance.
protocol AppModelEnvironment: ObservableObject {}
protocol HollowErrorHandler: ObservableObject {}

extension AppModelEnvironment {
extension HollowErrorHandler {
/// Default implementation to handle token expire error.
///
/// - parameter error: The request error
Expand Down
4 changes: 2 additions & 2 deletions Source/Hollow/en.lproj/Localizable.strings
Original file line number Diff line number Diff line change
Expand Up @@ -659,9 +659,9 @@

"SETTINGSVIEW_APPEARANCE_BLURRED_IMG_BG" = "Blurred Image Background";

"HOLLOWDETAIL_COMMENTS_ORDER_OLD_TO_NEW" = "Old to New";
"HOLLOWDETAIL_COMMENTS_ORDER_OLD_TO_NEW" = "OLD TO NEW";

"HOLLOWDETAIL_COMMENTS_ORDER_NEW_TO_OLD" = "New to Old";
"HOLLOWDETAIL_COMMENTS_ORDER_NEW_TO_OLD" = "NEW TO OLD";

"COMMENT_VIEW_SHOW_ONLY_LABEL" = "Show this Person Only";

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//
// AppModelEnvironment.swift
// HollowErrorHandler.swift
// HollowMac
//
// Created by liang2kl on 2021/4/24.
Expand All @@ -9,11 +9,10 @@
import SwiftUI
import Defaults

protocol AppModelEnvironment: ObservableObject {
var appModelState: AppModelState { get set }
protocol HollowErrorHandler: ObservableObject {
}

extension AppModelEnvironment {
extension HollowErrorHandler {
/// Default implementation to handle token expire error.
///
/// - parameter error: The request error
Expand Down
2 changes: 0 additions & 2 deletions Source/HollowMac/View/Hierarchy/Login/LoginView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -116,8 +116,6 @@ struct LoginView: View {
.disabled(disableButton)
}
.errorAlert($store.errorMessage)

.modifier(AppModelBehaviour(state: store.appModelState))
}
}

Expand Down
2 changes: 1 addition & 1 deletion Source/Shared/ViewModel/Account/AccountInfoStore.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import SwiftUI
import Combine
import Defaults

class AccountInfoStore: ObservableObject, AppModelEnvironment {
class AccountInfoStore: ObservableObject, HollowErrorHandler {
@Published var errorMessage: (title: String, message: String)?
@Published var isLoading = false

Expand Down
2 changes: 1 addition & 1 deletion Source/Shared/ViewModel/Account/DeviceListStore.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import Combine
import SwiftUI
import Defaults

class DeviceListStore: ObservableObject, AppModelEnvironment {
class DeviceListStore: ObservableObject, HollowErrorHandler {
@Published var deviceData: DeviceListRequestResultData
@Published var isLoading: Bool = false
@Published var loggingoutUUID: String?
Expand Down
2 changes: 1 addition & 1 deletion Source/Shared/ViewModel/Account/MessageStore.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import Combine
import Defaults
import SwiftUI

class MessageStore: ObservableObject, AppModelEnvironment {
class MessageStore: ObservableObject, HollowErrorHandler {
@Published var messages: [SystemMessage] = []
@Published var errorMessage: (title: String, message: String)?
@Published var isLoading = false
Expand Down
2 changes: 1 addition & 1 deletion Source/Shared/ViewModel/Hollow/HollowDetailStore.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import Defaults
import Connectivity
#endif

class HollowDetailStore: ObservableObject, ImageCompressStore, AppModelEnvironment {
class HollowDetailStore: ObservableObject, ImageCompressStore, HollowErrorHandler {
// MARK: Post Variables
var bindingPostWrapper: Binding<PostDataWrapper>
@Published var postDataWrapper: PostDataWrapper
Expand Down
2 changes: 1 addition & 1 deletion Source/Shared/ViewModel/Hollow/HollowInputStore.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import Combine
import SwiftUI
import Defaults

class HollowInputStore: ObservableObject, AppModelEnvironment, ImageCompressStore {
class HollowInputStore: ObservableObject, HollowErrorHandler, ImageCompressStore {
var presented: Binding<Bool>
var selfDismiss: Bool
var refreshHandler: (() -> Void)?
Expand Down
2 changes: 1 addition & 1 deletion Source/Shared/ViewModel/Hollow/PostListRequestStore.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import Combine

/// Shared view model for views that request `PostList`, `Search`, `AttentionList`
/// and `AttentionListSearch`.
class PostListRequestStore: ObservableObject, AppModelEnvironment {
class PostListRequestStore: ObservableObject, HollowErrorHandler {

// MARK: - Shared Variables
let type: PostListRequestGroupType
Expand Down
2 changes: 1 addition & 1 deletion Source/Shared/ViewModel/Login/LoginStore.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import SwiftUI
import Defaults

/// View model for `LoginView`
class LoginStore: ObservableObject, AppModelEnvironment {
class LoginStore: ObservableObject, HollowErrorHandler {

@Published var showsRecaptcha = false
@Published var reCAPTCHAToken: String = ""
Expand Down
2 changes: 1 addition & 1 deletion Source/Shared/ViewModel/Login/UnregisterStore.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import Combine
import Defaults
import SwiftUI

class UnregisterStore: ObservableObject, AppModelEnvironment {
class UnregisterStore: ObservableObject, HollowErrorHandler {
var presented: Binding<Bool>
@Published var email = "" {
didSet { if email != oldValue { restore() } }
Expand Down

0 comments on commit 3c11bd7

Please sign in to comment.