This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package com.raywenderlich.android.creatures.data | |
| class CreatureDataRepository @Inject constructor(private val factory: CreatureDataStoreFactory, | |
| private val creatureMapper: CreatureMapper) : CreatureRepository { | |
| override fun clearCreatures(): Completable { | |
| return factory.retrieveCacheDataStore().clearCreatures() | |
| } | |
| override fun saveCreatures(creatures: List<Creature>): Completable { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package com.raywenderlich.android.creatures.ui.injection.module | |
| /** | |
| * Module used to provide dependencies at an activity-level. | |
| */ | |
| @Module | |
| open class BrowseActivityModule { | |
| @Provides | |
| fun provideBrowseCreaturesViewModelFactory(getCreatures: GetCreatures, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import UIKit | |
| protocol AddTodoItemDelegate: class { | |
| func addItemViewControllerDidCancel(_ controller: AddTodoItemTableViewController) | |
| func addItemViewController(_ controller: AddTodoItemTableViewController, didFinishAdding item: TodoItem) | |
| func addItemViewController(_ controller: AddTodoItemTableViewController, didFinishEditing item: TodoItem) | |
| } | |
| class AddTodoItemTableViewController: UITableViewController { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| @immutable | |
| class EmotionAppState { | |
| final bool isDatabaseOpen; | |
| final String emoji; | |
| final String emotion; | |
| final List<SavedDetail> details; | |
| final int index; | |
| final bool loadComplete; | |
| EmotionAppState( |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| dependencies: | |
| redux: ^3.0.0 | |
| flutter_redux: ^0.5.2 | |
| flutter_redux_navigation: ^0.4.1 | |
| rxdart: ^0.20.0 | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class MyApp extends StatefulWidget { | |
| final Store<EmotionAppState> store = new Store<EmotionAppState>( | |
| emotionAppReducer, | |
| initialState: EmotionAppState(isDatabaseOpen: false, loadComplete: false), | |
| middleware: createLoginMiddleware(DataProviderImplementation()), | |
| ); | |
| _MyAppState createState() => _MyAppState(); | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class _MyAppState extends State<MyApp> { | |
| @override | |
| Widget build(BuildContext context) { | |
| //... | |
| child: MaterialApp( | |
| navigatorKey: NavigatorHolder.navigatorKey, | |
| home: MyHomePage(), | |
| routes: { | |
| '/all-emotions': (BuildContext context) => MyHomePage(), | |
| '/list-emotions': (BuildContext context) => EmotionsList(), |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| List<Middleware<EmotionAppState>> createLoginMiddleware( | |
| [DataProvider provider]) { | |
| //... | |
| return [ | |
| //... | |
| NavigationMiddleware<EmotionAppState>() | |
| ]; | |
| } | |
| //... | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class _ViewModel { | |
| final Store<EmotionAppState> store; | |
| const _ViewModel({this.store}); | |
| static _ViewModel fromStore(Store<EmotionAppState> store) { | |
| return _ViewModel(store: store); | |
| } | |
| void addNewEmotion() { | |
| store.dispatch(NavigateToAction.push('/list-emotions')); | |
| } | |
| //... |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class _ViewModel { | |
| final Store<EmotionAppState> store; | |
| const _ViewModel({this.store}); | |
| static _ViewModel fromStore(Store<EmotionAppState> store) { | |
| return _ViewModel(store: store); | |
| } | |
| void addEmotionDescription(String emotionType, String emotionDescription) { | |
| //... | |
| store.dispatch(NavigateToCreateEmotion( | |
| emoji: emotionType, emotion: emotionDescription)); |