View flutter_bloc_5.dart
import 'package:flutter/material.dart'; | |
import 'package:states_bloc/drawer_menu.dart'; | |
import 'package:states_bloc/bloc/settings/settings_bloc.dart'; | |
import 'package:flutter_bloc/flutter_bloc.dart'; | |
class Settings extends StatelessWidget { | |
double _value = 0.5; | |
bool isBold = false; | |
bool isItalic = false; | |
@override |
View flutter_bloc_4.dart
import 'package:flutter/material.dart'; | |
import 'package:states_bloc/home.dart'; | |
import 'package:states_bloc/about.dart'; | |
import 'package:states_bloc/settings.dart'; | |
import 'package:flutter_bloc/flutter_bloc.dart'; | |
import 'package:states_bloc/bloc/settings/settings_bloc.dart'; | |
void main() { | |
final BlocProvider<SettingsBloc> blocProvider = BlocProvider<SettingsBloc>( | |
builder: (_) => SettingsBloc(), |
View flutter_bloc_3.dart
import 'dart:async'; | |
import 'package:bloc/bloc.dart'; | |
import 'package:meta/meta.dart'; | |
part 'settings_event.dart'; | |
part 'settings_state.dart'; | |
class SettingsBloc extends Bloc<SettingsEvent, SettingsState> { | |
@override | |
SettingsState get initialState => InitialSettingsState(); |
View flutter_bloc_2.dart
part of 'settings_bloc.dart'; | |
@immutable | |
abstract class SettingsState { | |
final double sliderFontSize; | |
final bool isBold; | |
final bool isItalic; | |
SettingsState({this.sliderFontSize, this.isBold, this.isItalic}); | |
double get fontSize => sliderFontSize * 30; | |
} |
View flutter_bloc_1.dart
part of 'settings_bloc.dart'; | |
@immutable | |
abstract class SettingsEvent { | |
final dynamic payload; | |
SettingsEvent(this.payload); | |
} | |
class FontSize extends SettingsEvent { | |
FontSize(double payload) : super(payload); |
View ContentView.swift
// MARK:- View 2 | |
struct View2: View { | |
@EnvironmentObject var appState: AppState | |
var body: some View { | |
VStack { | |
Text("View 2") | |
.font(.headline) | |
Button(action: { | |
// FIXME:- add move to dashboard functionality |
View SceneDelegate.swift
var window: UIWindow? | |
var contentView: ContentView? | |
var appState: AppState? | |
func scene(_ scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions) { | |
if let windowScene = scene as? UIWindowScene { | |
let window = UIWindow(windowScene: windowScene) | |
self.window = window | |
reloadDashboard() | |
} |
View AppState.swift
import SwiftUI | |
import Combine | |
class AppState: ObservableObject { | |
func reloadDashboard() { | |
(UIApplication.shared.connectedScenes.first?.delegate as? SceneDelegate)?.reloadDashboard() | |
} | |
} |
View ContentView.swift
import SwiftUI | |
struct ContentView: View { | |
@EnvironmentObject var appState: AppState | |
var body: some View { | |
NavigationView { | |
VStack { | |
// TabView1() | |
tabsView |
NewerOlder