GithubHelp home page GithubHelp logo

realm / realm-tasks Goto Github PK

View Code? Open in Web Editor NEW
368.0 39.0 73.0 3.47 MB

To Do app built with Realm, inspired by Clear for iOS

License: Other

Swift 45.95% Ruby 1.31% Java 29.82% C# 10.85% JavaScript 9.79% Objective-C 1.75% Shell 0.07% Starlark 0.47%
realm android cocoa react-native xamarin

realm-tasks's Introduction

Realm Tasks (DEPRECATED)

This project is deprecated and is no longer actively maintained.

A basic task management app, designed as a homage to Realmac Software's Clear, with their knowledge and permission.

Realm Tasks

Warning: This project is very much a work in progress, being used as a testbed for new Realm technologies. It is in no way a fully feature-complete product, nor is it ever meant to be an actual competitor for the Clear app.

Requirements

Cocoa

  • Xcode 8.
  • CocoaPods 1.0.1.

Android

  • Android Studio 2.2 with Android API 25
  • An emulator, Genymotion or a real device attached and running.

1. Get the Realm Object Server

The Realm Tasks apps uses a Realm Object Server to synchronize tasks between them.

The fastest way to get access to a Realm Object Server is by signing up for a free Realm Cloud trial: https://cloud.realm.io/login/sign-up.

2. Build and Run RealmTasks

First download or clone this repo.

Cocoa

  1. Run pod install from the RealmTasks Apple directory in this repo.
  2. Open RealmTasks Apple/RealmTasks.xcworkspace with Xcode 8.
  3. Select either the "RealmTasks macOS" or "RealmTasks iOS" depending on which platform you'd like to try the app on.
  4. Click the "Build and Run" icon in the upper left of Xcode (play icon).
  5. When the app launches, tap/click "Register" if this is the first time you're trying the app, or "Log In" if you've already created an account.
  6. Optional: If you'd like to run the app on a physical iPhone, you'll need to have code signing set up with Xcode, and the iPhone should be connected on the same local network as your Mac running the object server.

Android

  1. Go to the RealmTasks Android directory in this repo.
  2. Run ./gradlew installDebug
  3. The RealmTask app should now be installed on all attached Android devices and emulators. You need to launch the app manually.

Using RealmTasks

At this point, you can login, start creating items, managing lists, and you'll see your actions reflected in real time in other running instances of the app wether it is the Android, iOS or macOS app.

We recommend that you run at least two instances of the app together to really show off sync in action.

3. Access Realm Files with Realm Studio

Another useful tool is Realm Studio which is available for macOS, Linux, Windows and allows developers to inspect and manage Realms. Realm Studio is recommended for all developers and can be downloaded from the Realm web site.

  1. Launch the Realm Studio app obtained above and click "Connect to Realm Object Server".
  2. Press "Connect" to connect to the Realm Object Server running locally.
  3. You now see a list of all Realms on the server. The RealmTask file is named /<UserId>/realmtasks.

Compatibility

RealmTasks is designed to be cross platform, so versions for all platforms/languages should be able to sync with each other. There may be slight discrepancies in terms of functionality which will be listed here.

  • Authentication against Azure Active Directory is only supported in the Xamarin version.

Third Party Dependencies

Cocoa

The following modules will be installed as part of the CocoaPods installation:

  • Realm Swift - The Swift version of the Realm Mobile Database.
  • Realm LoginKit - A Realm control for logging in to Realm servers.
  • Cartography - A library for making it easier to define auto layout constraints in code.
  • SwiftLint - A tool for validating the quality of Swift code.

Contributing

See CONTRIBUTING.md for more details!

This project adheres to the MongoDB Code of Conduct. By participating, you are expected to uphold this code. Please report unacceptable behavior to [email protected].

License

The source code for RealmTasks is licensed under the Apache License 2.0.

realm-tasks's People

Contributors

