You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
A Kotlin multiplatform (Android/iOS) WT name game. Player is shown a picture and must guess the name. User can select from Cats, Dogs, or Trees! (aka Willowtree employees). The app utilizes the following:
12
+
A Kotlin multiplatform (Android/iOS) name game. Player is shown a picture of a cat or dog and must guess the name. User can select from Cats, Dogs. The app utilizes the following:
13
13
*[Ktor](https://ktor.io/clients/http-client.html) for networking
Building and testing the Android App can be completed with:
@@ -30,13 +29,7 @@ The iOS workspace in `/iOS/NameGame` can be open and ran from xCode or AppCode.
30
29
31
30
## Architecture
32
31
33
-
A `GameEngine` object holds the state of the app in a redux store and provides a methods for views (fragments/UIViewControllers) to "attach". The `GameEngine` is initialized in the Application class on Android, and the AppDelegate on iOS. Because this `GameEngine` and the store is created at the application scope, the application state survives between ViewControllers/Fragments and rotation. Each view must attach/detach from the GameEngine when it is visible. `GameEngine.attachView(view)` returns the appropriate presenter for the view.
34
-
35
-
`BaseNameGameViewFragment` & `BaseNameGameViewController` handle attaching/detaching the presenter at the appropriate lifecycle methods. Each Fragment/ViewController extends from these.
36
-
37
-
An MVP arch is used with a redux store as the 'Model'. This approach allows maximum reuse of code and a simple contract for the platforms to satisfy. Presenters send `ViewStates` (simple data classes with fields needed to render UI) to the View interface. The View implementation has a reference to the presenter, and calls methods on the presetner for user interaction. This creates a unidirectional dataflow:
38
-
39
-
User interaction -> Dispatch Action -> new state (reduce) -> view rendered by presenter
32
+
More to come
40
33
41
34
## "Dumb Views"
42
35
Views in this arch are truely 'dumb' - they should contain nearly no logic. They are responsible for rendering the view based on the `ViewState` given to them by the presenter. They are implemented for each platform and utilize native UI SDKs and libs for each platform. Android uses Fragments and iOS uses UIViewControllers.
@@ -45,9 +38,7 @@ Views in this arch are truely 'dumb' - they should contain nearly no logic. The
Presenters give a layer of control between subscribing to the new state and the View. Views subscribing directly to the store results in code and logic in the View which must be duplicated on each platform. Presenters are singleton objects that contain no state other than the previous AppState. This works while presenters are for an entire screen, which for this app is the case. Another approach will be needed if multiple instances of a given presenter are needed. The presenter is responsible for rendering the view given the AppState or the delta in AppState. The Reduks library has a port of Reselect, which allows calling code only when a property changes. Presenters pass `ViewState` to View methods. All transformations from Appstate -> ViewState are extension functions in `Transformations.kt`.
0 commit comments