Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
66 changes: 0 additions & 66 deletions iOSClient/Settings/AutoUpload/NCAutoUploadModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import Foundation
import UIKit
import Photos
import NextcloudKit
import EasyTipView
import SwiftUI

enum AutoUploadTimespan: String, CaseIterable, Identifiable {
Expand Down Expand Up @@ -49,10 +48,6 @@ class NCAutoUploadModel: ObservableObject, ViewOnAppearHandling {
@Published var error: String = ""
let database = NCManageDatabase.shared

private var observerToken: NSObjectProtocol?

// Tip
var tip: EasyTipView?
// Root View Controller
var controller: NCMainTabBarController?
// A variable user for change the auto upload directory
Expand All @@ -65,19 +60,6 @@ class NCAutoUploadModel: ObservableObject, ViewOnAppearHandling {
/// Initialization code to set up the ViewModel with the active account
init(controller: NCMainTabBarController?) {
self.controller = controller

observerToken = NotificationCenter.default.addObserver(forName: UIDevice.orientationDidChangeNotification,
object: nil,
queue: .main) { _ in
self.tip?.dismiss()
self.tip = nil
}
}

deinit {
if let token = observerToken {
NotificationCenter.default.removeObserver(token)
}
}

/// Triggered when the view appears.
Expand All @@ -99,13 +81,6 @@ class NCAutoUploadModel: ObservableObject, ViewOnAppearHandling {
requestAuthorization()

if !autoUploadImage && !autoUploadVideo { autoUploadImage = true }

showTip()
}

func onViewDisappear() {
tip?.dismiss()
tip = nil
}

// MARK: - All functions
Expand Down Expand Up @@ -271,47 +246,6 @@ class NCAutoUploadModel: ObservableObject, ViewOnAppearHandling {
}
}

extension NCAutoUploadModel: EasyTipViewDelegate {
func showTip() {
guard !session.account.isEmpty,
!database.tipExists(NCGlobal.shared.tipAutoUploadButton)
else {
return
}

var preferences = EasyTipView.Preferences()

preferences.drawing.foregroundColor = .white
preferences.drawing.backgroundColor = .lightGray
preferences.drawing.textAlignment = .left
preferences.drawing.arrowPosition = .any
preferences.drawing.cornerRadius = 10

preferences.animating.dismissTransform = CGAffineTransform(translationX: 0, y: 100)
preferences.animating.showInitialTransform = CGAffineTransform(translationX: 0, y: -100)
preferences.animating.showInitialAlpha = 0
preferences.animating.showDuration = 0.5
preferences.animating.dismissDuration = 0.5

if tip == nil {
tip = EasyTipView(text: NSLocalizedString("_tip_autoupload_button_", comment: ""), preferences: preferences, delegate: self, tip: NCGlobal.shared.tipAutoUploadButton)
DispatchQueue.main.asyncAfter(deadline: .now() + 1) {
if let view = self.controller?.tabBar {
self.tip?.show(forView: view)
}
}
}
}

func easyTipViewDidTap(_ tipView: EasyTipView) {
database.addTip(NCGlobal.shared.tipAutoUploadButton)
}

func easyTipViewDidDismiss(_ tipView: EasyTipView) {
tip = nil
}
}

/// An enum that represents the granularity of the subfolders for auto upload
enum Granularity: Int {
/// Daily granularity, meaning the subfolders are named by day
Expand Down
3 changes: 0 additions & 3 deletions iOSClient/Settings/AutoUpload/NCAutoUploadView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,6 @@ struct NCAutoUploadView: View {
.onAppear {
model.onViewAppear()
}
.onDisappear {
model.onViewDisappear()
}
.onReceive(NotificationCenter.default.publisher(for: UIApplication.didBecomeActiveNotification)) { _ in
model.checkPermission()
}
Expand Down
Loading