akiniyalocts avatar austinzheng avatar bdash avatar bmunkholm avatar cmelchior avatar dalinaum avatar dan5082 avatar dhmspector avatar emanuelez avatar ericmaxwell2003 avatar icanzilb avatar jpsim avatar kishikawakatsumi avatar kraenhansen avatar kristiandupont avatar nhachicha avatar nirinchev avatar radu-tutueanu avatar stel avatar tgoyne avatar timoliver avatar zaki50 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

realm-tasks's Issues

Support multiple users per server

Right now, the app always connects to private/realmtasks, regardless of device or user. This means that a second user will fail to access their realm due to a permissions error.

Each user should have their own sync URL, which likely means delaying setting the sync URL until we have a user. This is incompatible with how we currently specify the sync URL, not at bind time, but at Realm initialization time.

I think we need to avoid Realm access until after authentication. We'll be able to have a better solution once realm/realm-sync#557 is implemented.

Inserting New Tasks via Sync

When a user swipes downward on the table view to a certain extent, and releases, this gesture triggers the input dialog for a new to-do item. The user is automatically presented with a keyboard in order to input their to-do task, which will be committed when the user taps 'Done'.

The to-do item creation item may be cancelled if the user taps on the table view while the input UI is active, or if they tap 'Done' while the text field is still empty.

To ensure only complete data is submitted to Sync, a new to-do item shouldn't be created in Realm until the user has explicitly entered text into the text field and then tapped 'Done'. At this point, a new Realm object can be created, and added to the Realm, which will then be handed over to Sync.

Due to the design of this app, it can reasonably be assumed that all new items will initially be inserted at the very front of the list of items.

Navigation

We need a way to navigate between parts of the app (e.g. to a "list of lists", #37) and also to a settings screen.

I'm currently working on an approach that uses view controller containment to add top/bottom view controllers when over-scrolling to navigate up & down.

Allow sharing lists with other users

Perhaps using the iOS share sheet? Some design would be needed here to determine how this could be done.

A primitive way to do this would be to have one Realm per list and sharing the Realm sync URL. Then once the permissions system is more complete, proper permissions can be incorporated.

Drag and Drop Slightly Broken

This is a very minor bug, and is probably easily fixed.

When long-pressing and then dragging cells to re-order them, if the cell is released while not over a cell 'slot', then nothing happens. The snapshot simply freezes where released and the real table cell never appears.

simulator screen shot 23 jun 2016 10 27 32 am

Live update title

As of #102 with support for multiple lists, including renaming lists, we should automatically update the top title. Since this isn't a collection notification, I'm thinking we should use KVO for the list's name/text property.

iPad Support

Following on from support for multiple collections, this would also enable a proper display mode for iPad as well:

clear7

Integrate Realm Reactor component

We should be demonstrating the full scope of functionality of sync with this demo, including running custom code on the server to react to sync changes. One idea would be to replicate the realms into a separate database system, like Postgres.

Collections of Items

At present, the app only presents one list of items. An additional step we could take, like the official Clear app is the ability to have multiple collections of items:

img_9242

In order to display this menu, Clear requires the user swipes down on the issue list, to a greater threshold than is required to simply add a new item. This will play a vertical scrolling animation of the collections list coming into view.

Just like items, tapping the text field of cell will let you edit the name, but tapping anywhere else will play another animation as the app drills into that cell's list of items. Each cell can also be swiped, which will either mark all sub-items correct, or delete the entire collection.

Refactor UITableView Interaction for Creating New Issues

At the moment, when the user has sufficiently dragged the table view downwards and releases their finger, it triggers the event to create new to-do item in the list. It does this by creating a new, empty item in Realm, and then performing a manual cell insertion into the UITableView.

While this works functionally, unfortunately, the action of inserting a new cell right after the user releases their finder plays an implicit UITableView animation that looks quite jumpy and doesn't line up with the user's interactions.

Additionally, because this method creates a new entry in Realm ahead of time, this means Sync will also propagate an initially empty to-do object to all of the other devices, which may look rather unpolished.

In order to solve these two problems, I've come up with an alternative implementation:

  • When the user pulls and releases, the edgeInset.top property of the UITableView is modified to create a new block of scrollable space at the top (The space that would have otherwise been filled with a new cell).
  • The placeholder cell (Currently used as the visual cue for how far the user has dragged downwards) then 'pretends' to be the new cell, aligning itself to the top of the scroll content, and providing the text field in which the user can enter their to-do item.
  • Upon completion and the user explicitly ends the input, the new Realm entry/table cell is generated, the placeholder cell is hidden from view, and the top edge inset value is reverted to produce the effect that the placeholder view was committed to the table view.

CloudKit Seamless Authentication Between User Devices

One of the overarching goals of this app is to consider each aspect of the experience from the user's perspective. Obviously, one of the more challenging aspects of Sync is coming up with a pattern where Sync is able to determine all of the devices a user owns (And would like their content sync'd to), with as little interaction on the user's behalf, and certainly avoiding requiring private information (Like email addresses).

