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

Commit

Permalink
- improved manual icloud sync
Browse files Browse the repository at this point in the history
  • Loading branch information
rursache committed Jan 16, 2020
1 parent b7443c2 commit a2685bb
Show file tree
Hide file tree
Showing 8 changed files with 40 additions and 38 deletions.
27 changes: 16 additions & 11 deletions Classes/Settings/SettingsViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ class SettingsViewController: BaseViewController {
}

func addRightDoneButton() {
self.navigationItem.rightBarButtonItem = UIBarButtonItem(title: "DONE".localized(), style: .done, target: self, action: #selector(self.closeButtonAction))
self.navigationItem.rightBarButtonItem = UIBarButtonItem(title: "DONE".localized(), style: .done, target: self, action: #selector(self.closeButtonAction))
}

func addBottomVersionLabel() {
Expand Down Expand Up @@ -113,7 +113,7 @@ class SettingsViewController: BaseViewController {
}

if section == 2 {

// nothing here, we got switches
}

if section == 3 {
Expand All @@ -122,15 +122,20 @@ class SettingsViewController: BaseViewController {
Utils().showSuccessToast(viewController: self, message: "SETTINGS_SYNC_START".localized())
self.navigationItem.rightBarButtonItem = nil

Utils().getSyncEngine()?.pull()
DispatchQueue.main.asyncAfter(deadline: .now() + 5, execute: {
Utils().getSyncEngine()?.pushAll()

DispatchQueue.main.asyncAfter(deadline: .now() + 5, execute: {
self.addRightDoneButton()
Utils().showSuccessToast(viewController: self, message: "SETTINGS_SYNC_END".localized())
})
})
Utils().getSyncEngine()?.pull(completionHandler: { error in
if error != nil {
DispatchQueue.main.async {
Utils().showSuccessToast(viewController: self, message: "SETTINGS_SYNC_FAILED".localized())
self.addRightDoneButton()
}
}

DispatchQueue.main.async {
Utils().getSyncEngine()?.pushAll()
Utils().showSuccessToast(viewController: self, message: "SETTINGS_SYNC_END".localized())
self.addRightDoneButton()
}
})

} else if row == 2 {
// feedback
Expand Down
2 changes: 1 addition & 1 deletion Others/Extensions.swift
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,6 @@ extension Bundle {

extension UIApplication {
func topMostViewController() -> UIViewController {
return (self.keyWindow?.rootViewController?.topMostViewController())!
return (self.keyWindow?.rootViewController?.topMostViewController())!
}
}
32 changes: 17 additions & 15 deletions Others/Utils.swift
Original file line number Diff line number Diff line change
Expand Up @@ -85,22 +85,24 @@ class Utils: NSObject {
}

fileprivate func showToast(viewController: UIViewController?, message: String, state: Loaf.State) {
var vc = UIViewController()
#if realApp
vc = UIApplication.shared.topMostViewController()
#endif
if viewController != nil {
vc = viewController!
DispatchQueue.main.async {
var vc = UIViewController()
#if realApp
vc = UIApplication.shared.topMostViewController()
#endif
if viewController != nil {
vc = viewController!
}

Loaf.dismiss(sender: vc)
DispatchQueue.main.asyncAfter(deadline: .now() + 0.1) {
Loaf(message, state: state, location: .top, sender: vc).show()

DispatchQueue.main.asyncAfter(deadline: .now() + Config.General.toastOnScreenTime) {
Loaf.dismiss(sender: vc, animated: true)
}
}
}

Loaf.dismiss(sender: vc)
DispatchQueue.main.asyncAfter(deadline: .now() + 0.1) {
Loaf(message, state: state, location: .top, sender: vc).show()

DispatchQueue.main.asyncAfter(deadline: .now() + Config.General.toastOnScreenTime) {
Loaf.dismiss(sender: vc, animated: true)
}
}
}

// notifications
Expand Down
1 change: 1 addition & 0 deletions Others/en.lproj/Localizable.strings
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
"SETTINGS_ITEM_ENTRY_ABOUT" = "About";
"SETTINGS_SYNC_START" = "Sync started, please wait...";
"SETTINGS_SYNC_END" = "Sync done";
"SETTINGS_SYNC_FAILED" = "Sync failed, check your iCloud account or try again later";
"SETTINGS_NO_EMAIL_FAILED" = "No email account setup on your device";
"SETTINGS_ABOUT_TEXT" = "A simple open source To-do list app written in Swift. Based on Todoist UI/UX\nRadu Ursache - RanduSoft\n\n";
"SETTINGS_CONFIRMATION_START_PAGE" = "Start page updated!";
Expand Down
3 changes: 2 additions & 1 deletion Others/ro.lproj/Localizable.strings
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,8 @@
"SETTINGS_ITEM_ENTRY_ACKNOW" = "Mulțumiri";
"SETTINGS_ITEM_ENTRY_ABOUT" = "Despre";
"SETTINGS_SYNC_START" = "A început sincronizarea, vă rugăm să așteptați ...";
"SETTINGS_SYNC_END" = "Sincronizare făcută";
"SETTINGS_SYNC_END" = "Sincronizare finalizată";
"SETTINGS_SYNC_FAILED" = "Sincronizare eșuată";
"SETTINGS_NO_EMAIL_FAILED" = "Nicio configurare a contului de e-mail pe dispozitiv";
"SETTINGS_ABOUT_TEXT" = "O simplă aplicație de listă de activități open source scrisă în Swift. Bazată pe Todoist UI/UX\nRadu Ursache - RanduSoft\n\n";
"SETTINGS_CONFIRMATION_START_PAGE" = "Pagina de pornire actualizată!";
Expand Down
3 changes: 1 addition & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,7 @@ A simple To-do list app build for iPhone, iPad and Apple Watch in Swift 5 (iOS 1

### Improvements/To Do
- [ ] watchOS complications + sync improvements
- [ ] Reload notifications after user gave push permissions
- [ ] Better CloudKit sync events and responses
- [ ] Reload notifications after user gave push permissions if initially declined

## Communication
- If you **found a bug**, open an [issue](https://github.com/rursache/ToDoList/issues).
Expand Down
6 changes: 0 additions & 6 deletions ToDoList.entitlements
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,9 @@
</array>
<key>com.apple.developer.ubiquity-kvstore-identifier</key>
<string>$(TeamIdentifierPrefix)$(CFBundleIdentifier)</string>
<key>com.apple.security.app-sandbox</key>
<true/>
<key>com.apple.security.application-groups</key>
<array>
<string>group.ro.randusoft.RSToDoList</string>
</array>
<key>com.apple.security.device.camera</key>
<true/>
<key>com.apple.security.network.client</key>
<true/>
</dict>
</plist>
4 changes: 2 additions & 2 deletions ToDoList.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -581,7 +581,7 @@
attributes = {
LastSwiftUpdateCheck = 1130;
LastUpgradeCheck = 1010;
ORGANIZATIONNAME = "Radu Ursache";
ORGANIZATIONNAME = "Radu Ursache - RanduSoft";
TargetAttributes = {
1718BE4223CCBB19009D591A = {
CreatedOnToolsVersion = 11.3;
Expand Down Expand Up @@ -611,7 +611,7 @@
};
};
buildConfigurationList = 17D18D36221D56C4005C647B /* Build configuration list for PBXProject "ToDoList" */;
compatibilityVersion = "Xcode 9.3";
compatibilityVersion = "Xcode 11.0";
developmentRegion = en;
hasScannedForEncodings = 0;
knownRegions = (
Expand Down

0 comments on commit a2685bb

Please sign in to comment.