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
| const val LIST = "list" | |
| const val OTHER = "other" | |
| class MainActivity : AppCompatActivity() { | |
| override fun onCreate(savedInstanceState: Bundle?) { | |
| super.onCreate(savedInstanceState) | |
| setContent { | |
| val navController = rememberNavController() | |
| ComposeSampleTheme { | |
| Scaffold( |
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 ComposableArchitecture | |
| import SwiftUI | |
| struct ContentView: View { | |
| let store: StoreOf<TodoReducer> | |
| var body: some View { | |
| VStack { | |
| Button("Change state to error") { | |
| store.send(.setLoadedState(.failure(FeatureError.unknown))) |
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 re | |
| # Define the file paths | |
| sql_file_path = "" | |
| kotlin_file_path = "" | |
| # Read the SQLDelight file | |
| with open(sql_file_path, 'r') as file: | |
| sql_file_content = file.read() |
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
| // Dagger | |
| interface Authenticator | |
| class RealAuthenticator @Inject constructor() : Authenticator | |
| @Module | |
| @ContributesTo(AppScope::class) | |
| abstract class AuthenticatorModule { | |
| @Binds abstract fun bindRealAuthenticator(authenticator: RealAuthenticator): Authenticator | |
| } |
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
| struct MoviesListScreenView: View { | |
| @State var state: MoviesState = MoviesState(movies: [], selectedMovie: nil) | |
| let viewModel = MoviesViewModel() | |
| var body: some View { | |
| List() { | |
| ForEach(state.movies, id: \.self) { movie in | |
| MovieView(movie, ...) | |
| } | |
| } |
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 MoviesFragment : Fragment() { | |
| private val viewModel: MoviesViewModel by activityViewModels {...} | |
| override fun onCreateView(inflater: LayoutInflater): View = ComposeView(inflater.context).apply { | |
| layoutParams = ... | |
| setContent { | |
| val state by viewModel.observeState().collectAsState() | |
| MoviesListView(state = state, onMovieSelected = { movie -> |
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 FlowWrapper<T>(private val source: Flow<T>) : Flow<T> by source { | |
| init { | |
| freeze() | |
| } | |
| fun collect(onEach: (T) -> Unit, onCompletion: (cause: Throwable?) -> Unit): Cancellable { | |
| val scope = CoroutineScope(SupervisorJob() + Dispatchers.Main) | |
| scope.launch { | |
| try { |
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 MoviesViewModel : | |
| ArchViewModel<MoviesActions, MoviesState, MoviesEffects, MovieEvents, Nothing>( | |
| updater = MoviesUpdater(), | |
| initialState = MoviesState(), | |
| initialEffects = setOf(MoviesEffects.LoadMovies()), | |
| processor = MoviesProcessor(threadInfo), | |
| ) { | |
| } |
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 MoviesProcessor() : Processor<MoviesEffects, MoviesActions> { | |
| private val api : TMDApi = TMDApi() | |
| override suspend fun dispatchSideEffect(effect: MoviesEffects): MoviesActions { | |
| return when(effect){ | |
| is MoviesEffects.LoadMovies -> getMovies(effect) | |
| } | |
| } |
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
| typealias NextResult = Next<MoviesState, MoviesEffects, MovieEvents> | |
| class MoviesUpdater : Updater<MoviesActions, MoviesState, MoviesEffects, MovieEvents> { | |
| override fun onNewAction( | |
| action: MoviesActions, | |
| currentState: MoviesState | |
| ): Next<MoviesState, MoviesEffects, MovieEvents> { | |
| return when (action) { | |
| is MoviesActions.FetchMovies -> fetchMovies(action, currentState) | |
| is MoviesActions.SaveMovies -> saveMovies(action, currentState) |
NewerOlder