In the actual Clear app, activating sync via iCloud is a simple as a single tap in the Settings dialog:
clearsync

This is the bar we should aim for, as anything lower than this would obviously be an inferior experience for the user.

An interesting article discovered by @astigsen shows a really good way of achieving this: https://medium.com/@skreutzb/ios-onboarding-without-signup-screens-cb7a76d01d6e#.rpxuwq3ke

The idea is to use CloudKit as a seamless authentication layer in order to identify users via their iCloud account, but still maintaining a complete level of anonymity without directly requiring their account credentials.

In a nutshell, CloudKit provides each app with a token that is unique for that user and their Apple ID, guaranteed to be the same for the app running on each of their devices.

In this way, it would simply be a matter of requesting this iCloud token on initial launch of the app, and then using it as the user identity value for Realm Sync.

From the user perspective, this would appear completely seamless and automatic.

Editing Items via Sync

After an item has been added, the user may tap on its table cell at any point to bring the text field back up again and edit its contents.

Due to the modal nature of this interaction, it would be acceptable to only update the Realm object (which will trigger Sync) after the user taps 'Done'. If the user deletes all of the text from the text field and taps 'Done', this will delete the object.

When a Sync notification block comes in, it should be possible to use the fine-grained notifications API to refresh the table cell containing this issue on other devices.

AutoLayout warning when swiping cell

Unable to simultaneously satisfy constraints.
    Probably at least one of the constraints in the following list is one you don't want. 
    Try this: 
        (1) look at each constraint and try to figure out which you don't expect; 
        (2) find the code that added the unwanted constraint or constraints and fix it. 
    (Note: If you're seeing NSAutoresizingMaskLayoutConstraints that you don't understand, refer to the documentation for the UIView property translatesAutoresizingMaskIntoConstraints) 
(
    "<NSAutoresizingMaskLayoutConstraint:0x7fe348c07480 h=--& v=--& UIImageView:0x7fe34b0914f0.midX == + 14.5>",
    "<NSAutoresizingMaskLayoutConstraint:0x7fe348c502b0 h=--& v=--& H:[UIImageView:0x7fe34b0914f0(26)]>",
    "<NSLayoutConstraint:0x7fe34b092600 H:|-(8)-[UIImageView:0x7fe34b0914f0](LTR)   (Names: '|':RealmClear.TableViewCell:0x7fe34a07a400'cell' )>",
    "<NSAutoresizingMaskLayoutConstraint:0x7fe34b09f710 h=-&- v=--& 'UIView-Encapsulated-Layout-Left' H:|-(0)-[RealmClear.TableViewCell:0x7fe34a07a400'cell']   (Names: '|':UITableViewWrapperView:0x7fe34a84d800 )>"
)

