mirror of
https://github.com/AppFlowy-IO/AppFlowy.git
synced 2024-08-30 18:12:39 +00:00
[flutter]: add flow diagrams
This commit is contained in:
parent
1a10f58e6f
commit
9ddfed5b87
@ -1,19 +0,0 @@
|
|||||||
import 'package:app_flowy/workspace/infrastructure/deps_resolver.dart';
|
|
||||||
import 'package:app_flowy/startup/launch.dart';
|
|
||||||
import 'package:app_flowy/startup/startup.dart';
|
|
||||||
import 'package:app_flowy/user/infrastructure/deps_resolver.dart';
|
|
||||||
import 'package:flowy_sdk/flowy_sdk.dart';
|
|
||||||
import 'package:get_it/get_it.dart';
|
|
||||||
|
|
||||||
void resolveDependencies(IntegrationEnv env) => initGetIt(getIt, env);
|
|
||||||
|
|
||||||
Future<void> initGetIt(
|
|
||||||
GetIt getIt,
|
|
||||||
IntegrationEnv env,
|
|
||||||
) async {
|
|
||||||
getIt.registerLazySingleton<FlowySDK>(() => const FlowySDK());
|
|
||||||
getIt.registerLazySingleton<AppLauncher>(() => AppLauncher(env, getIt));
|
|
||||||
|
|
||||||
await UserDepsResolver.resolve(getIt);
|
|
||||||
await HomeDepsResolver.resolve(getIt);
|
|
||||||
}
|
|
@ -1,9 +1,28 @@
|
|||||||
import 'package:app_flowy/startup/launch.dart';
|
import 'package:app_flowy/startup/launcher.dart';
|
||||||
import 'package:app_flowy/startup/tasks/prelude.dart';
|
import 'package:app_flowy/startup/tasks/prelude.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:get_it/get_it.dart';
|
import 'package:get_it/get_it.dart';
|
||||||
import 'deps_inject/prelude.dart';
|
import 'package:app_flowy/workspace/infrastructure/deps_resolver.dart';
|
||||||
|
import 'package:app_flowy/user/infrastructure/deps_resolver.dart';
|
||||||
|
import 'package:flowy_sdk/flowy_sdk.dart';
|
||||||
|
|
||||||
|
// [[diagram: flowy startup flow]]
|
||||||
|
// ┌──────────┐
|
||||||
|
// │ FlowyApp │
|
||||||
|
// └──────────┘
|
||||||
|
// │ impl
|
||||||
|
// ▼
|
||||||
|
// ┌────────┐ 1.run ┌──────────┐
|
||||||
|
// │ System │───┬───▶│EntryPoint│
|
||||||
|
// └────────┘ │ └──────────┘ ┌─────────────────┐
|
||||||
|
// │ ┌──▶ │ RustSDKInitTask │
|
||||||
|
// │ ┌───────────┐ │ └─────────────────┘
|
||||||
|
// └──▶ │AppLauncher│───┤
|
||||||
|
// 2.launch └───────────┘ │ ┌─────────────┐ ┌──────────────────┐ ┌───────────────┐
|
||||||
|
// └───▶│AppWidgetTask│────────▶│ApplicationWidget │─────▶│ SplashScreen │
|
||||||
|
// └─────────────┘ └──────────────────┘ └───────────────┘
|
||||||
|
//
|
||||||
|
// 3.build MeterialApp
|
||||||
final getIt = GetIt.instance;
|
final getIt = GetIt.instance;
|
||||||
enum IntegrationEnv {
|
enum IntegrationEnv {
|
||||||
dev,
|
dev,
|
||||||
@ -32,3 +51,16 @@ class System {
|
|||||||
getIt<AppLauncher>().launch();
|
getIt<AppLauncher>().launch();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void resolveDependencies(IntegrationEnv env) => initGetIt(getIt, env);
|
||||||
|
|
||||||
|
Future<void> initGetIt(
|
||||||
|
GetIt getIt,
|
||||||
|
IntegrationEnv env,
|
||||||
|
) async {
|
||||||
|
getIt.registerLazySingleton<FlowySDK>(() => const FlowySDK());
|
||||||
|
getIt.registerLazySingleton<AppLauncher>(() => AppLauncher(env, getIt));
|
||||||
|
|
||||||
|
await UserDepsResolver.resolve(getIt);
|
||||||
|
await HomeDepsResolver.resolve(getIt);
|
||||||
|
}
|
||||||
|
@ -4,7 +4,7 @@ import 'package:flowy_infra_ui/flowy_infra_ui.dart';
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:provider/provider.dart';
|
import 'package:provider/provider.dart';
|
||||||
import 'package:window_size/window_size.dart';
|
import 'package:window_size/window_size.dart';
|
||||||
import 'package:app_flowy/startup/launch.dart';
|
import 'package:app_flowy/startup/launcher.dart';
|
||||||
|
|
||||||
class AppWidgetTask extends LaunchTask {
|
class AppWidgetTask extends LaunchTask {
|
||||||
@override
|
@override
|
||||||
@ -30,8 +30,10 @@ class ApplicationWidget extends StatelessWidget {
|
|||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
const ratio = 1.73;
|
const ratio = 1.73;
|
||||||
setWindowMinSize(const Size(500, 500 / ratio));
|
const minWidth = 500.0;
|
||||||
setWindowFrame(const Rect.fromLTRB(0, 0, 1310, 1310 / ratio));
|
const launchWidth = 1310.0;
|
||||||
|
setWindowMinSize(const Size(minWidth, minWidth / ratio));
|
||||||
|
setWindowFrame(const Rect.fromLTRB(0, 0, launchWidth, launchWidth / ratio));
|
||||||
|
|
||||||
final theme = AppTheme.fromType(ThemeType.light);
|
final theme = AppTheme.fromType(ThemeType.light);
|
||||||
return Provider.value(
|
return Provider.value(
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
import 'dart:io';
|
import 'dart:io';
|
||||||
import 'package:app_flowy/startup/launch.dart';
|
import 'package:app_flowy/startup/launcher.dart';
|
||||||
import 'package:app_flowy/startup/startup.dart';
|
import 'package:app_flowy/startup/startup.dart';
|
||||||
import 'package:bloc/bloc.dart';
|
import 'package:bloc/bloc.dart';
|
||||||
import 'package:path_provider/path_provider.dart';
|
import 'package:path_provider/path_provider.dart';
|
||||||
@ -20,9 +20,7 @@ class RustSDKInitTask extends LaunchTask {
|
|||||||
Directory directory = await getApplicationDocumentsDirectory();
|
Directory directory = await getApplicationDocumentsDirectory();
|
||||||
final documentPath = directory.path;
|
final documentPath = directory.path;
|
||||||
|
|
||||||
return Directory('$documentPath/flowy')
|
return Directory('$documentPath/flowy').create().then((Directory directory) async {
|
||||||
.create()
|
|
||||||
.then((Directory directory) async {
|
|
||||||
switch (context.env) {
|
switch (context.env) {
|
||||||
case IntegrationEnv.dev:
|
case IntegrationEnv.dev:
|
||||||
// await context.getIt<FlowySDK>().init(Directory('./temp/flowy_dev'));
|
// await context.getIt<FlowySDK>().init(Directory('./temp/flowy_dev'));
|
||||||
@ -42,8 +40,7 @@ class ApplicationBlocObserver extends BlocObserver {
|
|||||||
@override
|
@override
|
||||||
// ignore: unnecessary_overrides
|
// ignore: unnecessary_overrides
|
||||||
void onTransition(Bloc bloc, Transition transition) {
|
void onTransition(Bloc bloc, Transition transition) {
|
||||||
Log.debug(
|
Log.debug("[current]: ${transition.currentState} \n[next]: ${transition.nextState}");
|
||||||
"[current]: ${transition.currentState} \n[next]: ${transition.nextState}");
|
|
||||||
super.onTransition(bloc, transition);
|
super.onTransition(bloc, transition);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -8,7 +8,7 @@ import 'package:app_flowy/user/infrastructure/i_auth_impl.dart';
|
|||||||
import 'package:app_flowy/user/infrastructure/i_splash_impl.dart';
|
import 'package:app_flowy/user/infrastructure/i_splash_impl.dart';
|
||||||
import 'package:app_flowy/workspace/application/edit_pannel/edit_pannel_bloc.dart';
|
import 'package:app_flowy/workspace/application/edit_pannel/edit_pannel_bloc.dart';
|
||||||
import 'package:app_flowy/workspace/application/home/home_bloc.dart';
|
import 'package:app_flowy/workspace/application/home/home_bloc.dart';
|
||||||
import 'package:app_flowy/workspace/application/home/home_auth_bloc.dart';
|
import 'package:app_flowy/workspace/application/home/home_listen_bloc.dart';
|
||||||
import 'package:app_flowy/workspace/domain/i_user.dart';
|
import 'package:app_flowy/workspace/domain/i_user.dart';
|
||||||
import 'package:app_flowy/workspace/infrastructure/i_user_impl.dart';
|
import 'package:app_flowy/workspace/infrastructure/i_user_impl.dart';
|
||||||
import 'package:get_it/get_it.dart';
|
import 'package:get_it/get_it.dart';
|
||||||
@ -31,9 +31,9 @@ class UserDepsResolver {
|
|||||||
getIt.registerFactory<EditPannelBloc>(() => EditPannelBloc());
|
getIt.registerFactory<EditPannelBloc>(() => EditPannelBloc());
|
||||||
getIt.registerFactory<SplashBloc>(() => SplashBloc(getIt<ISplashUser>()));
|
getIt.registerFactory<SplashBloc>(() => SplashBloc(getIt<ISplashUser>()));
|
||||||
|
|
||||||
getIt.registerFactoryParam<HomeAuthBloc, UserProfile, void>(
|
getIt.registerFactoryParam<HomeListenBloc, UserProfile, void>(
|
||||||
(user, _) => HomeAuthBloc(
|
(user, _) => HomeListenBloc(
|
||||||
getIt<IUserWatch>(param1: user),
|
getIt<IUserListener>(param1: user),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -8,6 +8,16 @@ import 'package:flutter/material.dart';
|
|||||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||||
import 'package:flowy_sdk/protobuf/flowy-workspace/errors.pb.dart' as workspace;
|
import 'package:flowy_sdk/protobuf/flowy-workspace/errors.pb.dart' as workspace;
|
||||||
|
|
||||||
|
// [[diagram: splash screen]]
|
||||||
|
// ┌────────────────┐1.get user ┌──────────┐ ┌────────────┐ 2.send UserEventCheckUser
|
||||||
|
// │ SplashScreen │──────────▶│SplashBloc│────▶│ISplashUser │─────┐
|
||||||
|
// └────────────────┘ └──────────┘ └────────────┘ │
|
||||||
|
// │
|
||||||
|
// ▼
|
||||||
|
// ┌───────────┐ ┌─────────────┐ ┌────────┐
|
||||||
|
// │HomeScreen │◀───────────│BlocListener │◀────────────────│RustSDK │
|
||||||
|
// └───────────┘ └─────────────┘ └────────┘
|
||||||
|
// 4. Show HomeScreen or SignIn 3.return AuthState
|
||||||
class SplashScreen extends StatelessWidget {
|
class SplashScreen extends StatelessWidget {
|
||||||
const SplashScreen({Key? key}) : super(key: key);
|
const SplashScreen({Key? key}) : super(key: key);
|
||||||
|
|
||||||
@ -37,8 +47,7 @@ class SplashScreen extends StatelessWidget {
|
|||||||
WorkspaceEventReadCurWorkspace().send().then(
|
WorkspaceEventReadCurWorkspace().send().then(
|
||||||
(result) {
|
(result) {
|
||||||
return result.fold(
|
return result.fold(
|
||||||
(workspace) => getIt<ISplashRoute>()
|
(workspace) => getIt<ISplashRoute>().pushHomeScreen(context, userProfile, workspace.id),
|
||||||
.pushHomeScreen(context, userProfile, workspace.id),
|
|
||||||
(error) async {
|
(error) async {
|
||||||
assert(error.code == workspace.ErrorCode.RecordNotFound);
|
assert(error.code == workspace.ErrorCode.RecordNotFound);
|
||||||
getIt<ISplashRoute>().pushWelcomeScreen(context, userProfile);
|
getIt<ISplashRoute>().pushWelcomeScreen(context, userProfile);
|
||||||
@ -70,8 +79,7 @@ class Body extends StatelessWidget {
|
|||||||
fit: BoxFit.cover,
|
fit: BoxFit.cover,
|
||||||
width: size.width,
|
width: size.width,
|
||||||
height: size.height,
|
height: size.height,
|
||||||
image: const AssetImage(
|
image: const AssetImage('assets/images/appflowy_launch_splash.jpg')),
|
||||||
'assets/images/appflowy_launch_splash.jpg')),
|
|
||||||
const CircularProgressIndicator.adaptive(),
|
const CircularProgressIndicator.adaptive(),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
|
55
app_flowy/lib/workspace/application/app/app_listen_bloc.dart
Normal file
55
app_flowy/lib/workspace/application/app/app_listen_bloc.dart
Normal file
@ -0,0 +1,55 @@
|
|||||||
|
import 'package:app_flowy/workspace/domain/i_app.dart';
|
||||||
|
import 'package:flowy_sdk/protobuf/flowy-workspace/errors.pb.dart';
|
||||||
|
import 'package:flowy_sdk/protobuf/flowy-workspace/view_create.pb.dart';
|
||||||
|
import 'package:freezed_annotation/freezed_annotation.dart';
|
||||||
|
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||||
|
import 'package:dartz/dartz.dart';
|
||||||
|
|
||||||
|
part 'app_listen_bloc.freezed.dart';
|
||||||
|
|
||||||
|
class AppListenBloc extends Bloc<AppListenEvent, AppListenState> {
|
||||||
|
final IAppListenr listener;
|
||||||
|
AppListenBloc(this.listener) : super(const AppListenState.initial());
|
||||||
|
|
||||||
|
@override
|
||||||
|
Stream<AppListenState> mapEventToState(
|
||||||
|
AppListenEvent event,
|
||||||
|
) async* {
|
||||||
|
yield* event.map(started: (_) async* {
|
||||||
|
listener.start(
|
||||||
|
addViewCallback: (viewsOrFail) => _handleViewsOrFail(viewsOrFail),
|
||||||
|
);
|
||||||
|
}, viewsReceived: (ViewsReceived value) async* {
|
||||||
|
yield value.viewsOrFail.fold(
|
||||||
|
(views) => AppListenState.loadViews(views),
|
||||||
|
(error) => AppListenState.loadFail(error),
|
||||||
|
);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
void _handleViewsOrFail(Either<List<View>, WorkspaceError> viewsOrFail) {
|
||||||
|
viewsOrFail.fold(
|
||||||
|
(views) => add(AppListenEvent.viewsReceived(left(views))),
|
||||||
|
(error) => add(AppListenEvent.viewsReceived(right(error))),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@freezed
|
||||||
|
class AppListenEvent with _$AppListenEvent {
|
||||||
|
const factory AppListenEvent.started() = _Started;
|
||||||
|
const factory AppListenEvent.viewsReceived(Either<List<View>, WorkspaceError> viewsOrFail) = ViewsReceived;
|
||||||
|
}
|
||||||
|
|
||||||
|
@freezed
|
||||||
|
class AppListenState with _$AppListenState {
|
||||||
|
const factory AppListenState.initial() = _Initial;
|
||||||
|
|
||||||
|
const factory AppListenState.loadViews(
|
||||||
|
List<View> views,
|
||||||
|
) = _LoadViews;
|
||||||
|
|
||||||
|
const factory AppListenState.loadFail(
|
||||||
|
WorkspaceError error,
|
||||||
|
) = _LoadFail;
|
||||||
|
}
|
@ -1,7 +1,7 @@
|
|||||||
// GENERATED CODE - DO NOT MODIFY BY HAND
|
// GENERATED CODE - DO NOT MODIFY BY HAND
|
||||||
// ignore_for_file: unused_element, deprecated_member_use, deprecated_member_use_from_same_package, use_function_type_syntax_for_parameters, unnecessary_const, avoid_init_to_null, invalid_override_different_default_values_named, prefer_expression_function_bodies, annotate_overrides, invalid_annotation_target
|
// ignore_for_file: unused_element, deprecated_member_use, deprecated_member_use_from_same_package, use_function_type_syntax_for_parameters, unnecessary_const, avoid_init_to_null, invalid_override_different_default_values_named, prefer_expression_function_bodies, annotate_overrides, invalid_annotation_target
|
||||||
|
|
||||||
part of 'app_watch_bloc.dart';
|
part of 'app_listen_bloc.dart';
|
||||||
|
|
||||||
// **************************************************************************
|
// **************************************************************************
|
||||||
// FreezedGenerator
|
// FreezedGenerator
|
||||||
@ -13,8 +13,8 @@ final _privateConstructorUsedError = UnsupportedError(
|
|||||||
'It seems like you constructed your class using `MyClass._()`. This constructor is only meant to be used by freezed and you are not supposed to need it nor use it.\nPlease check the documentation here for more informations: https://github.com/rrousselGit/freezed#custom-getters-and-methods');
|
'It seems like you constructed your class using `MyClass._()`. This constructor is only meant to be used by freezed and you are not supposed to need it nor use it.\nPlease check the documentation here for more informations: https://github.com/rrousselGit/freezed#custom-getters-and-methods');
|
||||||
|
|
||||||
/// @nodoc
|
/// @nodoc
|
||||||
class _$AppWatchEventTearOff {
|
class _$AppListenEventTearOff {
|
||||||
const _$AppWatchEventTearOff();
|
const _$AppListenEventTearOff();
|
||||||
|
|
||||||
_Started started() {
|
_Started started() {
|
||||||
return const _Started();
|
return const _Started();
|
||||||
@ -28,10 +28,10 @@ class _$AppWatchEventTearOff {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// @nodoc
|
/// @nodoc
|
||||||
const $AppWatchEvent = _$AppWatchEventTearOff();
|
const $AppListenEvent = _$AppListenEventTearOff();
|
||||||
|
|
||||||
/// @nodoc
|
/// @nodoc
|
||||||
mixin _$AppWatchEvent {
|
mixin _$AppListenEvent {
|
||||||
@optionalTypeArgs
|
@optionalTypeArgs
|
||||||
TResult when<TResult extends Object?>({
|
TResult when<TResult extends Object?>({
|
||||||
required TResult Function() started,
|
required TResult Function() started,
|
||||||
@ -63,20 +63,20 @@ mixin _$AppWatchEvent {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// @nodoc
|
/// @nodoc
|
||||||
abstract class $AppWatchEventCopyWith<$Res> {
|
abstract class $AppListenEventCopyWith<$Res> {
|
||||||
factory $AppWatchEventCopyWith(
|
factory $AppListenEventCopyWith(
|
||||||
AppWatchEvent value, $Res Function(AppWatchEvent) then) =
|
AppListenEvent value, $Res Function(AppListenEvent) then) =
|
||||||
_$AppWatchEventCopyWithImpl<$Res>;
|
_$AppListenEventCopyWithImpl<$Res>;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// @nodoc
|
/// @nodoc
|
||||||
class _$AppWatchEventCopyWithImpl<$Res>
|
class _$AppListenEventCopyWithImpl<$Res>
|
||||||
implements $AppWatchEventCopyWith<$Res> {
|
implements $AppListenEventCopyWith<$Res> {
|
||||||
_$AppWatchEventCopyWithImpl(this._value, this._then);
|
_$AppListenEventCopyWithImpl(this._value, this._then);
|
||||||
|
|
||||||
final AppWatchEvent _value;
|
final AppListenEvent _value;
|
||||||
// ignore: unused_field
|
// ignore: unused_field
|
||||||
final $Res Function(AppWatchEvent) _then;
|
final $Res Function(AppListenEvent) _then;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// @nodoc
|
/// @nodoc
|
||||||
@ -86,7 +86,7 @@ abstract class _$StartedCopyWith<$Res> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// @nodoc
|
/// @nodoc
|
||||||
class __$StartedCopyWithImpl<$Res> extends _$AppWatchEventCopyWithImpl<$Res>
|
class __$StartedCopyWithImpl<$Res> extends _$AppListenEventCopyWithImpl<$Res>
|
||||||
implements _$StartedCopyWith<$Res> {
|
implements _$StartedCopyWith<$Res> {
|
||||||
__$StartedCopyWithImpl(_Started _value, $Res Function(_Started) _then)
|
__$StartedCopyWithImpl(_Started _value, $Res Function(_Started) _then)
|
||||||
: super(_value, (v) => _then(v as _Started));
|
: super(_value, (v) => _then(v as _Started));
|
||||||
@ -102,7 +102,7 @@ class _$_Started implements _Started {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
String toString() {
|
String toString() {
|
||||||
return 'AppWatchEvent.started()';
|
return 'AppListenEvent.started()';
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@ -160,7 +160,7 @@ class _$_Started implements _Started {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
abstract class _Started implements AppWatchEvent {
|
abstract class _Started implements AppListenEvent {
|
||||||
const factory _Started() = _$_Started;
|
const factory _Started() = _$_Started;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -174,7 +174,7 @@ abstract class $ViewsReceivedCopyWith<$Res> {
|
|||||||
|
|
||||||
/// @nodoc
|
/// @nodoc
|
||||||
class _$ViewsReceivedCopyWithImpl<$Res>
|
class _$ViewsReceivedCopyWithImpl<$Res>
|
||||||
extends _$AppWatchEventCopyWithImpl<$Res>
|
extends _$AppListenEventCopyWithImpl<$Res>
|
||||||
implements $ViewsReceivedCopyWith<$Res> {
|
implements $ViewsReceivedCopyWith<$Res> {
|
||||||
_$ViewsReceivedCopyWithImpl(
|
_$ViewsReceivedCopyWithImpl(
|
||||||
ViewsReceived _value, $Res Function(ViewsReceived) _then)
|
ViewsReceived _value, $Res Function(ViewsReceived) _then)
|
||||||
@ -206,7 +206,7 @@ class _$ViewsReceived implements ViewsReceived {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
String toString() {
|
String toString() {
|
||||||
return 'AppWatchEvent.viewsReceived(viewsOrFail: $viewsOrFail)';
|
return 'AppListenEvent.viewsReceived(viewsOrFail: $viewsOrFail)';
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@ -274,7 +274,7 @@ class _$ViewsReceived implements ViewsReceived {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
abstract class ViewsReceived implements AppWatchEvent {
|
abstract class ViewsReceived implements AppListenEvent {
|
||||||
const factory ViewsReceived(Either<List<View>, WorkspaceError> viewsOrFail) =
|
const factory ViewsReceived(Either<List<View>, WorkspaceError> viewsOrFail) =
|
||||||
_$ViewsReceived;
|
_$ViewsReceived;
|
||||||
|
|
||||||
@ -286,8 +286,8 @@ abstract class ViewsReceived implements AppWatchEvent {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// @nodoc
|
/// @nodoc
|
||||||
class _$AppWatchStateTearOff {
|
class _$AppListenStateTearOff {
|
||||||
const _$AppWatchStateTearOff();
|
const _$AppListenStateTearOff();
|
||||||
|
|
||||||
_Initial initial() {
|
_Initial initial() {
|
||||||
return const _Initial();
|
return const _Initial();
|
||||||
@ -307,10 +307,10 @@ class _$AppWatchStateTearOff {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// @nodoc
|
/// @nodoc
|
||||||
const $AppWatchState = _$AppWatchStateTearOff();
|
const $AppListenState = _$AppListenStateTearOff();
|
||||||
|
|
||||||
/// @nodoc
|
/// @nodoc
|
||||||
mixin _$AppWatchState {
|
mixin _$AppListenState {
|
||||||
@optionalTypeArgs
|
@optionalTypeArgs
|
||||||
TResult when<TResult extends Object?>({
|
TResult when<TResult extends Object?>({
|
||||||
required TResult Function() initial,
|
required TResult Function() initial,
|
||||||
@ -344,20 +344,20 @@ mixin _$AppWatchState {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// @nodoc
|
/// @nodoc
|
||||||
abstract class $AppWatchStateCopyWith<$Res> {
|
abstract class $AppListenStateCopyWith<$Res> {
|
||||||
factory $AppWatchStateCopyWith(
|
factory $AppListenStateCopyWith(
|
||||||
AppWatchState value, $Res Function(AppWatchState) then) =
|
AppListenState value, $Res Function(AppListenState) then) =
|
||||||
_$AppWatchStateCopyWithImpl<$Res>;
|
_$AppListenStateCopyWithImpl<$Res>;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// @nodoc
|
/// @nodoc
|
||||||
class _$AppWatchStateCopyWithImpl<$Res>
|
class _$AppListenStateCopyWithImpl<$Res>
|
||||||
implements $AppWatchStateCopyWith<$Res> {
|
implements $AppListenStateCopyWith<$Res> {
|
||||||
_$AppWatchStateCopyWithImpl(this._value, this._then);
|
_$AppListenStateCopyWithImpl(this._value, this._then);
|
||||||
|
|
||||||
final AppWatchState _value;
|
final AppListenState _value;
|
||||||
// ignore: unused_field
|
// ignore: unused_field
|
||||||
final $Res Function(AppWatchState) _then;
|
final $Res Function(AppListenState) _then;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// @nodoc
|
/// @nodoc
|
||||||
@ -367,7 +367,7 @@ abstract class _$InitialCopyWith<$Res> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// @nodoc
|
/// @nodoc
|
||||||
class __$InitialCopyWithImpl<$Res> extends _$AppWatchStateCopyWithImpl<$Res>
|
class __$InitialCopyWithImpl<$Res> extends _$AppListenStateCopyWithImpl<$Res>
|
||||||
implements _$InitialCopyWith<$Res> {
|
implements _$InitialCopyWith<$Res> {
|
||||||
__$InitialCopyWithImpl(_Initial _value, $Res Function(_Initial) _then)
|
__$InitialCopyWithImpl(_Initial _value, $Res Function(_Initial) _then)
|
||||||
: super(_value, (v) => _then(v as _Initial));
|
: super(_value, (v) => _then(v as _Initial));
|
||||||
@ -383,7 +383,7 @@ class _$_Initial implements _Initial {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
String toString() {
|
String toString() {
|
||||||
return 'AppWatchState.initial()';
|
return 'AppListenState.initial()';
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@ -443,7 +443,7 @@ class _$_Initial implements _Initial {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
abstract class _Initial implements AppWatchState {
|
abstract class _Initial implements AppListenState {
|
||||||
const factory _Initial() = _$_Initial;
|
const factory _Initial() = _$_Initial;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -456,7 +456,7 @@ abstract class _$LoadViewsCopyWith<$Res> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// @nodoc
|
/// @nodoc
|
||||||
class __$LoadViewsCopyWithImpl<$Res> extends _$AppWatchStateCopyWithImpl<$Res>
|
class __$LoadViewsCopyWithImpl<$Res> extends _$AppListenStateCopyWithImpl<$Res>
|
||||||
implements _$LoadViewsCopyWith<$Res> {
|
implements _$LoadViewsCopyWith<$Res> {
|
||||||
__$LoadViewsCopyWithImpl(_LoadViews _value, $Res Function(_LoadViews) _then)
|
__$LoadViewsCopyWithImpl(_LoadViews _value, $Res Function(_LoadViews) _then)
|
||||||
: super(_value, (v) => _then(v as _LoadViews));
|
: super(_value, (v) => _then(v as _LoadViews));
|
||||||
@ -487,7 +487,7 @@ class _$_LoadViews implements _LoadViews {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
String toString() {
|
String toString() {
|
||||||
return 'AppWatchState.loadViews(views: $views)';
|
return 'AppListenState.loadViews(views: $views)';
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@ -556,7 +556,7 @@ class _$_LoadViews implements _LoadViews {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
abstract class _LoadViews implements AppWatchState {
|
abstract class _LoadViews implements AppListenState {
|
||||||
const factory _LoadViews(List<View> views) = _$_LoadViews;
|
const factory _LoadViews(List<View> views) = _$_LoadViews;
|
||||||
|
|
||||||
List<View> get views => throw _privateConstructorUsedError;
|
List<View> get views => throw _privateConstructorUsedError;
|
||||||
@ -573,7 +573,7 @@ abstract class _$LoadFailCopyWith<$Res> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// @nodoc
|
/// @nodoc
|
||||||
class __$LoadFailCopyWithImpl<$Res> extends _$AppWatchStateCopyWithImpl<$Res>
|
class __$LoadFailCopyWithImpl<$Res> extends _$AppListenStateCopyWithImpl<$Res>
|
||||||
implements _$LoadFailCopyWith<$Res> {
|
implements _$LoadFailCopyWith<$Res> {
|
||||||
__$LoadFailCopyWithImpl(_LoadFail _value, $Res Function(_LoadFail) _then)
|
__$LoadFailCopyWithImpl(_LoadFail _value, $Res Function(_LoadFail) _then)
|
||||||
: super(_value, (v) => _then(v as _LoadFail));
|
: super(_value, (v) => _then(v as _LoadFail));
|
||||||
@ -604,7 +604,7 @@ class _$_LoadFail implements _LoadFail {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
String toString() {
|
String toString() {
|
||||||
return 'AppWatchState.loadFail(error: $error)';
|
return 'AppListenState.loadFail(error: $error)';
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@ -673,7 +673,7 @@ class _$_LoadFail implements _LoadFail {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
abstract class _LoadFail implements AppWatchState {
|
abstract class _LoadFail implements AppListenState {
|
||||||
const factory _LoadFail(WorkspaceError error) = _$_LoadFail;
|
const factory _LoadFail(WorkspaceError error) = _$_LoadFail;
|
||||||
|
|
||||||
WorkspaceError get error => throw _privateConstructorUsedError;
|
WorkspaceError get error => throw _privateConstructorUsedError;
|
@ -1,56 +0,0 @@
|
|||||||
import 'package:app_flowy/workspace/domain/i_app.dart';
|
|
||||||
import 'package:flowy_sdk/protobuf/flowy-workspace/errors.pb.dart';
|
|
||||||
import 'package:flowy_sdk/protobuf/flowy-workspace/view_create.pb.dart';
|
|
||||||
import 'package:freezed_annotation/freezed_annotation.dart';
|
|
||||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
|
||||||
import 'package:dartz/dartz.dart';
|
|
||||||
|
|
||||||
part 'app_watch_bloc.freezed.dart';
|
|
||||||
|
|
||||||
class AppWatchBloc extends Bloc<AppWatchEvent, AppWatchState> {
|
|
||||||
final IAppWatch watcher;
|
|
||||||
AppWatchBloc(this.watcher) : super(const AppWatchState.initial());
|
|
||||||
|
|
||||||
@override
|
|
||||||
Stream<AppWatchState> mapEventToState(
|
|
||||||
AppWatchEvent event,
|
|
||||||
) async* {
|
|
||||||
yield* event.map(started: (_) async* {
|
|
||||||
watcher.startWatching(
|
|
||||||
addViewCallback: (viewsOrFail) => _handleViewsOrFail(viewsOrFail),
|
|
||||||
);
|
|
||||||
}, viewsReceived: (ViewsReceived value) async* {
|
|
||||||
yield value.viewsOrFail.fold(
|
|
||||||
(views) => AppWatchState.loadViews(views),
|
|
||||||
(error) => AppWatchState.loadFail(error),
|
|
||||||
);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
void _handleViewsOrFail(Either<List<View>, WorkspaceError> viewsOrFail) {
|
|
||||||
viewsOrFail.fold(
|
|
||||||
(views) => add(AppWatchEvent.viewsReceived(left(views))),
|
|
||||||
(error) => add(AppWatchEvent.viewsReceived(right(error))),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@freezed
|
|
||||||
class AppWatchEvent with _$AppWatchEvent {
|
|
||||||
const factory AppWatchEvent.started() = _Started;
|
|
||||||
const factory AppWatchEvent.viewsReceived(
|
|
||||||
Either<List<View>, WorkspaceError> viewsOrFail) = ViewsReceived;
|
|
||||||
}
|
|
||||||
|
|
||||||
@freezed
|
|
||||||
class AppWatchState with _$AppWatchState {
|
|
||||||
const factory AppWatchState.initial() = _Initial;
|
|
||||||
|
|
||||||
const factory AppWatchState.loadViews(
|
|
||||||
List<View> views,
|
|
||||||
) = _LoadViews;
|
|
||||||
|
|
||||||
const factory AppWatchState.loadFail(
|
|
||||||
WorkspaceError error,
|
|
||||||
) = _LoadFail;
|
|
||||||
}
|
|
@ -1,53 +0,0 @@
|
|||||||
import 'package:app_flowy/workspace/domain/i_user.dart';
|
|
||||||
import 'package:freezed_annotation/freezed_annotation.dart';
|
|
||||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
|
||||||
import 'package:dartz/dartz.dart';
|
|
||||||
part 'home_auth_bloc.freezed.dart';
|
|
||||||
|
|
||||||
class HomeAuthBloc extends Bloc<HomeAuthEvent, HomeAuthState> {
|
|
||||||
final IUserWatch watch;
|
|
||||||
HomeAuthBloc(this.watch) : super(const HomeAuthState.loading());
|
|
||||||
|
|
||||||
@override
|
|
||||||
Stream<HomeAuthState> mapEventToState(
|
|
||||||
HomeAuthEvent event,
|
|
||||||
) async* {
|
|
||||||
yield* event.map(
|
|
||||||
started: (_) async* {
|
|
||||||
watch.setAuthCallback(_authStateChanged);
|
|
||||||
watch.startWatching();
|
|
||||||
},
|
|
||||||
stop: (_) async* {},
|
|
||||||
unauthorized: (e) async* {
|
|
||||||
yield HomeAuthState.unauthorized(e.msg);
|
|
||||||
},
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
Future<void> close() async {
|
|
||||||
await watch.stopWatching();
|
|
||||||
super.close();
|
|
||||||
}
|
|
||||||
|
|
||||||
void _authStateChanged(Either<Unit, UserError> errorOrNothing) {
|
|
||||||
errorOrNothing.fold((_) {}, (error) {
|
|
||||||
if (error.code == ErrorCode.UserUnauthorized) {
|
|
||||||
add(HomeAuthEvent.unauthorized(error.msg));
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@freezed
|
|
||||||
class HomeAuthEvent with _$HomeAuthEvent {
|
|
||||||
const factory HomeAuthEvent.started() = _Started;
|
|
||||||
const factory HomeAuthEvent.stop() = _Stop;
|
|
||||||
const factory HomeAuthEvent.unauthorized(String msg) = _Unauthorized;
|
|
||||||
}
|
|
||||||
|
|
||||||
@freezed
|
|
||||||
class HomeAuthState with _$HomeAuthState {
|
|
||||||
const factory HomeAuthState.loading() = Loading;
|
|
||||||
const factory HomeAuthState.unauthorized(String msg) = Unauthorized;
|
|
||||||
}
|
|
@ -0,0 +1,53 @@
|
|||||||
|
import 'package:app_flowy/workspace/domain/i_user.dart';
|
||||||
|
import 'package:freezed_annotation/freezed_annotation.dart';
|
||||||
|
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||||
|
import 'package:dartz/dartz.dart';
|
||||||
|
part 'home_listen_bloc.freezed.dart';
|
||||||
|
|
||||||
|
class HomeListenBloc extends Bloc<HomeListenEvent, HomeListenState> {
|
||||||
|
final IUserListener listener;
|
||||||
|
HomeListenBloc(this.listener) : super(const HomeListenState.loading());
|
||||||
|
|
||||||
|
@override
|
||||||
|
Stream<HomeListenState> mapEventToState(
|
||||||
|
HomeListenEvent event,
|
||||||
|
) async* {
|
||||||
|
yield* event.map(
|
||||||
|
started: (_) async* {
|
||||||
|
listener.setAuthCallback(_authStateChanged);
|
||||||
|
listener.start();
|
||||||
|
},
|
||||||
|
stop: (_) async* {},
|
||||||
|
unauthorized: (e) async* {
|
||||||
|
yield HomeListenState.unauthorized(e.msg);
|
||||||
|
},
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Future<void> close() async {
|
||||||
|
await listener.stop();
|
||||||
|
super.close();
|
||||||
|
}
|
||||||
|
|
||||||
|
void _authStateChanged(Either<Unit, UserError> errorOrNothing) {
|
||||||
|
errorOrNothing.fold((_) {}, (error) {
|
||||||
|
if (error.code == ErrorCode.UserUnauthorized) {
|
||||||
|
add(HomeListenEvent.unauthorized(error.msg));
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@freezed
|
||||||
|
class HomeListenEvent with _$HomeListenEvent {
|
||||||
|
const factory HomeListenEvent.started() = _Started;
|
||||||
|
const factory HomeListenEvent.stop() = _Stop;
|
||||||
|
const factory HomeListenEvent.unauthorized(String msg) = _Unauthorized;
|
||||||
|
}
|
||||||
|
|
||||||
|
@freezed
|
||||||
|
class HomeListenState with _$HomeListenState {
|
||||||
|
const factory HomeListenState.loading() = Loading;
|
||||||
|
const factory HomeListenState.unauthorized(String msg) = Unauthorized;
|
||||||
|
}
|
@ -1,7 +1,7 @@
|
|||||||
// GENERATED CODE - DO NOT MODIFY BY HAND
|
// GENERATED CODE - DO NOT MODIFY BY HAND
|
||||||
// ignore_for_file: unused_element, deprecated_member_use, deprecated_member_use_from_same_package, use_function_type_syntax_for_parameters, unnecessary_const, avoid_init_to_null, invalid_override_different_default_values_named, prefer_expression_function_bodies, annotate_overrides, invalid_annotation_target
|
// ignore_for_file: unused_element, deprecated_member_use, deprecated_member_use_from_same_package, use_function_type_syntax_for_parameters, unnecessary_const, avoid_init_to_null, invalid_override_different_default_values_named, prefer_expression_function_bodies, annotate_overrides, invalid_annotation_target
|
||||||
|
|
||||||
part of 'home_auth_bloc.dart';
|
part of 'home_listen_bloc.dart';
|
||||||
|
|
||||||
// **************************************************************************
|
// **************************************************************************
|
||||||
// FreezedGenerator
|
// FreezedGenerator
|
||||||
@ -13,8 +13,8 @@ final _privateConstructorUsedError = UnsupportedError(
|
|||||||
'It seems like you constructed your class using `MyClass._()`. This constructor is only meant to be used by freezed and you are not supposed to need it nor use it.\nPlease check the documentation here for more informations: https://github.com/rrousselGit/freezed#custom-getters-and-methods');
|
'It seems like you constructed your class using `MyClass._()`. This constructor is only meant to be used by freezed and you are not supposed to need it nor use it.\nPlease check the documentation here for more informations: https://github.com/rrousselGit/freezed#custom-getters-and-methods');
|
||||||
|
|
||||||
/// @nodoc
|
/// @nodoc
|
||||||
class _$HomeAuthEventTearOff {
|
class _$HomeListenEventTearOff {
|
||||||
const _$HomeAuthEventTearOff();
|
const _$HomeListenEventTearOff();
|
||||||
|
|
||||||
_Started started() {
|
_Started started() {
|
||||||
return const _Started();
|
return const _Started();
|
||||||
@ -32,10 +32,10 @@ class _$HomeAuthEventTearOff {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// @nodoc
|
/// @nodoc
|
||||||
const $HomeAuthEvent = _$HomeAuthEventTearOff();
|
const $HomeListenEvent = _$HomeListenEventTearOff();
|
||||||
|
|
||||||
/// @nodoc
|
/// @nodoc
|
||||||
mixin _$HomeAuthEvent {
|
mixin _$HomeListenEvent {
|
||||||
@optionalTypeArgs
|
@optionalTypeArgs
|
||||||
TResult when<TResult extends Object?>({
|
TResult when<TResult extends Object?>({
|
||||||
required TResult Function() started,
|
required TResult Function() started,
|
||||||
@ -69,20 +69,20 @@ mixin _$HomeAuthEvent {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// @nodoc
|
/// @nodoc
|
||||||
abstract class $HomeAuthEventCopyWith<$Res> {
|
abstract class $HomeListenEventCopyWith<$Res> {
|
||||||
factory $HomeAuthEventCopyWith(
|
factory $HomeListenEventCopyWith(
|
||||||
HomeAuthEvent value, $Res Function(HomeAuthEvent) then) =
|
HomeListenEvent value, $Res Function(HomeListenEvent) then) =
|
||||||
_$HomeAuthEventCopyWithImpl<$Res>;
|
_$HomeListenEventCopyWithImpl<$Res>;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// @nodoc
|
/// @nodoc
|
||||||
class _$HomeAuthEventCopyWithImpl<$Res>
|
class _$HomeListenEventCopyWithImpl<$Res>
|
||||||
implements $HomeAuthEventCopyWith<$Res> {
|
implements $HomeListenEventCopyWith<$Res> {
|
||||||
_$HomeAuthEventCopyWithImpl(this._value, this._then);
|
_$HomeListenEventCopyWithImpl(this._value, this._then);
|
||||||
|
|
||||||
final HomeAuthEvent _value;
|
final HomeListenEvent _value;
|
||||||
// ignore: unused_field
|
// ignore: unused_field
|
||||||
final $Res Function(HomeAuthEvent) _then;
|
final $Res Function(HomeListenEvent) _then;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// @nodoc
|
/// @nodoc
|
||||||
@ -92,7 +92,7 @@ abstract class _$StartedCopyWith<$Res> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// @nodoc
|
/// @nodoc
|
||||||
class __$StartedCopyWithImpl<$Res> extends _$HomeAuthEventCopyWithImpl<$Res>
|
class __$StartedCopyWithImpl<$Res> extends _$HomeListenEventCopyWithImpl<$Res>
|
||||||
implements _$StartedCopyWith<$Res> {
|
implements _$StartedCopyWith<$Res> {
|
||||||
__$StartedCopyWithImpl(_Started _value, $Res Function(_Started) _then)
|
__$StartedCopyWithImpl(_Started _value, $Res Function(_Started) _then)
|
||||||
: super(_value, (v) => _then(v as _Started));
|
: super(_value, (v) => _then(v as _Started));
|
||||||
@ -108,7 +108,7 @@ class _$_Started implements _Started {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
String toString() {
|
String toString() {
|
||||||
return 'HomeAuthEvent.started()';
|
return 'HomeListenEvent.started()';
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@ -168,7 +168,7 @@ class _$_Started implements _Started {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
abstract class _Started implements HomeAuthEvent {
|
abstract class _Started implements HomeListenEvent {
|
||||||
const factory _Started() = _$_Started;
|
const factory _Started() = _$_Started;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -179,7 +179,7 @@ abstract class _$StopCopyWith<$Res> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// @nodoc
|
/// @nodoc
|
||||||
class __$StopCopyWithImpl<$Res> extends _$HomeAuthEventCopyWithImpl<$Res>
|
class __$StopCopyWithImpl<$Res> extends _$HomeListenEventCopyWithImpl<$Res>
|
||||||
implements _$StopCopyWith<$Res> {
|
implements _$StopCopyWith<$Res> {
|
||||||
__$StopCopyWithImpl(_Stop _value, $Res Function(_Stop) _then)
|
__$StopCopyWithImpl(_Stop _value, $Res Function(_Stop) _then)
|
||||||
: super(_value, (v) => _then(v as _Stop));
|
: super(_value, (v) => _then(v as _Stop));
|
||||||
@ -195,7 +195,7 @@ class _$_Stop implements _Stop {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
String toString() {
|
String toString() {
|
||||||
return 'HomeAuthEvent.stop()';
|
return 'HomeListenEvent.stop()';
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@ -255,7 +255,7 @@ class _$_Stop implements _Stop {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
abstract class _Stop implements HomeAuthEvent {
|
abstract class _Stop implements HomeListenEvent {
|
||||||
const factory _Stop() = _$_Stop;
|
const factory _Stop() = _$_Stop;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -269,7 +269,7 @@ abstract class _$UnauthorizedCopyWith<$Res> {
|
|||||||
|
|
||||||
/// @nodoc
|
/// @nodoc
|
||||||
class __$UnauthorizedCopyWithImpl<$Res>
|
class __$UnauthorizedCopyWithImpl<$Res>
|
||||||
extends _$HomeAuthEventCopyWithImpl<$Res>
|
extends _$HomeListenEventCopyWithImpl<$Res>
|
||||||
implements _$UnauthorizedCopyWith<$Res> {
|
implements _$UnauthorizedCopyWith<$Res> {
|
||||||
__$UnauthorizedCopyWithImpl(
|
__$UnauthorizedCopyWithImpl(
|
||||||
_Unauthorized _value, $Res Function(_Unauthorized) _then)
|
_Unauthorized _value, $Res Function(_Unauthorized) _then)
|
||||||
@ -301,7 +301,7 @@ class _$_Unauthorized implements _Unauthorized {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
String toString() {
|
String toString() {
|
||||||
return 'HomeAuthEvent.unauthorized(msg: $msg)';
|
return 'HomeListenEvent.unauthorized(msg: $msg)';
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@ -370,7 +370,7 @@ class _$_Unauthorized implements _Unauthorized {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
abstract class _Unauthorized implements HomeAuthEvent {
|
abstract class _Unauthorized implements HomeListenEvent {
|
||||||
const factory _Unauthorized(String msg) = _$_Unauthorized;
|
const factory _Unauthorized(String msg) = _$_Unauthorized;
|
||||||
|
|
||||||
String get msg => throw _privateConstructorUsedError;
|
String get msg => throw _privateConstructorUsedError;
|
||||||
@ -380,8 +380,8 @@ abstract class _Unauthorized implements HomeAuthEvent {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// @nodoc
|
/// @nodoc
|
||||||
class _$HomeAuthStateTearOff {
|
class _$HomeListenStateTearOff {
|
||||||
const _$HomeAuthStateTearOff();
|
const _$HomeListenStateTearOff();
|
||||||
|
|
||||||
Loading loading() {
|
Loading loading() {
|
||||||
return const Loading();
|
return const Loading();
|
||||||
@ -395,10 +395,10 @@ class _$HomeAuthStateTearOff {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// @nodoc
|
/// @nodoc
|
||||||
const $HomeAuthState = _$HomeAuthStateTearOff();
|
const $HomeListenState = _$HomeListenStateTearOff();
|
||||||
|
|
||||||
/// @nodoc
|
/// @nodoc
|
||||||
mixin _$HomeAuthState {
|
mixin _$HomeListenState {
|
||||||
@optionalTypeArgs
|
@optionalTypeArgs
|
||||||
TResult when<TResult extends Object?>({
|
TResult when<TResult extends Object?>({
|
||||||
required TResult Function() loading,
|
required TResult Function() loading,
|
||||||
@ -428,20 +428,20 @@ mixin _$HomeAuthState {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// @nodoc
|
/// @nodoc
|
||||||
abstract class $HomeAuthStateCopyWith<$Res> {
|
abstract class $HomeListenStateCopyWith<$Res> {
|
||||||
factory $HomeAuthStateCopyWith(
|
factory $HomeListenStateCopyWith(
|
||||||
HomeAuthState value, $Res Function(HomeAuthState) then) =
|
HomeListenState value, $Res Function(HomeListenState) then) =
|
||||||
_$HomeAuthStateCopyWithImpl<$Res>;
|
_$HomeListenStateCopyWithImpl<$Res>;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// @nodoc
|
/// @nodoc
|
||||||
class _$HomeAuthStateCopyWithImpl<$Res>
|
class _$HomeListenStateCopyWithImpl<$Res>
|
||||||
implements $HomeAuthStateCopyWith<$Res> {
|
implements $HomeListenStateCopyWith<$Res> {
|
||||||
_$HomeAuthStateCopyWithImpl(this._value, this._then);
|
_$HomeListenStateCopyWithImpl(this._value, this._then);
|
||||||
|
|
||||||
final HomeAuthState _value;
|
final HomeListenState _value;
|
||||||
// ignore: unused_field
|
// ignore: unused_field
|
||||||
final $Res Function(HomeAuthState) _then;
|
final $Res Function(HomeListenState) _then;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// @nodoc
|
/// @nodoc
|
||||||
@ -451,7 +451,7 @@ abstract class $LoadingCopyWith<$Res> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// @nodoc
|
/// @nodoc
|
||||||
class _$LoadingCopyWithImpl<$Res> extends _$HomeAuthStateCopyWithImpl<$Res>
|
class _$LoadingCopyWithImpl<$Res> extends _$HomeListenStateCopyWithImpl<$Res>
|
||||||
implements $LoadingCopyWith<$Res> {
|
implements $LoadingCopyWith<$Res> {
|
||||||
_$LoadingCopyWithImpl(Loading _value, $Res Function(Loading) _then)
|
_$LoadingCopyWithImpl(Loading _value, $Res Function(Loading) _then)
|
||||||
: super(_value, (v) => _then(v as Loading));
|
: super(_value, (v) => _then(v as Loading));
|
||||||
@ -467,7 +467,7 @@ class _$Loading implements Loading {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
String toString() {
|
String toString() {
|
||||||
return 'HomeAuthState.loading()';
|
return 'HomeListenState.loading()';
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@ -523,7 +523,7 @@ class _$Loading implements Loading {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
abstract class Loading implements HomeAuthState {
|
abstract class Loading implements HomeListenState {
|
||||||
const factory Loading() = _$Loading;
|
const factory Loading() = _$Loading;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -536,7 +536,8 @@ abstract class $UnauthorizedCopyWith<$Res> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// @nodoc
|
/// @nodoc
|
||||||
class _$UnauthorizedCopyWithImpl<$Res> extends _$HomeAuthStateCopyWithImpl<$Res>
|
class _$UnauthorizedCopyWithImpl<$Res>
|
||||||
|
extends _$HomeListenStateCopyWithImpl<$Res>
|
||||||
implements $UnauthorizedCopyWith<$Res> {
|
implements $UnauthorizedCopyWith<$Res> {
|
||||||
_$UnauthorizedCopyWithImpl(
|
_$UnauthorizedCopyWithImpl(
|
||||||
Unauthorized _value, $Res Function(Unauthorized) _then)
|
Unauthorized _value, $Res Function(Unauthorized) _then)
|
||||||
@ -568,7 +569,7 @@ class _$Unauthorized implements Unauthorized {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
String toString() {
|
String toString() {
|
||||||
return 'HomeAuthState.unauthorized(msg: $msg)';
|
return 'HomeListenState.unauthorized(msg: $msg)';
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@ -633,7 +634,7 @@ class _$Unauthorized implements Unauthorized {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
abstract class Unauthorized implements HomeAuthState {
|
abstract class Unauthorized implements HomeListenState {
|
||||||
const factory Unauthorized(String msg) = _$Unauthorized;
|
const factory Unauthorized(String msg) = _$Unauthorized;
|
||||||
|
|
||||||
String get msg => throw _privateConstructorUsedError;
|
String get msg => throw _privateConstructorUsedError;
|
@ -86,6 +86,6 @@ class MenuState with _$MenuState {
|
|||||||
isCollapse: false,
|
isCollapse: false,
|
||||||
apps: none(),
|
apps: none(),
|
||||||
successOrFailure: left(unit),
|
successOrFailure: left(unit),
|
||||||
context: DefaultHomeStackContext(),
|
context: BlankStackContext(),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -7,14 +7,14 @@ import 'package:freezed_annotation/freezed_annotation.dart';
|
|||||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||||
import 'package:dartz/dartz.dart';
|
import 'package:dartz/dartz.dart';
|
||||||
|
|
||||||
part 'menu_watch.freezed.dart';
|
part 'menu_listen.freezed.dart';
|
||||||
|
|
||||||
class MenuWatchBloc extends Bloc<MenuWatchEvent, MenuWatchState> {
|
class MenuListenBloc extends Bloc<MenuListenEvent, MenuListenState> {
|
||||||
final IWorkspaceWatch watch;
|
final IWorkspaceWatch watch;
|
||||||
MenuWatchBloc(this.watch) : super(const MenuWatchState.initial());
|
MenuListenBloc(this.watch) : super(const MenuListenState.initial());
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Stream<MenuWatchState> mapEventToState(MenuWatchEvent event) async* {
|
Stream<MenuListenState> mapEventToState(MenuListenEvent event) async* {
|
||||||
yield* event.map(
|
yield* event.map(
|
||||||
started: (_) async* {
|
started: (_) async* {
|
||||||
watch.startWatching(
|
watch.startWatching(
|
||||||
@ -23,8 +23,8 @@ class MenuWatchBloc extends Bloc<MenuWatchEvent, MenuWatchState> {
|
|||||||
},
|
},
|
||||||
appsReceived: (e) async* {
|
appsReceived: (e) async* {
|
||||||
yield e.appsOrFail.fold(
|
yield e.appsOrFail.fold(
|
||||||
(apps) => MenuWatchState.loadApps(apps),
|
(apps) => MenuListenState.loadApps(apps),
|
||||||
(error) => MenuWatchState.loadFail(error),
|
(error) => MenuListenState.loadFail(error),
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
@ -38,31 +38,30 @@ class MenuWatchBloc extends Bloc<MenuWatchEvent, MenuWatchState> {
|
|||||||
|
|
||||||
void _handleAppsOrFail(Either<List<App>, WorkspaceError> appsOrFail) {
|
void _handleAppsOrFail(Either<List<App>, WorkspaceError> appsOrFail) {
|
||||||
appsOrFail.fold(
|
appsOrFail.fold(
|
||||||
(apps) => add(MenuWatchEvent.appsReceived(left(apps))),
|
(apps) => add(MenuListenEvent.appsReceived(left(apps))),
|
||||||
(error) {
|
(error) {
|
||||||
Log.error(error);
|
Log.error(error);
|
||||||
add(MenuWatchEvent.appsReceived(right(error)));
|
add(MenuListenEvent.appsReceived(right(error)));
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@freezed
|
@freezed
|
||||||
class MenuWatchEvent with _$MenuWatchEvent {
|
class MenuListenEvent with _$MenuListenEvent {
|
||||||
const factory MenuWatchEvent.started() = _Started;
|
const factory MenuListenEvent.started() = _Started;
|
||||||
const factory MenuWatchEvent.appsReceived(
|
const factory MenuListenEvent.appsReceived(Either<List<App>, WorkspaceError> appsOrFail) = AppsReceived;
|
||||||
Either<List<App>, WorkspaceError> appsOrFail) = AppsReceived;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@freezed
|
@freezed
|
||||||
class MenuWatchState with _$MenuWatchState {
|
class MenuListenState with _$MenuListenState {
|
||||||
const factory MenuWatchState.initial() = _Initial;
|
const factory MenuListenState.initial() = _Initial;
|
||||||
|
|
||||||
const factory MenuWatchState.loadApps(
|
const factory MenuListenState.loadApps(
|
||||||
List<App> apps,
|
List<App> apps,
|
||||||
) = _LoadApps;
|
) = _LoadApps;
|
||||||
|
|
||||||
const factory MenuWatchState.loadFail(
|
const factory MenuListenState.loadFail(
|
||||||
WorkspaceError error,
|
WorkspaceError error,
|
||||||
) = _LoadFail;
|
) = _LoadFail;
|
||||||
}
|
}
|
@ -1,7 +1,7 @@
|
|||||||
// GENERATED CODE - DO NOT MODIFY BY HAND
|
// GENERATED CODE - DO NOT MODIFY BY HAND
|
||||||
// ignore_for_file: unused_element, deprecated_member_use, deprecated_member_use_from_same_package, use_function_type_syntax_for_parameters, unnecessary_const, avoid_init_to_null, invalid_override_different_default_values_named, prefer_expression_function_bodies, annotate_overrides, invalid_annotation_target
|
// ignore_for_file: unused_element, deprecated_member_use, deprecated_member_use_from_same_package, use_function_type_syntax_for_parameters, unnecessary_const, avoid_init_to_null, invalid_override_different_default_values_named, prefer_expression_function_bodies, annotate_overrides, invalid_annotation_target
|
||||||
|
|
||||||
part of 'menu_watch.dart';
|
part of 'menu_listen.dart';
|
||||||
|
|
||||||
// **************************************************************************
|
// **************************************************************************
|
||||||
// FreezedGenerator
|
// FreezedGenerator
|
||||||
@ -13,8 +13,8 @@ final _privateConstructorUsedError = UnsupportedError(
|
|||||||
'It seems like you constructed your class using `MyClass._()`. This constructor is only meant to be used by freezed and you are not supposed to need it nor use it.\nPlease check the documentation here for more informations: https://github.com/rrousselGit/freezed#custom-getters-and-methods');
|
'It seems like you constructed your class using `MyClass._()`. This constructor is only meant to be used by freezed and you are not supposed to need it nor use it.\nPlease check the documentation here for more informations: https://github.com/rrousselGit/freezed#custom-getters-and-methods');
|
||||||
|
|
||||||
/// @nodoc
|
/// @nodoc
|
||||||
class _$MenuWatchEventTearOff {
|
class _$MenuListenEventTearOff {
|
||||||
const _$MenuWatchEventTearOff();
|
const _$MenuListenEventTearOff();
|
||||||
|
|
||||||
_Started started() {
|
_Started started() {
|
||||||
return const _Started();
|
return const _Started();
|
||||||
@ -28,10 +28,10 @@ class _$MenuWatchEventTearOff {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// @nodoc
|
/// @nodoc
|
||||||
const $MenuWatchEvent = _$MenuWatchEventTearOff();
|
const $MenuListenEvent = _$MenuListenEventTearOff();
|
||||||
|
|
||||||
/// @nodoc
|
/// @nodoc
|
||||||
mixin _$MenuWatchEvent {
|
mixin _$MenuListenEvent {
|
||||||
@optionalTypeArgs
|
@optionalTypeArgs
|
||||||
TResult when<TResult extends Object?>({
|
TResult when<TResult extends Object?>({
|
||||||
required TResult Function() started,
|
required TResult Function() started,
|
||||||
@ -63,20 +63,20 @@ mixin _$MenuWatchEvent {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// @nodoc
|
/// @nodoc
|
||||||
abstract class $MenuWatchEventCopyWith<$Res> {
|
abstract class $MenuListenEventCopyWith<$Res> {
|
||||||
factory $MenuWatchEventCopyWith(
|
factory $MenuListenEventCopyWith(
|
||||||
MenuWatchEvent value, $Res Function(MenuWatchEvent) then) =
|
MenuListenEvent value, $Res Function(MenuListenEvent) then) =
|
||||||
_$MenuWatchEventCopyWithImpl<$Res>;
|
_$MenuListenEventCopyWithImpl<$Res>;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// @nodoc
|
/// @nodoc
|
||||||
class _$MenuWatchEventCopyWithImpl<$Res>
|
class _$MenuListenEventCopyWithImpl<$Res>
|
||||||
implements $MenuWatchEventCopyWith<$Res> {
|
implements $MenuListenEventCopyWith<$Res> {
|
||||||
_$MenuWatchEventCopyWithImpl(this._value, this._then);
|
_$MenuListenEventCopyWithImpl(this._value, this._then);
|
||||||
|
|
||||||
final MenuWatchEvent _value;
|
final MenuListenEvent _value;
|
||||||
// ignore: unused_field
|
// ignore: unused_field
|
||||||
final $Res Function(MenuWatchEvent) _then;
|
final $Res Function(MenuListenEvent) _then;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// @nodoc
|
/// @nodoc
|
||||||
@ -86,7 +86,7 @@ abstract class _$StartedCopyWith<$Res> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// @nodoc
|
/// @nodoc
|
||||||
class __$StartedCopyWithImpl<$Res> extends _$MenuWatchEventCopyWithImpl<$Res>
|
class __$StartedCopyWithImpl<$Res> extends _$MenuListenEventCopyWithImpl<$Res>
|
||||||
implements _$StartedCopyWith<$Res> {
|
implements _$StartedCopyWith<$Res> {
|
||||||
__$StartedCopyWithImpl(_Started _value, $Res Function(_Started) _then)
|
__$StartedCopyWithImpl(_Started _value, $Res Function(_Started) _then)
|
||||||
: super(_value, (v) => _then(v as _Started));
|
: super(_value, (v) => _then(v as _Started));
|
||||||
@ -102,7 +102,7 @@ class _$_Started implements _Started {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
String toString() {
|
String toString() {
|
||||||
return 'MenuWatchEvent.started()';
|
return 'MenuListenEvent.started()';
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@ -160,7 +160,7 @@ class _$_Started implements _Started {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
abstract class _Started implements MenuWatchEvent {
|
abstract class _Started implements MenuListenEvent {
|
||||||
const factory _Started() = _$_Started;
|
const factory _Started() = _$_Started;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -174,7 +174,7 @@ abstract class $AppsReceivedCopyWith<$Res> {
|
|||||||
|
|
||||||
/// @nodoc
|
/// @nodoc
|
||||||
class _$AppsReceivedCopyWithImpl<$Res>
|
class _$AppsReceivedCopyWithImpl<$Res>
|
||||||
extends _$MenuWatchEventCopyWithImpl<$Res>
|
extends _$MenuListenEventCopyWithImpl<$Res>
|
||||||
implements $AppsReceivedCopyWith<$Res> {
|
implements $AppsReceivedCopyWith<$Res> {
|
||||||
_$AppsReceivedCopyWithImpl(
|
_$AppsReceivedCopyWithImpl(
|
||||||
AppsReceived _value, $Res Function(AppsReceived) _then)
|
AppsReceived _value, $Res Function(AppsReceived) _then)
|
||||||
@ -206,7 +206,7 @@ class _$AppsReceived implements AppsReceived {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
String toString() {
|
String toString() {
|
||||||
return 'MenuWatchEvent.appsReceived(appsOrFail: $appsOrFail)';
|
return 'MenuListenEvent.appsReceived(appsOrFail: $appsOrFail)';
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@ -274,7 +274,7 @@ class _$AppsReceived implements AppsReceived {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
abstract class AppsReceived implements MenuWatchEvent {
|
abstract class AppsReceived implements MenuListenEvent {
|
||||||
const factory AppsReceived(Either<List<App>, WorkspaceError> appsOrFail) =
|
const factory AppsReceived(Either<List<App>, WorkspaceError> appsOrFail) =
|
||||||
_$AppsReceived;
|
_$AppsReceived;
|
||||||
|
|
||||||
@ -286,8 +286,8 @@ abstract class AppsReceived implements MenuWatchEvent {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// @nodoc
|
/// @nodoc
|
||||||
class _$MenuWatchStateTearOff {
|
class _$MenuListenStateTearOff {
|
||||||
const _$MenuWatchStateTearOff();
|
const _$MenuListenStateTearOff();
|
||||||
|
|
||||||
_Initial initial() {
|
_Initial initial() {
|
||||||
return const _Initial();
|
return const _Initial();
|
||||||
@ -307,10 +307,10 @@ class _$MenuWatchStateTearOff {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// @nodoc
|
/// @nodoc
|
||||||
const $MenuWatchState = _$MenuWatchStateTearOff();
|
const $MenuListenState = _$MenuListenStateTearOff();
|
||||||
|
|
||||||
/// @nodoc
|
/// @nodoc
|
||||||
mixin _$MenuWatchState {
|
mixin _$MenuListenState {
|
||||||
@optionalTypeArgs
|
@optionalTypeArgs
|
||||||
TResult when<TResult extends Object?>({
|
TResult when<TResult extends Object?>({
|
||||||
required TResult Function() initial,
|
required TResult Function() initial,
|
||||||
@ -344,20 +344,20 @@ mixin _$MenuWatchState {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// @nodoc
|
/// @nodoc
|
||||||
abstract class $MenuWatchStateCopyWith<$Res> {
|
abstract class $MenuListenStateCopyWith<$Res> {
|
||||||
factory $MenuWatchStateCopyWith(
|
factory $MenuListenStateCopyWith(
|
||||||
MenuWatchState value, $Res Function(MenuWatchState) then) =
|
MenuListenState value, $Res Function(MenuListenState) then) =
|
||||||
_$MenuWatchStateCopyWithImpl<$Res>;
|
_$MenuListenStateCopyWithImpl<$Res>;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// @nodoc
|
/// @nodoc
|
||||||
class _$MenuWatchStateCopyWithImpl<$Res>
|
class _$MenuListenStateCopyWithImpl<$Res>
|
||||||
implements $MenuWatchStateCopyWith<$Res> {
|
implements $MenuListenStateCopyWith<$Res> {
|
||||||
_$MenuWatchStateCopyWithImpl(this._value, this._then);
|
_$MenuListenStateCopyWithImpl(this._value, this._then);
|
||||||
|
|
||||||
final MenuWatchState _value;
|
final MenuListenState _value;
|
||||||
// ignore: unused_field
|
// ignore: unused_field
|
||||||
final $Res Function(MenuWatchState) _then;
|
final $Res Function(MenuListenState) _then;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// @nodoc
|
/// @nodoc
|
||||||
@ -367,7 +367,7 @@ abstract class _$InitialCopyWith<$Res> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// @nodoc
|
/// @nodoc
|
||||||
class __$InitialCopyWithImpl<$Res> extends _$MenuWatchStateCopyWithImpl<$Res>
|
class __$InitialCopyWithImpl<$Res> extends _$MenuListenStateCopyWithImpl<$Res>
|
||||||
implements _$InitialCopyWith<$Res> {
|
implements _$InitialCopyWith<$Res> {
|
||||||
__$InitialCopyWithImpl(_Initial _value, $Res Function(_Initial) _then)
|
__$InitialCopyWithImpl(_Initial _value, $Res Function(_Initial) _then)
|
||||||
: super(_value, (v) => _then(v as _Initial));
|
: super(_value, (v) => _then(v as _Initial));
|
||||||
@ -383,7 +383,7 @@ class _$_Initial implements _Initial {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
String toString() {
|
String toString() {
|
||||||
return 'MenuWatchState.initial()';
|
return 'MenuListenState.initial()';
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@ -443,7 +443,7 @@ class _$_Initial implements _Initial {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
abstract class _Initial implements MenuWatchState {
|
abstract class _Initial implements MenuListenState {
|
||||||
const factory _Initial() = _$_Initial;
|
const factory _Initial() = _$_Initial;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -455,7 +455,7 @@ abstract class _$LoadAppsCopyWith<$Res> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// @nodoc
|
/// @nodoc
|
||||||
class __$LoadAppsCopyWithImpl<$Res> extends _$MenuWatchStateCopyWithImpl<$Res>
|
class __$LoadAppsCopyWithImpl<$Res> extends _$MenuListenStateCopyWithImpl<$Res>
|
||||||
implements _$LoadAppsCopyWith<$Res> {
|
implements _$LoadAppsCopyWith<$Res> {
|
||||||
__$LoadAppsCopyWithImpl(_LoadApps _value, $Res Function(_LoadApps) _then)
|
__$LoadAppsCopyWithImpl(_LoadApps _value, $Res Function(_LoadApps) _then)
|
||||||
: super(_value, (v) => _then(v as _LoadApps));
|
: super(_value, (v) => _then(v as _LoadApps));
|
||||||
@ -486,7 +486,7 @@ class _$_LoadApps implements _LoadApps {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
String toString() {
|
String toString() {
|
||||||
return 'MenuWatchState.loadApps(apps: $apps)';
|
return 'MenuListenState.loadApps(apps: $apps)';
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@ -555,7 +555,7 @@ class _$_LoadApps implements _LoadApps {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
abstract class _LoadApps implements MenuWatchState {
|
abstract class _LoadApps implements MenuListenState {
|
||||||
const factory _LoadApps(List<App> apps) = _$_LoadApps;
|
const factory _LoadApps(List<App> apps) = _$_LoadApps;
|
||||||
|
|
||||||
List<App> get apps => throw _privateConstructorUsedError;
|
List<App> get apps => throw _privateConstructorUsedError;
|
||||||
@ -572,7 +572,7 @@ abstract class _$LoadFailCopyWith<$Res> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// @nodoc
|
/// @nodoc
|
||||||
class __$LoadFailCopyWithImpl<$Res> extends _$MenuWatchStateCopyWithImpl<$Res>
|
class __$LoadFailCopyWithImpl<$Res> extends _$MenuListenStateCopyWithImpl<$Res>
|
||||||
implements _$LoadFailCopyWith<$Res> {
|
implements _$LoadFailCopyWith<$Res> {
|
||||||
__$LoadFailCopyWithImpl(_LoadFail _value, $Res Function(_LoadFail) _then)
|
__$LoadFailCopyWithImpl(_LoadFail _value, $Res Function(_LoadFail) _then)
|
||||||
: super(_value, (v) => _then(v as _LoadFail));
|
: super(_value, (v) => _then(v as _LoadFail));
|
||||||
@ -603,7 +603,7 @@ class _$_LoadFail implements _LoadFail {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
String toString() {
|
String toString() {
|
||||||
return 'MenuWatchState.loadFail(error: $error)';
|
return 'MenuListenState.loadFail(error: $error)';
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@ -672,7 +672,7 @@ class _$_LoadFail implements _LoadFail {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
abstract class _LoadFail implements MenuWatchState {
|
abstract class _LoadFail implements MenuListenState {
|
||||||
const factory _LoadFail(WorkspaceError error) = _$_LoadFail;
|
const factory _LoadFail(WorkspaceError error) = _$_LoadFail;
|
||||||
|
|
||||||
WorkspaceError get error => throw _privateConstructorUsedError;
|
WorkspaceError get error => throw _privateConstructorUsedError;
|
@ -11,18 +11,17 @@ part 'menu_user_bloc.freezed.dart';
|
|||||||
|
|
||||||
class MenuUserBloc extends Bloc<MenuUserEvent, MenuUserState> {
|
class MenuUserBloc extends Bloc<MenuUserEvent, MenuUserState> {
|
||||||
final IUser iUserImpl;
|
final IUser iUserImpl;
|
||||||
final IUserWatch watch;
|
final IUserListener listener;
|
||||||
|
|
||||||
MenuUserBloc(this.iUserImpl, this.watch)
|
MenuUserBloc(this.iUserImpl, this.listener) : super(MenuUserState.initial(iUserImpl.user));
|
||||||
: super(MenuUserState.initial(iUserImpl.user));
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Stream<MenuUserState> mapEventToState(MenuUserEvent event) async* {
|
Stream<MenuUserState> mapEventToState(MenuUserEvent event) async* {
|
||||||
yield* event.map(
|
yield* event.map(
|
||||||
initial: (_) async* {
|
initial: (_) async* {
|
||||||
watch.setProfileCallback(_profileUpdated);
|
listener.setProfileCallback(_profileUpdated);
|
||||||
watch.setWorkspacesCallback(_workspacesUpdated);
|
listener.setWorkspacesCallback(_workspacesUpdated);
|
||||||
watch.startWatching();
|
listener.start();
|
||||||
|
|
||||||
await _initUser();
|
await _initUser();
|
||||||
},
|
},
|
||||||
@ -32,7 +31,7 @@ class MenuUserBloc extends Bloc<MenuUserEvent, MenuUserState> {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
Future<void> close() async {
|
Future<void> close() async {
|
||||||
await watch.stopWatching();
|
await listener.stop();
|
||||||
super.close();
|
super.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -42,8 +41,7 @@ class MenuUserBloc extends Bloc<MenuUserEvent, MenuUserState> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void _profileUpdated(Either<UserProfile, UserError> userOrFailed) {}
|
void _profileUpdated(Either<UserProfile, UserError> userOrFailed) {}
|
||||||
void _workspacesUpdated(
|
void _workspacesUpdated(Either<List<Workspace>, WorkspaceError> workspacesOrFailed) {
|
||||||
Either<List<Workspace>, WorkspaceError> workspacesOrFailed) {
|
|
||||||
// fetch workspaces
|
// fetch workspaces
|
||||||
// iUserImpl.fetchWorkspaces().then((result) {
|
// iUserImpl.fetchWorkspaces().then((result) {
|
||||||
// result.fold(
|
// result.fold(
|
||||||
|
@ -11,9 +11,8 @@ part 'welcome_bloc.freezed.dart';
|
|||||||
|
|
||||||
class WelcomeBloc extends Bloc<WelcomeEvent, WelcomeState> {
|
class WelcomeBloc extends Bloc<WelcomeEvent, WelcomeState> {
|
||||||
final UserRepo repo;
|
final UserRepo repo;
|
||||||
final IUserWatch watch;
|
final IUserListener watch;
|
||||||
WelcomeBloc({required this.repo, required this.watch})
|
WelcomeBloc({required this.repo, required this.watch}) : super(WelcomeState.initial());
|
||||||
: super(WelcomeState.initial());
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Stream<WelcomeState> mapEventToState(
|
Stream<WelcomeState> mapEventToState(
|
||||||
@ -21,7 +20,7 @@ class WelcomeBloc extends Bloc<WelcomeEvent, WelcomeState> {
|
|||||||
) async* {
|
) async* {
|
||||||
yield* event.map(initial: (e) async* {
|
yield* event.map(initial: (e) async* {
|
||||||
watch.setWorkspacesCallback(_workspacesUpdated);
|
watch.setWorkspacesCallback(_workspacesUpdated);
|
||||||
watch.startWatching();
|
watch.start();
|
||||||
//
|
//
|
||||||
yield* _fetchWorkspaces();
|
yield* _fetchWorkspaces();
|
||||||
}, openWorkspace: (e) async* {
|
}, openWorkspace: (e) async* {
|
||||||
@ -30,8 +29,7 @@ class WelcomeBloc extends Bloc<WelcomeEvent, WelcomeState> {
|
|||||||
yield* _createWorkspace(e.name, e.desc);
|
yield* _createWorkspace(e.name, e.desc);
|
||||||
}, workspacesReveived: (e) async* {
|
}, workspacesReveived: (e) async* {
|
||||||
yield e.workspacesOrFail.fold(
|
yield e.workspacesOrFail.fold(
|
||||||
(workspaces) => state.copyWith(
|
(workspaces) => state.copyWith(workspaces: workspaces, successOrFailure: left(unit)),
|
||||||
workspaces: workspaces, successOrFailure: left(unit)),
|
|
||||||
(error) => state.copyWith(successOrFailure: right(error)),
|
(error) => state.copyWith(successOrFailure: right(error)),
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
@ -39,15 +37,14 @@ class WelcomeBloc extends Bloc<WelcomeEvent, WelcomeState> {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
Future<void> close() async {
|
Future<void> close() async {
|
||||||
await watch.stopWatching();
|
await watch.stop();
|
||||||
super.close();
|
super.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
Stream<WelcomeState> _fetchWorkspaces() async* {
|
Stream<WelcomeState> _fetchWorkspaces() async* {
|
||||||
final workspacesOrFailed = await repo.getWorkspaces();
|
final workspacesOrFailed = await repo.getWorkspaces();
|
||||||
yield workspacesOrFailed.fold(
|
yield workspacesOrFailed.fold(
|
||||||
(workspaces) =>
|
(workspaces) => state.copyWith(workspaces: workspaces, successOrFailure: left(unit)),
|
||||||
state.copyWith(workspaces: workspaces, successOrFailure: left(unit)),
|
|
||||||
(error) {
|
(error) {
|
||||||
Log.error(error);
|
Log.error(error);
|
||||||
return state.copyWith(successOrFailure: right(error));
|
return state.copyWith(successOrFailure: right(error));
|
||||||
@ -80,8 +77,7 @@ class WelcomeBloc extends Bloc<WelcomeEvent, WelcomeState> {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
void _workspacesUpdated(
|
void _workspacesUpdated(Either<List<Workspace>, WorkspaceError> workspacesOrFail) {
|
||||||
Either<List<Workspace>, WorkspaceError> workspacesOrFail) {
|
|
||||||
add(WelcomeEvent.workspacesReveived(workspacesOrFail));
|
add(WelcomeEvent.workspacesReveived(workspacesOrFail));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -90,12 +86,10 @@ class WelcomeBloc extends Bloc<WelcomeEvent, WelcomeState> {
|
|||||||
class WelcomeEvent with _$WelcomeEvent {
|
class WelcomeEvent with _$WelcomeEvent {
|
||||||
const factory WelcomeEvent.initial() = Initial;
|
const factory WelcomeEvent.initial() = Initial;
|
||||||
// const factory WelcomeEvent.fetchWorkspaces() = FetchWorkspace;
|
// const factory WelcomeEvent.fetchWorkspaces() = FetchWorkspace;
|
||||||
const factory WelcomeEvent.createWorkspace(String name, String desc) =
|
const factory WelcomeEvent.createWorkspace(String name, String desc) = CreateWorkspace;
|
||||||
CreateWorkspace;
|
|
||||||
const factory WelcomeEvent.openWorkspace(Workspace workspace) = OpenWorkspace;
|
const factory WelcomeEvent.openWorkspace(Workspace workspace) = OpenWorkspace;
|
||||||
|
|
||||||
const factory WelcomeEvent.workspacesReveived(
|
const factory WelcomeEvent.workspacesReveived(Either<List<Workspace>, WorkspaceError> workspacesOrFail) =
|
||||||
Either<List<Workspace>, WorkspaceError> workspacesOrFail) =
|
|
||||||
WorkspacesReceived;
|
WorkspacesReceived;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2,23 +2,18 @@ import 'package:flowy_sdk/protobuf/flowy-workspace/protobuf.dart';
|
|||||||
import 'package:dartz/dartz.dart';
|
import 'package:dartz/dartz.dart';
|
||||||
|
|
||||||
typedef AppUpdatedCallback = void Function(String name, String desc);
|
typedef AppUpdatedCallback = void Function(String name, String desc);
|
||||||
typedef AppCreateViewCallback = void Function(
|
typedef AppCreateViewCallback = void Function(Either<List<View>, WorkspaceError> viewsOrFailed);
|
||||||
Either<List<View>, WorkspaceError> viewsOrFailed);
|
|
||||||
|
|
||||||
typedef AppDeleteViewCallback = void Function(
|
typedef AppDeleteViewCallback = void Function(Either<List<View>, WorkspaceError> viewsOrFailed);
|
||||||
Either<List<View>, WorkspaceError> viewsOrFailed);
|
|
||||||
|
|
||||||
abstract class IApp {
|
abstract class IApp {
|
||||||
Future<Either<List<View>, WorkspaceError>> getViews();
|
Future<Either<List<View>, WorkspaceError>> getViews();
|
||||||
|
|
||||||
Future<Either<View, WorkspaceError>> createView(
|
Future<Either<View, WorkspaceError>> createView({required String name, String? desc, required ViewType viewType});
|
||||||
{required String name, String? desc, required ViewType viewType});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
abstract class IAppWatch {
|
abstract class IAppListenr {
|
||||||
void startWatching(
|
void start({AppCreateViewCallback? addViewCallback, AppUpdatedCallback? updatedCallback});
|
||||||
{AppCreateViewCallback? addViewCallback,
|
|
||||||
AppUpdatedCallback? updatedCallback});
|
|
||||||
|
|
||||||
Future<void> stopWatching();
|
Future<void> stop();
|
||||||
}
|
}
|
||||||
|
@ -17,18 +17,16 @@ abstract class IUser {
|
|||||||
Future<Either<Unit, UserError>> initUser();
|
Future<Either<Unit, UserError>> initUser();
|
||||||
}
|
}
|
||||||
|
|
||||||
typedef UserProfileUpdateCallback = void Function(
|
typedef UserProfileUpdateCallback = void Function(Either<UserProfile, UserError>);
|
||||||
Either<UserProfile, UserError>);
|
|
||||||
|
|
||||||
typedef AuthChangedCallback = void Function(Either<Unit, UserError>);
|
typedef AuthChangedCallback = void Function(Either<Unit, UserError>);
|
||||||
typedef WorkspacesUpdatedCallback = void Function(
|
typedef WorkspacesUpdatedCallback = void Function(Either<List<Workspace>, WorkspaceError> workspacesOrFailed);
|
||||||
Either<List<Workspace>, WorkspaceError> workspacesOrFailed);
|
|
||||||
|
|
||||||
abstract class IUserWatch {
|
abstract class IUserListener {
|
||||||
void startWatching();
|
void start();
|
||||||
void setProfileCallback(UserProfileUpdateCallback profileCallback);
|
void setProfileCallback(UserProfileUpdateCallback profileCallback);
|
||||||
void setAuthCallback(AuthChangedCallback authCallback);
|
void setAuthCallback(AuthChangedCallback authCallback);
|
||||||
void setWorkspacesCallback(WorkspacesUpdatedCallback workspacesCallback);
|
void setWorkspacesCallback(WorkspacesUpdatedCallback workspacesCallback);
|
||||||
|
|
||||||
Future<void> stopWatching();
|
Future<void> stop();
|
||||||
}
|
}
|
||||||
|
@ -6,7 +6,7 @@ import 'package:provider/provider.dart';
|
|||||||
import 'package:app_flowy/startup/startup.dart';
|
import 'package:app_flowy/startup/startup.dart';
|
||||||
import 'package:app_flowy/workspace/presentation/stack_page/blank/blank_page.dart';
|
import 'package:app_flowy/workspace/presentation/stack_page/blank/blank_page.dart';
|
||||||
import 'package:app_flowy/workspace/presentation/stack_page/doc/doc_stack_page.dart';
|
import 'package:app_flowy/workspace/presentation/stack_page/doc/doc_stack_page.dart';
|
||||||
import 'package:app_flowy/workspace/presentation/stack_page/fading_index_stack.dart';
|
import 'package:app_flowy/workspace/presentation/stack_page/home_stack.dart';
|
||||||
import 'package:app_flowy/workspace/presentation/widgets/prelude.dart';
|
import 'package:app_flowy/workspace/presentation/widgets/prelude.dart';
|
||||||
|
|
||||||
typedef NavigationCallback = void Function(String id);
|
typedef NavigationCallback = void Function(String id);
|
||||||
@ -16,7 +16,7 @@ abstract class NavigationItem {
|
|||||||
String get identifier;
|
String get identifier;
|
||||||
|
|
||||||
NavigationCallback get action => (id) {
|
NavigationCallback get action => (id) {
|
||||||
getIt<HomeStack>().setStackWithId(id);
|
getIt<HomeStackManager>().setStackWithId(id);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -37,17 +37,17 @@ abstract class HomeStackContext extends Equatable with NavigationItem {
|
|||||||
HomeStackContext stackCtxFromView(View view) {
|
HomeStackContext stackCtxFromView(View view) {
|
||||||
switch (view.viewType) {
|
switch (view.viewType) {
|
||||||
case ViewType.Blank:
|
case ViewType.Blank:
|
||||||
return DefaultHomeStackContext();
|
return BlankStackContext();
|
||||||
case ViewType.Doc:
|
case ViewType.Doc:
|
||||||
return DocStackContext(view: view);
|
return DocStackContext(view: view);
|
||||||
default:
|
default:
|
||||||
return DefaultHomeStackContext();
|
return BlankStackContext();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class HomeStackNotifier extends ChangeNotifier {
|
class HomeStackNotifier extends ChangeNotifier {
|
||||||
HomeStackContext inner;
|
HomeStackContext inner;
|
||||||
HomeStackNotifier({HomeStackContext? context}) : inner = context ?? DefaultHomeStackContext();
|
HomeStackNotifier({HomeStackContext? context}) : inner = context ?? BlankStackContext();
|
||||||
|
|
||||||
set context(HomeStackContext context) {
|
set context(HomeStackContext context) {
|
||||||
inner = context;
|
inner = context;
|
||||||
@ -58,9 +58,9 @@ class HomeStackNotifier extends ChangeNotifier {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// HomeStack is initialized as singleton to controll the page stack.
|
// HomeStack is initialized as singleton to controll the page stack.
|
||||||
class HomeStack {
|
class HomeStackManager {
|
||||||
final HomeStackNotifier _notifier = HomeStackNotifier();
|
final HomeStackNotifier _notifier = HomeStackNotifier();
|
||||||
HomeStack();
|
HomeStackManager();
|
||||||
|
|
||||||
String title() {
|
String title() {
|
||||||
return _notifier.context.title;
|
return _notifier.context.title;
|
||||||
@ -95,7 +95,7 @@ class HomeStack {
|
|||||||
if (viewType == notifier.context.type) {
|
if (viewType == notifier.context.type) {
|
||||||
return notifier.context.render();
|
return notifier.context.render();
|
||||||
} else {
|
} else {
|
||||||
return const AnnouncementStackPage();
|
return const BlankStackPage();
|
||||||
}
|
}
|
||||||
}).toList(),
|
}).toList(),
|
||||||
);
|
);
|
||||||
|
@ -1,10 +1,10 @@
|
|||||||
import 'package:app_flowy/workspace/application/app/app_bloc.dart';
|
import 'package:app_flowy/workspace/application/app/app_bloc.dart';
|
||||||
import 'package:app_flowy/workspace/application/app/app_watch_bloc.dart';
|
import 'package:app_flowy/workspace/application/app/app_listen_bloc.dart';
|
||||||
import 'package:app_flowy/workspace/application/doc/doc_bloc.dart';
|
import 'package:app_flowy/workspace/application/doc/doc_bloc.dart';
|
||||||
import 'package:app_flowy/workspace/application/doc/doc_edit_bloc.dart';
|
import 'package:app_flowy/workspace/application/doc/doc_edit_bloc.dart';
|
||||||
import 'package:app_flowy/workspace/application/menu/menu_bloc.dart';
|
import 'package:app_flowy/workspace/application/menu/menu_bloc.dart';
|
||||||
import 'package:app_flowy/workspace/application/menu/menu_user_bloc.dart';
|
import 'package:app_flowy/workspace/application/menu/menu_user_bloc.dart';
|
||||||
import 'package:app_flowy/workspace/application/menu/menu_watch.dart';
|
import 'package:app_flowy/workspace/application/menu/menu_listen.dart';
|
||||||
import 'package:app_flowy/workspace/application/view/view_bloc.dart';
|
import 'package:app_flowy/workspace/application/view/view_bloc.dart';
|
||||||
import 'package:app_flowy/workspace/application/view/view_list_bloc.dart';
|
import 'package:app_flowy/workspace/application/view/view_list_bloc.dart';
|
||||||
import 'package:app_flowy/workspace/application/workspace/welcome_bloc.dart';
|
import 'package:app_flowy/workspace/application/workspace/welcome_bloc.dart';
|
||||||
@ -28,11 +28,11 @@ import 'i_view_impl.dart';
|
|||||||
class HomeDepsResolver {
|
class HomeDepsResolver {
|
||||||
static Future<void> resolve(GetIt getIt) async {
|
static Future<void> resolve(GetIt getIt) async {
|
||||||
//
|
//
|
||||||
getIt.registerLazySingleton<HomeStack>(() => HomeStack());
|
getIt.registerLazySingleton<HomeStackManager>(() => HomeStackManager());
|
||||||
|
|
||||||
//App
|
//App
|
||||||
getIt.registerFactoryParam<IApp, String, void>((appId, _) => IAppImpl(repo: AppRepository(appId: appId)));
|
getIt.registerFactoryParam<IApp, String, void>((appId, _) => IAppImpl(repo: AppRepository(appId: appId)));
|
||||||
getIt.registerFactoryParam<IAppWatch, String, void>(
|
getIt.registerFactoryParam<IAppListenr, String, void>(
|
||||||
(appId, _) => IAppWatchImpl(repo: AppWatchRepository(appId: appId)));
|
(appId, _) => IAppWatchImpl(repo: AppWatchRepository(appId: appId)));
|
||||||
|
|
||||||
//workspace
|
//workspace
|
||||||
@ -51,20 +51,21 @@ class HomeDepsResolver {
|
|||||||
|
|
||||||
// User
|
// User
|
||||||
getIt.registerFactoryParam<IUser, UserProfile, void>((user, _) => IUserImpl(repo: UserRepo(user: user)));
|
getIt.registerFactoryParam<IUser, UserProfile, void>((user, _) => IUserImpl(repo: UserRepo(user: user)));
|
||||||
getIt.registerFactoryParam<IUserWatch, UserProfile, void>((user, _) => IUserWatchImpl(user: user));
|
getIt.registerFactoryParam<IUserListener, UserProfile, void>((user, _) => IUserWatchImpl(user: user));
|
||||||
|
|
||||||
//Menu Bloc
|
//Menu Bloc
|
||||||
getIt.registerFactoryParam<MenuBloc, UserProfile, String>(
|
getIt.registerFactoryParam<MenuBloc, UserProfile, String>(
|
||||||
(user, workspaceId) => MenuBloc(getIt<IWorkspace>(param1: user, param2: workspaceId)));
|
(user, workspaceId) => MenuBloc(getIt<IWorkspace>(param1: user, param2: workspaceId)));
|
||||||
getIt.registerFactoryParam<MenuWatchBloc, UserProfile, String>(
|
getIt.registerFactoryParam<MenuListenBloc, UserProfile, String>(
|
||||||
(user, workspaceId) => MenuWatchBloc(getIt<IWorkspaceWatch>(param1: user, param2: workspaceId)));
|
(user, workspaceId) => MenuListenBloc(getIt<IWorkspaceWatch>(param1: user, param2: workspaceId)));
|
||||||
|
|
||||||
getIt.registerFactoryParam<MenuUserBloc, UserProfile, void>(
|
getIt.registerFactoryParam<MenuUserBloc, UserProfile, void>(
|
||||||
(user, _) => MenuUserBloc(getIt<IUser>(param1: user), getIt<IUserWatch>(param1: user)));
|
(user, _) => MenuUserBloc(getIt<IUser>(param1: user), getIt<IUserListener>(param1: user)));
|
||||||
|
|
||||||
//
|
//
|
||||||
getIt.registerFactoryParam<AppBloc, String, void>((appId, _) => AppBloc(getIt<IApp>(param1: appId)));
|
getIt.registerFactoryParam<AppBloc, String, void>((appId, _) => AppBloc(getIt<IApp>(param1: appId)));
|
||||||
getIt.registerFactoryParam<AppWatchBloc, String, void>((appId, _) => AppWatchBloc(getIt<IAppWatch>(param1: appId)));
|
getIt.registerFactoryParam<AppListenBloc, String, void>(
|
||||||
|
(appId, _) => AppListenBloc(getIt<IAppListenr>(param1: appId)));
|
||||||
|
|
||||||
getIt
|
getIt
|
||||||
.registerFactoryParam<ViewBloc, String, void>((viewId, _) => ViewBloc(iViewImpl: getIt<IView>(param1: viewId)));
|
.registerFactoryParam<ViewBloc, String, void>((viewId, _) => ViewBloc(iViewImpl: getIt<IView>(param1: viewId)));
|
||||||
@ -79,7 +80,7 @@ class HomeDepsResolver {
|
|||||||
getIt.registerFactoryParam<WelcomeBloc, UserProfile, void>(
|
getIt.registerFactoryParam<WelcomeBloc, UserProfile, void>(
|
||||||
(user, _) => WelcomeBloc(
|
(user, _) => WelcomeBloc(
|
||||||
repo: UserRepo(user: user),
|
repo: UserRepo(user: user),
|
||||||
watch: getIt<IUserWatch>(param1: user),
|
watch: getIt<IUserListener>(param1: user),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -28,21 +28,19 @@ class IAppImpl extends IApp {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class IAppWatchImpl extends IAppWatch {
|
class IAppWatchImpl extends IAppListenr {
|
||||||
AppWatchRepository repo;
|
AppWatchRepository repo;
|
||||||
IAppWatchImpl({
|
IAppWatchImpl({
|
||||||
required this.repo,
|
required this.repo,
|
||||||
});
|
});
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void startWatching(
|
void start({AppCreateViewCallback? addViewCallback, AppUpdatedCallback? updatedCallback}) {
|
||||||
{AppCreateViewCallback? addViewCallback,
|
|
||||||
AppUpdatedCallback? updatedCallback}) {
|
|
||||||
repo.startWatching(createView: addViewCallback, update: updatedCallback);
|
repo.startWatching(createView: addViewCallback, update: updatedCallback);
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Future<void> stopWatching() async {
|
Future<void> stop() async {
|
||||||
await repo.close();
|
await repo.close();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -49,7 +49,7 @@ class IUserImpl extends IUser {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class IUserWatchImpl extends IUserWatch {
|
class IUserWatchImpl extends IUserListener {
|
||||||
StreamSubscription<ObservableSubject>? _subscription;
|
StreamSubscription<ObservableSubject>? _subscription;
|
||||||
WorkspacesUpdatedCallback? _workspacesUpdated;
|
WorkspacesUpdatedCallback? _workspacesUpdated;
|
||||||
AuthChangedCallback? _authChanged;
|
AuthChangedCallback? _authChanged;
|
||||||
@ -65,12 +65,10 @@ class IUserWatchImpl extends IUserWatch {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void startWatching() {
|
void start() {
|
||||||
_workspaceParser = WorkspaceObservableParser(
|
_workspaceParser = WorkspaceObservableParser(id: _user.token, callback: _workspaceObservableCallback);
|
||||||
id: _user.token, callback: _workspaceObservableCallback);
|
|
||||||
|
|
||||||
_userParser = UserObservableParser(
|
_userParser = UserObservableParser(id: _user.token, callback: _userObservableCallback);
|
||||||
id: _user.token, callback: _userObservableCallback);
|
|
||||||
|
|
||||||
_subscription = RustStreamReceiver.listen((observable) {
|
_subscription = RustStreamReceiver.listen((observable) {
|
||||||
_workspaceParser.parse(observable);
|
_workspaceParser.parse(observable);
|
||||||
@ -79,7 +77,7 @@ class IUserWatchImpl extends IUserWatch {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Future<void> stopWatching() async {
|
Future<void> stop() async {
|
||||||
await _subscription?.cancel();
|
await _subscription?.cancel();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -98,8 +96,7 @@ class IUserWatchImpl extends IUserWatch {
|
|||||||
_workspacesUpdated = workspacesCallback;
|
_workspacesUpdated = workspacesCallback;
|
||||||
}
|
}
|
||||||
|
|
||||||
void _workspaceObservableCallback(
|
void _workspaceObservableCallback(WorkspaceObservable ty, Either<Uint8List, WorkspaceError> result) {
|
||||||
WorkspaceObservable ty, Either<Uint8List, WorkspaceError> result) {
|
|
||||||
switch (ty) {
|
switch (ty) {
|
||||||
case WorkspaceObservable.UserCreateWorkspace:
|
case WorkspaceObservable.UserCreateWorkspace:
|
||||||
case WorkspaceObservable.UserDeleteWorkspace:
|
case WorkspaceObservable.UserDeleteWorkspace:
|
||||||
@ -118,10 +115,7 @@ class IUserWatchImpl extends IUserWatch {
|
|||||||
if (_authChanged != null) {
|
if (_authChanged != null) {
|
||||||
result.fold(
|
result.fold(
|
||||||
(_) {},
|
(_) {},
|
||||||
(error) => {
|
(error) => {_authChanged!(right(UserError.create()..code = user_error.ErrorCode.UserUnauthorized))},
|
||||||
_authChanged!(right(UserError.create()
|
|
||||||
..code = user_error.ErrorCode.UserUnauthorized))
|
|
||||||
},
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@ -130,8 +124,7 @@ class IUserWatchImpl extends IUserWatch {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void _userObservableCallback(
|
void _userObservableCallback(user.UserObservable ty, Either<Uint8List, UserError> result) {
|
||||||
user.UserObservable ty, Either<Uint8List, UserError> result) {
|
|
||||||
switch (ty) {
|
switch (ty) {
|
||||||
case user.UserObservable.UserUnauthorized:
|
case user.UserObservable.UserUnauthorized:
|
||||||
if (_profileUpdated != null) {
|
if (_profileUpdated != null) {
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
import 'package:app_flowy/workspace/application/home/home_bloc.dart';
|
import 'package:app_flowy/workspace/application/home/home_bloc.dart';
|
||||||
import 'package:app_flowy/workspace/application/home/home_auth_bloc.dart';
|
import 'package:app_flowy/workspace/application/home/home_listen_bloc.dart';
|
||||||
import 'package:app_flowy/workspace/domain/page_stack/page_stack.dart';
|
import 'package:app_flowy/workspace/domain/page_stack/page_stack.dart';
|
||||||
|
import 'package:app_flowy/workspace/presentation/stack_page/home_stack.dart';
|
||||||
import 'package:app_flowy/workspace/presentation/widgets/prelude.dart';
|
import 'package:app_flowy/workspace/presentation/widgets/prelude.dart';
|
||||||
import 'package:app_flowy/startup/startup.dart';
|
import 'package:app_flowy/startup/startup.dart';
|
||||||
import 'package:flowy_log/flowy_log.dart';
|
import 'package:flowy_log/flowy_log.dart';
|
||||||
@ -12,6 +13,29 @@ import 'package:styled_widget/styled_widget.dart';
|
|||||||
|
|
||||||
import 'home_layout.dart';
|
import 'home_layout.dart';
|
||||||
|
|
||||||
|
// [[diagram: Home's widget structure]]
|
||||||
|
// 1.start listening user auth state
|
||||||
|
// ┌────────────────┐ ┌──────────────┐
|
||||||
|
// ┌─▶│ HomeListenBloc │────────▶│IUserListener │
|
||||||
|
// │ └────────────────┘ └──────────────┘
|
||||||
|
// ┌────────────┐ │
|
||||||
|
// │ HomeScreen │──┤
|
||||||
|
// └────────────┘ │ ┌──────────────┐
|
||||||
|
// │ ┌───▶│ BlocListener │
|
||||||
|
// │ │ └──────────────┘
|
||||||
|
// │ ┌─────────┐ │ ┌──────────┐
|
||||||
|
// └─▶│HomeBloc │────┤ ┌───▶│HomeStack │
|
||||||
|
// └─────────┘ │ │ └──────────┘
|
||||||
|
// │ ┌──────────────┐ │ ┌──────────┐
|
||||||
|
// └──▶│ BlocBuilder │───┼───▶│ HomeMenu │
|
||||||
|
// └──────────────┘ │ └──────────┘
|
||||||
|
// │ ┌──────────┐
|
||||||
|
// 2.1 show login screen if user └───▶│EditPannel│
|
||||||
|
// session is invalid └──────────┘
|
||||||
|
//
|
||||||
|
// 2.2 build home screen
|
||||||
|
//
|
||||||
|
//
|
||||||
class HomeScreen extends StatelessWidget {
|
class HomeScreen extends StatelessWidget {
|
||||||
static GlobalKey<ScaffoldState> scaffoldKey = GlobalKey();
|
static GlobalKey<ScaffoldState> scaffoldKey = GlobalKey();
|
||||||
final UserProfile user;
|
final UserProfile user;
|
||||||
@ -22,14 +46,14 @@ class HomeScreen extends StatelessWidget {
|
|||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return MultiBlocProvider(
|
return MultiBlocProvider(
|
||||||
providers: [
|
providers: [
|
||||||
BlocProvider<HomeAuthBloc>(
|
BlocProvider<HomeListenBloc>(
|
||||||
create: (context) => getIt<HomeAuthBloc>(param1: user)..add(const HomeAuthEvent.started()),
|
create: (context) => getIt<HomeListenBloc>(param1: user)..add(const HomeListenEvent.started()),
|
||||||
),
|
),
|
||||||
BlocProvider<HomeBloc>(create: (context) => getIt<HomeBloc>()),
|
BlocProvider<HomeBloc>(create: (context) => getIt<HomeBloc>()),
|
||||||
],
|
],
|
||||||
child: Scaffold(
|
child: Scaffold(
|
||||||
key: HomeScreen.scaffoldKey,
|
key: HomeScreen.scaffoldKey,
|
||||||
body: BlocListener<HomeAuthBloc, HomeAuthState>(
|
body: BlocListener<HomeListenBloc, HomeListenState>(
|
||||||
listener: (context, state) {
|
listener: (context, state) {
|
||||||
state.map(
|
state.map(
|
||||||
loading: (_) {},
|
loading: (_) {},
|
||||||
@ -58,7 +82,7 @@ class HomeScreen extends StatelessWidget {
|
|||||||
return LayoutBuilder(
|
return LayoutBuilder(
|
||||||
builder: (BuildContext context, BoxConstraints constraints) {
|
builder: (BuildContext context, BoxConstraints constraints) {
|
||||||
final layout = HomeLayout(context, constraints, forceCollapse);
|
final layout = HomeLayout(context, constraints, forceCollapse);
|
||||||
const homePage = HomePage();
|
const homeStack = HomeStack();
|
||||||
final menu = _buildHomeMenu(
|
final menu = _buildHomeMenu(
|
||||||
layout: layout,
|
layout: layout,
|
||||||
context: context,
|
context: context,
|
||||||
@ -68,7 +92,7 @@ class HomeScreen extends StatelessWidget {
|
|||||||
layout: layout,
|
layout: layout,
|
||||||
context: context,
|
context: context,
|
||||||
);
|
);
|
||||||
return _layoutWidgets(layout: layout, homePage: homePage, homeMenu: menu, editPannel: editPannel);
|
return _layoutWidgets(layout: layout, homeStack: homeStack, homeMenu: menu, editPannel: editPannel);
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -77,7 +101,7 @@ class HomeScreen extends StatelessWidget {
|
|||||||
final homeBloc = context.read<HomeBloc>();
|
final homeBloc = context.read<HomeBloc>();
|
||||||
Widget homeMenu = HomeMenu(
|
Widget homeMenu = HomeMenu(
|
||||||
pageContextChanged: (pageContext) {
|
pageContextChanged: (pageContext) {
|
||||||
getIt<HomeStack>().setStack(pageContext);
|
getIt<HomeStackManager>().setStack(pageContext);
|
||||||
},
|
},
|
||||||
isCollapseChanged: (isCollapse) {
|
isCollapseChanged: (isCollapse) {
|
||||||
homeBloc.add(HomeEvent.forceCollapse(isCollapse));
|
homeBloc.add(HomeEvent.forceCollapse(isCollapse));
|
||||||
@ -102,7 +126,7 @@ class HomeScreen extends StatelessWidget {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Widget _layoutWidgets(
|
Widget _layoutWidgets(
|
||||||
{required HomeLayout layout, required Widget homeMenu, required Widget homePage, required Widget editPannel}) {
|
{required HomeLayout layout, required Widget homeMenu, required Widget homeStack, required Widget editPannel}) {
|
||||||
return Stack(
|
return Stack(
|
||||||
children: [
|
children: [
|
||||||
homeMenu
|
homeMenu
|
||||||
@ -112,7 +136,7 @@ class HomeScreen extends StatelessWidget {
|
|||||||
)
|
)
|
||||||
.positioned(left: 0, top: 0, width: layout.menuWidth, bottom: 0, animate: true)
|
.positioned(left: 0, top: 0, width: layout.menuWidth, bottom: 0, animate: true)
|
||||||
.animate(layout.animDuration, Curves.easeOut),
|
.animate(layout.animDuration, Curves.easeOut),
|
||||||
homePage
|
homeStack
|
||||||
.constrained(minWidth: 500)
|
.constrained(minWidth: 500)
|
||||||
.positioned(left: layout.homePageLOffset, right: layout.homePageROffset, bottom: 0, top: 0, animate: true)
|
.positioned(left: layout.homePageLOffset, right: layout.homePageROffset, bottom: 0, top: 0, animate: true)
|
||||||
.animate(layout.animDuration, Curves.easeOut),
|
.animate(layout.animDuration, Curves.easeOut),
|
||||||
@ -127,28 +151,3 @@ class HomeScreen extends StatelessWidget {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class HomePage extends StatelessWidget {
|
|
||||||
static GlobalKey<ScaffoldState> scaffoldKey = GlobalKey();
|
|
||||||
// final Size size;
|
|
||||||
const HomePage({Key? key}) : super(key: key);
|
|
||||||
|
|
||||||
@override
|
|
||||||
Widget build(BuildContext context) {
|
|
||||||
Log.info('HomePage build');
|
|
||||||
return Column(
|
|
||||||
mainAxisAlignment: MainAxisAlignment.start,
|
|
||||||
children: [
|
|
||||||
getIt<HomeStack>().stackTopBar(),
|
|
||||||
Expanded(
|
|
||||||
child: Container(
|
|
||||||
color: Colors.white,
|
|
||||||
child: FocusTraversalGroup(
|
|
||||||
child: getIt<HomeStack>().stackWidget(),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
@ -18,7 +18,7 @@ class NavigationNotifier with ChangeNotifier {
|
|||||||
List<NavigationItem> get naviItems => homeStackNotifier.context.navigationItems;
|
List<NavigationItem> get naviItems => homeStackNotifier.context.navigationItems;
|
||||||
}
|
}
|
||||||
|
|
||||||
// [[Navigation]]
|
// [[diagram: HomeStack navigation flow]]
|
||||||
// ┌───────────────────────┐
|
// ┌───────────────────────┐
|
||||||
// 2.notify listeners ┌──────│DefaultHomeStackContext│
|
// 2.notify listeners ┌──────│DefaultHomeStackContext│
|
||||||
// ┌────────────────┐ ┌───────────┐ ┌────────────────┐ │ └───────────────────────┘
|
// ┌────────────────┐ ┌───────────┐ ┌────────────────┐ │ └───────────────────────┘
|
||||||
|
@ -2,7 +2,7 @@ import 'package:app_flowy/workspace/domain/page_stack/page_stack.dart';
|
|||||||
import 'package:flowy_sdk/protobuf/flowy-workspace/view_create.pb.dart';
|
import 'package:flowy_sdk/protobuf/flowy-workspace/view_create.pb.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
class DefaultHomeStackContext extends HomeStackContext {
|
class BlankStackContext extends HomeStackContext {
|
||||||
@override
|
@override
|
||||||
String get identifier => "1";
|
String get identifier => "1";
|
||||||
|
|
||||||
@ -17,21 +17,21 @@ class DefaultHomeStackContext extends HomeStackContext {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
Widget render() {
|
Widget render() {
|
||||||
return const AnnouncementStackPage();
|
return const BlankStackPage();
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
List<NavigationItem> get navigationItems => [this];
|
List<NavigationItem> get navigationItems => [this];
|
||||||
}
|
}
|
||||||
|
|
||||||
class AnnouncementStackPage extends StatefulWidget {
|
class BlankStackPage extends StatefulWidget {
|
||||||
const AnnouncementStackPage({Key? key}) : super(key: key);
|
const BlankStackPage({Key? key}) : super(key: key);
|
||||||
|
|
||||||
@override
|
@override
|
||||||
State<AnnouncementStackPage> createState() => _AnnouncementPage();
|
State<BlankStackPage> createState() => _AnnouncementPage();
|
||||||
}
|
}
|
||||||
|
|
||||||
class _AnnouncementPage extends State<AnnouncementStackPage> {
|
class _AnnouncementPage extends State<BlankStackPage> {
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return SizedBox.expand(
|
return SizedBox.expand(
|
||||||
|
@ -1,44 +0,0 @@
|
|||||||
import 'package:flutter/material.dart';
|
|
||||||
import 'package:time/time.dart';
|
|
||||||
|
|
||||||
class FadingIndexedStack extends StatefulWidget {
|
|
||||||
final int index;
|
|
||||||
final List<Widget> children;
|
|
||||||
final Duration duration;
|
|
||||||
|
|
||||||
const FadingIndexedStack({
|
|
||||||
Key? key,
|
|
||||||
required this.index,
|
|
||||||
required this.children,
|
|
||||||
this.duration = const Duration(
|
|
||||||
milliseconds: 250,
|
|
||||||
),
|
|
||||||
}) : super(key: key);
|
|
||||||
|
|
||||||
@override
|
|
||||||
_FadingIndexedStackState createState() => _FadingIndexedStackState();
|
|
||||||
}
|
|
||||||
|
|
||||||
class _FadingIndexedStackState extends State<FadingIndexedStack> {
|
|
||||||
double _targetOpacity = 1;
|
|
||||||
|
|
||||||
@override
|
|
||||||
void didUpdateWidget(FadingIndexedStack oldWidget) {
|
|
||||||
if (oldWidget.index == widget.index) return;
|
|
||||||
setState(() => _targetOpacity = 0);
|
|
||||||
Future.delayed(1.milliseconds, () => setState(() => _targetOpacity = 1));
|
|
||||||
super.didUpdateWidget(oldWidget);
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
Widget build(BuildContext context) {
|
|
||||||
return TweenAnimationBuilder<double>(
|
|
||||||
duration: _targetOpacity > 0 ? widget.duration : 0.milliseconds,
|
|
||||||
tween: Tween(begin: 0, end: _targetOpacity),
|
|
||||||
builder: (_, value, child) {
|
|
||||||
return Opacity(opacity: value, child: child);
|
|
||||||
},
|
|
||||||
child: IndexedStack(index: widget.index, children: widget.children),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
@ -0,0 +1,83 @@
|
|||||||
|
import 'package:app_flowy/startup/startup.dart';
|
||||||
|
import 'package:app_flowy/workspace/domain/page_stack/page_stack.dart';
|
||||||
|
import 'package:flowy_log/flowy_log.dart';
|
||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:time/time.dart';
|
||||||
|
|
||||||
|
// [[diagram: HomeStack's widget structure]]
|
||||||
|
//
|
||||||
|
// ┌──────────────────┐ ┌───────────────┐
|
||||||
|
// ┌──│BlankStackContext │──▶│BlankStackPage │
|
||||||
|
// ┌──────────┐ ┌───────────────────┐ ┌─────────────────┐ │ └──────────────────┘ └───────────────┘
|
||||||
|
// │HomeStack │─▶│ HomeStackManager │──▶│HomeStackContext │◀─┤
|
||||||
|
// └──────────┘ └───────────────────┘ └─────────────────┘ │ ┌─────────────────┐ ┌────────────┐
|
||||||
|
// └──│ DocStackContext │───▶│DocStackPage│
|
||||||
|
// └─────────────────┘ └────────────┘
|
||||||
|
//
|
||||||
|
//
|
||||||
|
class HomeStack extends StatelessWidget {
|
||||||
|
static GlobalKey<ScaffoldState> scaffoldKey = GlobalKey();
|
||||||
|
// final Size size;
|
||||||
|
const HomeStack({Key? key}) : super(key: key);
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
Log.info('HomePage build');
|
||||||
|
return Column(
|
||||||
|
mainAxisAlignment: MainAxisAlignment.start,
|
||||||
|
children: [
|
||||||
|
getIt<HomeStackManager>().stackTopBar(),
|
||||||
|
Expanded(
|
||||||
|
child: Container(
|
||||||
|
color: Colors.white,
|
||||||
|
child: FocusTraversalGroup(
|
||||||
|
child: getIt<HomeStackManager>().stackWidget(),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class FadingIndexedStack extends StatefulWidget {
|
||||||
|
final int index;
|
||||||
|
final List<Widget> children;
|
||||||
|
final Duration duration;
|
||||||
|
|
||||||
|
const FadingIndexedStack({
|
||||||
|
Key? key,
|
||||||
|
required this.index,
|
||||||
|
required this.children,
|
||||||
|
this.duration = const Duration(
|
||||||
|
milliseconds: 250,
|
||||||
|
),
|
||||||
|
}) : super(key: key);
|
||||||
|
|
||||||
|
@override
|
||||||
|
_FadingIndexedStackState createState() => _FadingIndexedStackState();
|
||||||
|
}
|
||||||
|
|
||||||
|
class _FadingIndexedStackState extends State<FadingIndexedStack> {
|
||||||
|
double _targetOpacity = 1;
|
||||||
|
|
||||||
|
@override
|
||||||
|
void didUpdateWidget(FadingIndexedStack oldWidget) {
|
||||||
|
if (oldWidget.index == widget.index) return;
|
||||||
|
setState(() => _targetOpacity = 0);
|
||||||
|
Future.delayed(1.milliseconds, () => setState(() => _targetOpacity = 1));
|
||||||
|
super.didUpdateWidget(oldWidget);
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return TweenAnimationBuilder<double>(
|
||||||
|
duration: _targetOpacity > 0 ? widget.duration : 0.milliseconds,
|
||||||
|
tween: Tween(begin: 0, end: _targetOpacity),
|
||||||
|
builder: (_, value, child) {
|
||||||
|
return Opacity(opacity: value, child: child);
|
||||||
|
},
|
||||||
|
child: IndexedStack(index: widget.index, children: widget.children),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
@ -8,17 +8,40 @@ import 'package:flowy_sdk/protobuf/flowy-workspace/app_create.pb.dart';
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||||
import 'package:styled_widget/styled_widget.dart';
|
import 'package:styled_widget/styled_widget.dart';
|
||||||
|
import 'package:expandable/expandable.dart';
|
||||||
|
import 'package:flowy_infra/time/duration.dart';
|
||||||
import 'package:app_flowy/startup/startup.dart';
|
import 'package:app_flowy/startup/startup.dart';
|
||||||
import 'package:app_flowy/workspace/application/menu/menu_bloc.dart';
|
import 'package:app_flowy/workspace/application/menu/menu_bloc.dart';
|
||||||
import 'package:app_flowy/workspace/application/menu/menu_watch.dart';
|
import 'package:app_flowy/workspace/application/menu/menu_listen.dart';
|
||||||
import 'package:app_flowy/workspace/domain/page_stack/page_stack.dart';
|
import 'package:app_flowy/workspace/domain/page_stack/page_stack.dart';
|
||||||
import 'package:app_flowy/workspace/presentation/widgets/menu/widget/user.dart';
|
import 'package:app_flowy/workspace/presentation/widgets/menu/widget/menu_user.dart';
|
||||||
|
|
||||||
import 'menu_list.dart';
|
import 'widget/app/menu_app.dart';
|
||||||
import 'widget/app/app.dart';
|
|
||||||
import 'widget/app/create_button.dart';
|
import 'widget/app/create_button.dart';
|
||||||
|
|
||||||
|
// [[diagram: HomeMenu's widget structure]]
|
||||||
|
// get user profile or modify user
|
||||||
|
// ┌──────┐
|
||||||
|
// ┌──────────┐ ┌──▶│IUser │
|
||||||
|
// ┌─▶│MenuTopBar│ ┌────────┐ ┌─────────────┐ │ └──────┘
|
||||||
|
// │ └──────────┘ ┌───│MenuUser│─▶│MenuUserBloc │──┤
|
||||||
|
// ┌──────────┐ │ │ └────────┘ └─────────────┘ │ ┌─────────────┐
|
||||||
|
// │ HomeMenu │─┤ │ └──▶│IUserListener│
|
||||||
|
// └──────────┘ │ │ └─────────────┘
|
||||||
|
// │ │ listen workspace changes or user
|
||||||
|
// │ impl │ profile changes
|
||||||
|
// │ ┌──────────┐ ┌─────────┐ │
|
||||||
|
// └─▶│ MenuList │───▶│MenuItem │◀─┤
|
||||||
|
// └──────────┘ └─────────┘ │ ┌────────┐
|
||||||
|
// │ ┌─▶│AppBloc │ fetch app's views or modify view
|
||||||
|
// │ │ └────────┘
|
||||||
|
// │ ┌────────┐ │
|
||||||
|
// └───│MenuApp │──┤
|
||||||
|
// └────────┘ │
|
||||||
|
// │ ┌──────────────┐
|
||||||
|
// └─▶│AppListenBloc │ Receive view changes
|
||||||
|
// └──────────────┘
|
||||||
|
|
||||||
class HomeMenu extends StatelessWidget {
|
class HomeMenu extends StatelessWidget {
|
||||||
final Function(HomeStackContext) pageContextChanged;
|
final Function(HomeStackContext) pageContextChanged;
|
||||||
final Function(bool) isCollapseChanged;
|
final Function(bool) isCollapseChanged;
|
||||||
@ -41,7 +64,7 @@ class HomeMenu extends StatelessWidget {
|
|||||||
create: (context) => getIt<MenuBloc>(param1: user, param2: workspaceId)..add(const MenuEvent.initial())),
|
create: (context) => getIt<MenuBloc>(param1: user, param2: workspaceId)..add(const MenuEvent.initial())),
|
||||||
BlocProvider(
|
BlocProvider(
|
||||||
create: (context) =>
|
create: (context) =>
|
||||||
getIt<MenuWatchBloc>(param1: user, param2: workspaceId)..add(const MenuWatchEvent.started())),
|
getIt<MenuListenBloc>(param1: user, param2: workspaceId)..add(const MenuListenEvent.started())),
|
||||||
],
|
],
|
||||||
child: MultiBlocListener(
|
child: MultiBlocListener(
|
||||||
listeners: [
|
listeners: [
|
||||||
@ -85,7 +108,7 @@ class HomeMenu extends StatelessWidget {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Widget _renderMenuList(BuildContext context) {
|
Widget _renderMenuList(BuildContext context) {
|
||||||
return BlocBuilder<MenuWatchBloc, MenuWatchState>(
|
return BlocBuilder<MenuListenBloc, MenuListenState>(
|
||||||
builder: (context, state) {
|
builder: (context, state) {
|
||||||
return state.map(
|
return state.map(
|
||||||
initial: (_) => MenuList(
|
initial: (_) => MenuList(
|
||||||
@ -128,7 +151,7 @@ class MenuItemBuilder {
|
|||||||
MenuItemBuilder withApps(Option<List<App>> someApps) {
|
MenuItemBuilder withApps(Option<List<App>> someApps) {
|
||||||
List<MenuItem> appWidgets = someApps.foldRight(
|
List<MenuItem> appWidgets = someApps.foldRight(
|
||||||
[],
|
[],
|
||||||
(apps, _) => apps.map((app) => AppPage(AppPageContext(app))).toList(),
|
(apps, _) => apps.map((app) => MenuApp(MenuAppContext(app))).toList(),
|
||||||
);
|
);
|
||||||
items.addAll(appWidgets);
|
items.addAll(appWidgets);
|
||||||
return this;
|
return this;
|
||||||
@ -138,3 +161,44 @@ class MenuItemBuilder {
|
|||||||
return items;
|
return items;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
enum MenuItemType {
|
||||||
|
userProfile,
|
||||||
|
dashboard,
|
||||||
|
favorites,
|
||||||
|
app,
|
||||||
|
}
|
||||||
|
|
||||||
|
abstract class MenuItem extends StatelessWidget {
|
||||||
|
const MenuItem({Key? key}) : super(key: key);
|
||||||
|
|
||||||
|
MenuItemType get type;
|
||||||
|
}
|
||||||
|
|
||||||
|
class MenuList extends StatelessWidget {
|
||||||
|
final List<MenuItem> menuItems;
|
||||||
|
const MenuList({required this.menuItems, Key? key}) : super(key: key);
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return ExpandableTheme(
|
||||||
|
data: ExpandableThemeData(useInkWell: true, animationDuration: Durations.medium),
|
||||||
|
child: Expanded(
|
||||||
|
child: ListView.separated(
|
||||||
|
itemCount: menuItems.length,
|
||||||
|
separatorBuilder: (context, index) {
|
||||||
|
if (index == 0) {
|
||||||
|
return const VSpace(29);
|
||||||
|
} else {
|
||||||
|
return const VSpace(24);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
physics: const BouncingScrollPhysics(),
|
||||||
|
itemBuilder: (BuildContext context, int index) {
|
||||||
|
return menuItems[index];
|
||||||
|
},
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
@ -1,45 +0,0 @@
|
|||||||
import 'package:expandable/expandable.dart';
|
|
||||||
import 'package:flowy_infra_ui/widget/spacing.dart';
|
|
||||||
import 'package:flowy_infra/time/duration.dart';
|
|
||||||
import 'package:flutter/material.dart';
|
|
||||||
|
|
||||||
enum MenuItemType {
|
|
||||||
userProfile,
|
|
||||||
dashboard,
|
|
||||||
favorites,
|
|
||||||
app,
|
|
||||||
}
|
|
||||||
|
|
||||||
abstract class MenuItem extends StatelessWidget {
|
|
||||||
const MenuItem({Key? key}) : super(key: key);
|
|
||||||
|
|
||||||
MenuItemType get type;
|
|
||||||
}
|
|
||||||
|
|
||||||
class MenuList extends StatelessWidget {
|
|
||||||
final List<MenuItem> menuItems;
|
|
||||||
const MenuList({required this.menuItems, Key? key}) : super(key: key);
|
|
||||||
|
|
||||||
@override
|
|
||||||
Widget build(BuildContext context) {
|
|
||||||
return ExpandableTheme(
|
|
||||||
data: ExpandableThemeData(useInkWell: true, animationDuration: Durations.medium),
|
|
||||||
child: Expanded(
|
|
||||||
child: ListView.separated(
|
|
||||||
itemCount: menuItems.length,
|
|
||||||
separatorBuilder: (context, index) {
|
|
||||||
if (index == 0) {
|
|
||||||
return const VSpace(29);
|
|
||||||
} else {
|
|
||||||
return const VSpace(24);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
physics: const BouncingScrollPhysics(),
|
|
||||||
itemBuilder: (BuildContext context, int index) {
|
|
||||||
return menuItems[index];
|
|
||||||
},
|
|
||||||
),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
@ -1 +1 @@
|
|||||||
export 'menu_page.dart';
|
export 'menu.dart';
|
||||||
|
@ -11,11 +11,11 @@ import 'package:flutter/material.dart';
|
|||||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||||
import 'package:styled_widget/styled_widget.dart';
|
import 'package:styled_widget/styled_widget.dart';
|
||||||
|
|
||||||
import 'app.dart';
|
import 'menu_app.dart';
|
||||||
|
|
||||||
class AppHeader extends StatelessWidget {
|
class MenuAppHeader extends StatelessWidget {
|
||||||
final App app;
|
final App app;
|
||||||
const AppHeader(
|
const MenuAppHeader(
|
||||||
this.app, {
|
this.app, {
|
||||||
Key? key,
|
Key? key,
|
||||||
}) : super(key: key);
|
}) : super(key: key);
|
||||||
@ -38,13 +38,13 @@ class AppHeader extends StatelessWidget {
|
|||||||
expandIcon: FlowyIconData.drop_down_show,
|
expandIcon: FlowyIconData.drop_down_show,
|
||||||
collapseIcon: FlowyIconData.drop_down_hide,
|
collapseIcon: FlowyIconData.drop_down_hide,
|
||||||
iconColor: theme.shader1,
|
iconColor: theme.shader1,
|
||||||
iconSize: AppPageSize.expandedIconSize,
|
iconSize: MenuAppSizes.expandedIconSize,
|
||||||
iconPadding: EdgeInsets.zero,
|
iconPadding: EdgeInsets.zero,
|
||||||
hasIcon: false,
|
hasIcon: false,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
HSpace(AppPageSize.expandedIconPadding),
|
HSpace(MenuAppSizes.expandedIconPadding),
|
||||||
Expanded(
|
Expanded(
|
||||||
child: GestureDetector(
|
child: GestureDetector(
|
||||||
onTapDown: (_) {
|
onTapDown: (_) {
|
||||||
@ -62,7 +62,7 @@ class AppHeader extends StatelessWidget {
|
|||||||
// FlowyOverlay.of(context)
|
// FlowyOverlay.of(context)
|
||||||
// .insert(widget: Text('test'), identifier: 'identifier');
|
// .insert(widget: Text('test'), identifier: 'identifier');
|
||||||
},
|
},
|
||||||
).padding(right: AppPageSize.expandedIconPadding),
|
).padding(right: MenuAppSizes.expandedIconPadding),
|
||||||
// PopupMenuButton(
|
// PopupMenuButton(
|
||||||
// iconSize: 16,
|
// iconSize: 16,
|
||||||
// tooltip: 'create new view',
|
// tooltip: 'create new view',
|
||||||
|
@ -7,33 +7,31 @@ import 'package:flutter/material.dart';
|
|||||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||||
import 'package:app_flowy/startup/startup.dart';
|
import 'package:app_flowy/startup/startup.dart';
|
||||||
import 'package:app_flowy/workspace/application/app/app_bloc.dart';
|
import 'package:app_flowy/workspace/application/app/app_bloc.dart';
|
||||||
import 'package:app_flowy/workspace/application/app/app_watch_bloc.dart';
|
import 'package:app_flowy/workspace/application/app/app_listen_bloc.dart';
|
||||||
import 'package:app_flowy/workspace/presentation/widgets/menu/menu_list.dart';
|
import 'package:app_flowy/workspace/presentation/widgets/menu/menu.dart';
|
||||||
import 'package:provider/provider.dart';
|
import 'package:provider/provider.dart';
|
||||||
import 'package:styled_widget/styled_widget.dart';
|
import 'package:styled_widget/styled_widget.dart';
|
||||||
import 'section/section.dart';
|
import 'section/section.dart';
|
||||||
|
|
||||||
class AppPageSize {
|
class MenuAppSizes {
|
||||||
static double expandedIconSize = 16;
|
static double expandedIconSize = 16;
|
||||||
static double expandedIconPadding = 6;
|
static double expandedIconPadding = 6;
|
||||||
static double scale = 1;
|
static double scale = 1;
|
||||||
static double get expandedPadding => expandedIconSize * scale + expandedIconPadding;
|
static double get expandedPadding => expandedIconSize * scale + expandedIconPadding;
|
||||||
}
|
}
|
||||||
|
|
||||||
class AppPageContext {
|
class MenuAppContext {
|
||||||
final App app;
|
final App app;
|
||||||
final viewListData = ViewSectionData();
|
final viewListData = ViewSectionData();
|
||||||
|
|
||||||
AppPageContext(
|
MenuAppContext(this.app);
|
||||||
this.app,
|
|
||||||
);
|
|
||||||
|
|
||||||
Key valueKey() => ValueKey("${app.id}${app.version}");
|
Key valueKey() => ValueKey("${app.id}${app.version}");
|
||||||
}
|
}
|
||||||
|
|
||||||
class AppPage extends MenuItem {
|
class MenuApp extends MenuItem {
|
||||||
final AppPageContext appCtx;
|
final MenuAppContext appCtx;
|
||||||
AppPage(this.appCtx, {Key? key}) : super(key: appCtx.valueKey());
|
MenuApp(this.appCtx, {Key? key}) : super(key: appCtx.valueKey());
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
@ -44,13 +42,13 @@ class AppPage extends MenuItem {
|
|||||||
appBloc.add(const AppEvent.initial());
|
appBloc.add(const AppEvent.initial());
|
||||||
return appBloc;
|
return appBloc;
|
||||||
}),
|
}),
|
||||||
BlocProvider<AppWatchBloc>(create: (context) {
|
BlocProvider<AppListenBloc>(create: (context) {
|
||||||
final watchBloc = getIt<AppWatchBloc>(param1: appCtx.app.id);
|
final watchBloc = getIt<AppListenBloc>(param1: appCtx.app.id);
|
||||||
watchBloc.add(const AppWatchEvent.started());
|
watchBloc.add(const AppListenEvent.started());
|
||||||
return watchBloc;
|
return watchBloc;
|
||||||
}),
|
}),
|
||||||
],
|
],
|
||||||
child: BlocBuilder<AppWatchBloc, AppWatchState>(
|
child: BlocBuilder<AppListenBloc, AppListenState>(
|
||||||
builder: (context, state) {
|
builder: (context, state) {
|
||||||
final child = state.map(
|
final child = state.map(
|
||||||
initial: (_) => BlocBuilder<AppBloc, AppState>(
|
initial: (_) => BlocBuilder<AppBloc, AppState>(
|
||||||
@ -82,7 +80,7 @@ class AppPage extends MenuItem {
|
|||||||
iconPadding: EdgeInsets.zero,
|
iconPadding: EdgeInsets.zero,
|
||||||
hasIcon: false,
|
hasIcon: false,
|
||||||
),
|
),
|
||||||
header: AppHeader(appCtx.app),
|
header: MenuAppHeader(appCtx.app),
|
||||||
expanded: child,
|
expanded: child,
|
||||||
collapsed: const SizedBox(),
|
collapsed: const SizedBox(),
|
||||||
),
|
),
|
@ -1,4 +1,4 @@
|
|||||||
import 'package:app_flowy/workspace/presentation/widgets/menu/widget/app/app.dart';
|
import 'package:app_flowy/workspace/presentation/widgets/menu/widget/app/menu_app.dart';
|
||||||
import 'package:flowy_infra/theme.dart';
|
import 'package:flowy_infra/theme.dart';
|
||||||
import 'package:flowy_infra_ui/style_widget/hover.dart';
|
import 'package:flowy_infra_ui/style_widget/hover.dart';
|
||||||
import 'package:flowy_infra_ui/style_widget/icon_button.dart';
|
import 'package:flowy_infra_ui/style_widget/icon_button.dart';
|
||||||
@ -65,8 +65,8 @@ class ViewSectionItem extends StatelessWidget {
|
|||||||
|
|
||||||
Widget widget = Container(
|
Widget widget = Container(
|
||||||
child: Row(children: children).padding(
|
child: Row(children: children).padding(
|
||||||
left: AppPageSize.expandedPadding,
|
left: MenuAppSizes.expandedPadding,
|
||||||
right: AppPageSize.expandedIconPadding,
|
right: MenuAppSizes.expandedIconPadding,
|
||||||
),
|
),
|
||||||
height: 24,
|
height: 24,
|
||||||
alignment: Alignment.centerLeft,
|
alignment: Alignment.centerLeft,
|
||||||
|
@ -73,7 +73,7 @@ class ViewSection extends StatelessWidget {
|
|||||||
Log.debug("Open view: $view");
|
Log.debug("Open view: $view");
|
||||||
context.read<ViewSectionNotifier>().setSelectedView(view);
|
context.read<ViewSectionNotifier>().setSelectedView(view);
|
||||||
final stackView = stackCtxFromView(viewCtx.view);
|
final stackView = stackCtxFromView(viewCtx.view);
|
||||||
getIt<HomeStack>().setStack(stackView);
|
getIt<HomeStackManager>().setStack(stackView);
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import '../../menu_list.dart';
|
import '../../menu.dart';
|
||||||
|
|
||||||
class FavoriteHeader extends MenuItem {
|
class FavoriteHeader extends MenuItem {
|
||||||
const FavoriteHeader({Key? key}) : super(key: key);
|
const FavoriteHeader({Key? key}) : super(key: key);
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
import 'package:app_flowy/startup/startup.dart';
|
import 'package:app_flowy/startup/startup.dart';
|
||||||
import 'package:app_flowy/workspace/application/menu/menu_user_bloc.dart';
|
import 'package:app_flowy/workspace/application/menu/menu_user_bloc.dart';
|
||||||
import 'package:app_flowy/workspace/presentation/widgets/menu/menu_list.dart';
|
import 'package:app_flowy/workspace/presentation/widgets/menu/menu.dart';
|
||||||
import 'package:flowy_infra_ui/widget/spacing.dart';
|
import 'package:flowy_infra_ui/widget/spacing.dart';
|
||||||
import 'package:flowy_sdk/protobuf/flowy-user/user_profile.pb.dart';
|
import 'package:flowy_sdk/protobuf/flowy-user/user_profile.pb.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
@ -2,4 +2,4 @@ export '../stack_page/blank/blank_page.dart';
|
|||||||
export './edit_pannel/edit_pannel.dart';
|
export './edit_pannel/edit_pannel.dart';
|
||||||
export './edit_pannel/pannel_animation.dart';
|
export './edit_pannel/pannel_animation.dart';
|
||||||
export './home_top_bar.dart';
|
export './home_top_bar.dart';
|
||||||
export 'menu/menu_page.dart';
|
export 'menu/menu.dart';
|
||||||
|
Loading…
x
Reference in New Issue
Block a user