Will attempt to recover by breaking constraint 
<NSLayoutConstraint:0x7fe34b092600 H:|-(8)-[UIImageView:0x7fe34b0914f0](LTR)   (Names: '|':RealmClear.TableViewCell:0x7fe34a07a400'cell' )>

Make a symbolic breakpoint at UIViewAlertForUnsatisfiableConstraints to catch this in the debugger.
The methods in the UIConstraintBasedLayoutDebugging category on UIView listed in <UIKit/UIView.h> may also be helpful.
2016-06-30 17:44:54.948 RealmClear[13879:213408] Unable to simultaneously satisfy constraints.
    Probably at least one of the constraints in the following list is one you don't want. 
    Try this: 
        (1) look at each constraint and try to figure out which you don't expect; 
        (2) find the code that added the unwanted constraint or constraints and fix it. 
    (Note: If you're seeing NSAutoresizingMaskLayoutConstraints that you don't understand, refer to the documentation for the UIView property translatesAutoresizingMaskIntoConstraints) 
(
    "<NSAutoresizingMaskLayoutConstraint:0x7fe348c4cd70 h=--& v=--& UIImageView:0x7fe34b091af0.midX == + 361>",
    "<NSAutoresizingMaskLayoutConstraint:0x7fe348c40590 h=--& v=--& H:[UIImageView:0x7fe34b091af0(17)]>",
    "<NSLayoutConstraint:0x7fe34b093280 UIImageView:0x7fe34b091af0.right == RealmClear.TableViewCell:0x7fe34a07a400'cell'.right - 12>",
    "<NSAutoresizingMaskLayoutConstraint:0x7fe34b09f710 h=-&- v=--& 'UIView-Encapsulated-Layout-Left' H:|-(0)-[RealmClear.TableViewCell:0x7fe34a07a400'cell']   (Names: '|':UITableViewWrapperView:0x7fe34a84d800 )>",
    "<NSLayoutConstraint:0x7fe34b09f670 'UIView-Encapsulated-Layout-Width' H:[RealmClear.TableViewCell:0x7fe34a07a400'cell'(375)]>"
)

Will attempt to recover by breaking constraint 
<NSLayoutConstraint:0x7fe34b093280 UIImageView:0x7fe34b091af0.right == RealmClear.TableViewCell:0x7fe34a07a400'cell'.right - 12>

Make a symbolic breakpoint at UIViewAlertForUnsatisfiableConstraints to catch this in the debugger.
The methods in the UIConstraintBasedLayoutDebugging category on UIView listed in <UIKit/UIView.h> may also be helpful.

Linker warning

ld: warning: directory not found for option '-F/Users/jp/Projects/RealmClear/Pods/Realm/ios/static/xcode-7'

image

Probably an issue with the private podspec.

Integrate Realm Sync CocoaPods with Project

At the moment, the project is pulling in the public version of Realm Swift via Carthage.

Thanks to the work on the Browser and the sync team, we've got a private CocoaPods infrastructure in place in order to serve builds of Realm Sync as CocoaPods dependencies.

We'll need to remove the Carthage dependency and replace it with our private CocoaPods in order to get Sync integrated with it. :)

Use same development team for both targets

The macOS target uses the QX5CR2FTN2 development team, whereas the iOS target uses 57LMAT5XPH. I don't know where the iOS one comes from, I don't have it locally on my machine, but I do have the macOS one.

One of these is right, the other is wrong. @TimOliver where'd you get 57LMAT5XPH? What team is that?

Support task list sharing via server-side event handling

Realm Object Server supports event-handling on the server-side to listen for changes to Realms (https://github.com/realm/realm-sync-beta/tree/master/event-handling). A great way to showcase this would be to build in support for sharing task lists. There are more advanced ways to do this, but the simplest way would be:

  1. Have a public Realm accessible to all RealmTasks users that contain a list of all the users, most importantly making the Realm user IDs available to the clients (in the advanced scenario this wouldn't be exposed to all clients, but there would be a server-side API to search for users, or the app would support emailing an address where the recipient would have to click the email to confirm the share).
  2. A share button is added to the task list view, which allows the user to select a Realm user from the list of users in the Realm provided above
  3. Each client would have another Realm to save "Share Actions". This Realm would be used to post an object that identifies the URL of the Realm being shared by a user and the Realm user ID of the recipient (the action above would create this object)
  4. A server-side event-handler would then listen to all "Share Action" Realms for all users. When a new object is added that is requesting to share a Realm, the handler would use the Realm user ID to adjust the permissions of the recipient in the admin.realm so that it now has access. The server-side handler would then create a "Share Action" object in the recipients "Share Action" Realm that notifies the user a new Realm has been shown
  5. The recipients app would then react to the new "Share Action" to connect to the shared Realm and display the shared task list.

While this basic version wouldn't be ideal for an app released in production, it would be sufficient to act as a great tutorial to show how to use the server-side event handling. Given that we want to use RealmTasks as the base level "Getting Started" and the "Getting Started With Sync Code" this is then a logical tutorial extension.

3D Transform Effect for Placeholder Cell

While simply changing the opacity will be sufficient during development, ideally, the placeholder cell will present itself onscreen with a 3D perspective transform effect.

Reconciling changes performed locally and remotely

At the moment, both local user changes and remote sync changes both trigger the same UI updates via the fine-grained notifications API.

While this approach works great with changes propagated from sync, responding to user interactions in this way is not great, and it would be more appropriate to directly control the UITableView's updates when local changes are occurring.

Unfortunately, it's not simply a matter of including the appropriate UI update code right after the Realm write transaction, as calling the same insertion/deletion methods on a UITableView more than once will cause an inconsistency exception to be thrown.

The ideal solution to this would be to have an option to temporarily disable fine-grained notifications while manually performing a UI update, and while that is definitely planned, it's not going to be available for this demo app.

There have been several options for workarounds we could use for this demo:

  1. Write a device identifier as the β€œlast” UI-driven modifier, so that changes are only ignored on that device and not on others (e.g. those changes coming in over sync)
  2. Hold a write transaction open for the duration of the user interaction plus following animations

Personally, I think option 1 is the best choice as it lets us determine where the change came from, and selectively avoid calling local UITableView methods twice by accident. It also means we won't be potentially blocking any actual changes coming from Sync at the same time.

To do this effectively, it'll probably mean each todo item will need to keep a copy of the device identifier, and each one will need to be manually checked inside the change notification block.

This is by far the most important issue in this app that we need to have working properly for Friday's deadline.

Re-ordering Items Via Sync

At any point, the user may long-press a cell and then drag it around to re-order the table view. In the current Realm logic model, ToDoList.items is then updated to match the new ordering of the issues.

Ideally, the index changes should be available through Sync via the fine-grained notifications API and an equivalent re-ordering animation can be played on the other devices.

Writing items spanning multiple lines is glitchy

An error is occurring when adding text to items that is sufficiently long to force it to wrap to the next line.
When doing this, the table will suddenly scroll downwards, leaving a black gap along the top.

simulator screen shot 5 jul 2016 8 02 52 pm

When this is committed, the cell and scroll positions correct themselves; this issue is only while the item is initially being added.

Getting Started With Sync Code Tutorial

We are designing RealmTasks to be the "Getting Started" experience, or rather the first 5 minutes to Wow!. However, because we are making it so easy to start the server, then run RealmTasks locally on the Mac alongside the browser, there isn't any actual exposure to code.

I would like to suggest we build a basic code tutorial that shows how to create a very simplified version of RealmTasks which is just a standard tableview and uses an AlertView for input (similar to https://github.com/realm/RealmToDo) but shares the same data model. This way the user can then quickly build a working task app that would sync with the Mac version of RealmTasks.

Thoughts? cc @jpsim @TimOliver @stel

Assertion failure when following instructions in TUTORIAL.md

When following the instructions exactly from TUTORIAL.md, I get the follow log output and assertion failure:

2016-07-20 10:01:19.384 RealmTasks[70894:2971954] RealmSync: Opening Realm file: /Users/jp/Library/Developer/CoreSimulator/Devices/F7798F26-0DFF-441B-AC21-4456220EC9B2/data/Containers/Data/Application/F2E81575-8938-4E3C-B0E6-53720EE6C6A4/Documents/default.realm
2016-07-20 10:01:19.388 RealmTasks[70894:2971954] RealmSync: Connection[1]: Session[1]: Starting session for '/Users/jp/Library/Developer/CoreSimulator/Devices/F7798F26-0DFF-441B-AC21-4456220EC9B2/data/Containers/Data/Application/F2E81575-8938-4E3C-B0E6-53720EE6C6A4/Documents/default.realm'
2016-07-20 10:01:19.389 RealmTasks[70894:2971954] RealmSync: Connection[1]: Connected to '127.0.0.1:7800'
2016-07-20 10:01:19.390 RealmTasks[70894:2971954] RealmSync: Connection[1]: Sending: CLIENT(protocol_version=8, client_info_size=2)
2016-07-20 10:01:19.393 RealmTasks[70894:2971954] RealmSync: Connection[1]: Session[1]: Sending: BIND(server_path='/realmtasks', signed_user_token_size=501, need_file_ident_pair=1)
2016-07-20 10:01:19.426 RealmTasks[70894:2971954] RealmSync: Connection[1]: Session[1]: Received: ALLOC(server_file_ident=3007485835699964852, client_file_ident=1, client_file_ident_secret=4233277764432629199)
2016-07-20 10:01:19.427 RealmTasks[70894:2971954] RealmSync: Using already open Realm file: /Users/jp/Library/Developer/CoreSimulator/Devices/F7798F26-0DFF-441B-AC21-4456220EC9B2/data/Containers/Data/Application/F2E81575-8938-4E3C-B0E6-53720EE6C6A4/Documents/default.realm
sync/history.cpp:585: [realm-core-1.3.0] Assertion failed: m_top->size() == s_top_num_slots
0   Realm                               0x000000010aa5a778 _ZN5realm4utilL18terminate_internalERNSt3__118basic_stringstreamIcNS1_11char_traitsIcEENS1_9allocatorIcEEEE + 40
1   Realm                               0x000000010aa5aa7a _ZN5realm4util9terminateEPKcS2_lOSt16initializer_listINS0_9PrintableEE + 506
2   Realm                               0x000000010aa3a264 _ZNK12_GLOBAL__N_111HistoryImpl15update_from_refEmy + 3332
3   Realm                               0x000000010aa37d88 _ZN12_GLOBAL__N_111HistoryImpl19set_file_ident_pairEyyx + 168
4   Realm                               0x000000010aa47c50 _ZNSt3__110__function6__funcIZN12_GLOBAL__N_110Connection18initiate_read_headEvEUlNS_10error_codeEmE_NS_9allocatorIS5_EEFvS4_mEEclEOS4_Om + 6000
5   Realm                               0x000000010aa63c26 _ZN5realm4util15call_with_tupleINSt3__18functionIFvNS2_10error_codeEmEEEJS4_mEEEDTclsr5_implE15call_with_tupleclsr3stdE4movefp_Eclsr3stdE4movefp0_EcvNS_5_impl10GenIndexesIXsZT0_EJEE4typeE_EEET_NS2_5tupleIJDpT0_EEE + 134
6   Realm                               0x000000010aa63a85 _ZN5realm4util7network10io_service10async_oper22do_recycle_and_executeINSt3__18functionIFvNS5_10error_codeEmEEEJRS7_RmEEEvbRT_DpOT0_ + 357
7   Realm                               0x000000010aa63811 _ZN5realm4util7network21buffered_input_stream9read_operINSt3__18functionIFvNS4_10error_codeEmEEEE19recycle_and_executeEv + 209
8   Realm                               0x000000010aa5db76 _ZN5realm4util7network10io_service4impl3runEv + 310
9   Realm                               0x000000010aa3cb8c _ZN5realm4sync6Client3runEv + 236
10  Realm                               0x000000010a94acbe _ZNSt3__114__thread_proxyINS_5tupleIJZN5realm5_impl10SyncClientC1ENS2_4sync6ClientEEUlvE_EEEEEPvS9_ + 61
11  libsystem_pthread.dylib             0x000000010f6d499d _pthread_body + 131
12  libsystem_pthread.dylib             0x000000010f6d491a _pthread_body + 0
13  libsystem_pthread.dylib             0x000000010f6d2351 thread_start + 13
IMPORTANT: if you see this error, please send this log to [email protected].(lldb) 

Accompanying server log:

Opening Realm: /Users/jp/Library/Containers/io.realm.realm-sync-server/Data/Library/Application Support/io.realm.realm-sync-server/permissions.realm (/permissions)
Realm sync server started ([realm-core-1.3.0], [realm-sync-0.24.1])
Listening on 127.0.0.1:7800 (sync protocol version 8)
Connection[1]: Connection from 127.0.0.1:64492
Connection[1]: Received: CLIENT(protocol_version=8, client_info_size=2)
Connection[1]: Session[1]: Initiated
Connection[1]: Session[1]: Received: BIND(server_path='/realmtasks', signed_user_token=ewogICJhY2Nlc3MiIDog..., need_file_ident_pair=1)
Opening Realm: /Users/jp/Library/Containers/io.realm.realm-sync-server/Data/Library/Application Support/io.realm.realm-sync-server/realmtasks.realm (/realmtasks)
Connection[1]: Session[1]: Sending: ALLOC(server_file_ident=3007485835699964852, client_file_ident=1, client_file_ident_secret=4233277764432629199)
Connection[1]: Session[1]: Terminated
Connection[1]: Connection closed by client: End of input

Separate ViewController into multiple files

After #102, ViewController.swift is close to 800 lines 😱. There's a lot we can do to refactor this:

  1. Encapsulate navigation logic & animations into the ContainerViewController
  2. Move ContainerViewController to its own file (ok, slightly unrelated to ViewController.swift)
  3. Encapsulate UITableView's KVO'd contentView into its own class or file (or replace this approach with a nicer one)
  4. Look into encapsulating basically every MARK section into a separate file. This won't be possible for all of them, but should be possible for several.

Sync Integration

The use case scenario for Sync we're envisioning for this app is the same one as the official Clear app:

A user has downloaded the app onto their multiple iOS devices, and would like to ensure that any changes they perform on any device will be instantly updated to every other device.

The latest release of Realm Swift with Sync available from Realm's private CocoaPods repo will be the one used for this project.

Integrating Sync itself for this project should be relatively trivial. The app itself is simply a UITableView interface, so as long as Sync changes are exposed via the fine-grained notifications API, it should be a matter of simply joining the two inside the notification block.

For authentication, at the very beginning (and for testing purposes), one shared Sync session should be suitable. Down the line, we can start looking at ways to invisibly identity discrete users, using methods such as the user's iCloud ID token.

Change events would be responsible for:

  • A new task is created and inserted from scratch (#11)
  • An existing task's text is edited. (#12)
  • The sort order of the tasks is changed. (#13)
  • A task is deleted. (#14)

Deleting Items Via Sync

There are 3 ways an item may be deleted:

  1. The user marks the item completed, and then swipes upwards on the table to delete all completed items.
  2. The user swipes the item's table cell to the right, deleting it instantly.
  3. The user edits the item, clears all of its text, and then taps 'Done'.

When an item is deleted, it is immediately deleted from Realm as well. This will trigger a Sync notification block on the other devices so they may also remove it from their UIs. The block will provide the index of the item being deleted, which can simply be forwarded to the UITableView API for removing cells.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.