mirror of
				https://github.com/AppFlowy-IO/AppFlowy.git
				synced 2025-11-04 03:54:44 +00:00 
			
		
		
		
	rename some widget
This commit is contained in:
		
							parent
							
								
									20ec4c448c
								
							
						
					
					
						commit
						826a50bd76
					
				@ -29,7 +29,7 @@ class AppBloc extends Bloc<AppEvent, AppState> {
 | 
				
			|||||||
  Stream<AppState> _fetchViews() async* {
 | 
					  Stream<AppState> _fetchViews() async* {
 | 
				
			||||||
    final viewsOrFailed = await iAppImpl.getViews();
 | 
					    final viewsOrFailed = await iAppImpl.getViews();
 | 
				
			||||||
    yield viewsOrFailed.fold(
 | 
					    yield viewsOrFailed.fold(
 | 
				
			||||||
      (apps) => state.copyWith(views: some(apps)),
 | 
					      (apps) => state.copyWith(views: apps),
 | 
				
			||||||
      (error) => state.copyWith(successOrFailure: right(error)),
 | 
					      (error) => state.copyWith(successOrFailure: right(error)),
 | 
				
			||||||
    );
 | 
					    );
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
@ -46,13 +46,13 @@ abstract class AppEvent with _$AppEvent {
 | 
				
			|||||||
abstract class AppState implements _$AppState {
 | 
					abstract class AppState implements _$AppState {
 | 
				
			||||||
  const factory AppState({
 | 
					  const factory AppState({
 | 
				
			||||||
    required bool isLoading,
 | 
					    required bool isLoading,
 | 
				
			||||||
    required Option<List<View>> views,
 | 
					    required List<View>? views,
 | 
				
			||||||
    required Either<Unit, WorkspaceError> successOrFailure,
 | 
					    required Either<Unit, WorkspaceError> successOrFailure,
 | 
				
			||||||
  }) = _AppState;
 | 
					  }) = _AppState;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  factory AppState.initial() => AppState(
 | 
					  factory AppState.initial() => AppState(
 | 
				
			||||||
        isLoading: false,
 | 
					        isLoading: false,
 | 
				
			||||||
        views: none(),
 | 
					        views: null,
 | 
				
			||||||
        successOrFailure: left(unit),
 | 
					        successOrFailure: left(unit),
 | 
				
			||||||
      );
 | 
					      );
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
				
			|||||||
@ -308,7 +308,7 @@ class _$AppStateTearOff {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
  _AppState call(
 | 
					  _AppState call(
 | 
				
			||||||
      {required bool isLoading,
 | 
					      {required bool isLoading,
 | 
				
			||||||
      required Option<List<View>> views,
 | 
					      required List<View>? views,
 | 
				
			||||||
      required Either<Unit, WorkspaceError> successOrFailure}) {
 | 
					      required Either<Unit, WorkspaceError> successOrFailure}) {
 | 
				
			||||||
    return _AppState(
 | 
					    return _AppState(
 | 
				
			||||||
      isLoading: isLoading,
 | 
					      isLoading: isLoading,
 | 
				
			||||||
@ -324,7 +324,7 @@ const $AppState = _$AppStateTearOff();
 | 
				
			|||||||
/// @nodoc
 | 
					/// @nodoc
 | 
				
			||||||
mixin _$AppState {
 | 
					mixin _$AppState {
 | 
				
			||||||
  bool get isLoading => throw _privateConstructorUsedError;
 | 
					  bool get isLoading => throw _privateConstructorUsedError;
 | 
				
			||||||
  Option<List<View>> get views => throw _privateConstructorUsedError;
 | 
					  List<View>? get views => throw _privateConstructorUsedError;
 | 
				
			||||||
  Either<Unit, WorkspaceError> get successOrFailure =>
 | 
					  Either<Unit, WorkspaceError> get successOrFailure =>
 | 
				
			||||||
      throw _privateConstructorUsedError;
 | 
					      throw _privateConstructorUsedError;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -339,7 +339,7 @@ abstract class $AppStateCopyWith<$Res> {
 | 
				
			|||||||
      _$AppStateCopyWithImpl<$Res>;
 | 
					      _$AppStateCopyWithImpl<$Res>;
 | 
				
			||||||
  $Res call(
 | 
					  $Res call(
 | 
				
			||||||
      {bool isLoading,
 | 
					      {bool isLoading,
 | 
				
			||||||
      Option<List<View>> views,
 | 
					      List<View>? views,
 | 
				
			||||||
      Either<Unit, WorkspaceError> successOrFailure});
 | 
					      Either<Unit, WorkspaceError> successOrFailure});
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -365,7 +365,7 @@ class _$AppStateCopyWithImpl<$Res> implements $AppStateCopyWith<$Res> {
 | 
				
			|||||||
      views: views == freezed
 | 
					      views: views == freezed
 | 
				
			||||||
          ? _value.views
 | 
					          ? _value.views
 | 
				
			||||||
          : views // ignore: cast_nullable_to_non_nullable
 | 
					          : views // ignore: cast_nullable_to_non_nullable
 | 
				
			||||||
              as Option<List<View>>,
 | 
					              as List<View>?,
 | 
				
			||||||
      successOrFailure: successOrFailure == freezed
 | 
					      successOrFailure: successOrFailure == freezed
 | 
				
			||||||
          ? _value.successOrFailure
 | 
					          ? _value.successOrFailure
 | 
				
			||||||
          : successOrFailure // ignore: cast_nullable_to_non_nullable
 | 
					          : successOrFailure // ignore: cast_nullable_to_non_nullable
 | 
				
			||||||
@ -381,7 +381,7 @@ abstract class _$AppStateCopyWith<$Res> implements $AppStateCopyWith<$Res> {
 | 
				
			|||||||
  @override
 | 
					  @override
 | 
				
			||||||
  $Res call(
 | 
					  $Res call(
 | 
				
			||||||
      {bool isLoading,
 | 
					      {bool isLoading,
 | 
				
			||||||
      Option<List<View>> views,
 | 
					      List<View>? views,
 | 
				
			||||||
      Either<Unit, WorkspaceError> successOrFailure});
 | 
					      Either<Unit, WorkspaceError> successOrFailure});
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -408,7 +408,7 @@ class __$AppStateCopyWithImpl<$Res> extends _$AppStateCopyWithImpl<$Res>
 | 
				
			|||||||
      views: views == freezed
 | 
					      views: views == freezed
 | 
				
			||||||
          ? _value.views
 | 
					          ? _value.views
 | 
				
			||||||
          : views // ignore: cast_nullable_to_non_nullable
 | 
					          : views // ignore: cast_nullable_to_non_nullable
 | 
				
			||||||
              as Option<List<View>>,
 | 
					              as List<View>?,
 | 
				
			||||||
      successOrFailure: successOrFailure == freezed
 | 
					      successOrFailure: successOrFailure == freezed
 | 
				
			||||||
          ? _value.successOrFailure
 | 
					          ? _value.successOrFailure
 | 
				
			||||||
          : successOrFailure // ignore: cast_nullable_to_non_nullable
 | 
					          : successOrFailure // ignore: cast_nullable_to_non_nullable
 | 
				
			||||||
@ -428,7 +428,7 @@ class _$_AppState implements _AppState {
 | 
				
			|||||||
  @override
 | 
					  @override
 | 
				
			||||||
  final bool isLoading;
 | 
					  final bool isLoading;
 | 
				
			||||||
  @override
 | 
					  @override
 | 
				
			||||||
  final Option<List<View>> views;
 | 
					  final List<View>? views;
 | 
				
			||||||
  @override
 | 
					  @override
 | 
				
			||||||
  final Either<Unit, WorkspaceError> successOrFailure;
 | 
					  final Either<Unit, WorkspaceError> successOrFailure;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -467,13 +467,13 @@ class _$_AppState implements _AppState {
 | 
				
			|||||||
abstract class _AppState implements AppState {
 | 
					abstract class _AppState implements AppState {
 | 
				
			||||||
  const factory _AppState(
 | 
					  const factory _AppState(
 | 
				
			||||||
      {required bool isLoading,
 | 
					      {required bool isLoading,
 | 
				
			||||||
      required Option<List<View>> views,
 | 
					      required List<View>? views,
 | 
				
			||||||
      required Either<Unit, WorkspaceError> successOrFailure}) = _$_AppState;
 | 
					      required Either<Unit, WorkspaceError> successOrFailure}) = _$_AppState;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  @override
 | 
					  @override
 | 
				
			||||||
  bool get isLoading => throw _privateConstructorUsedError;
 | 
					  bool get isLoading => throw _privateConstructorUsedError;
 | 
				
			||||||
  @override
 | 
					  @override
 | 
				
			||||||
  Option<List<View>> get views => throw _privateConstructorUsedError;
 | 
					  List<View>? get views => throw _privateConstructorUsedError;
 | 
				
			||||||
  @override
 | 
					  @override
 | 
				
			||||||
  Either<Unit, WorkspaceError> get successOrFailure =>
 | 
					  Either<Unit, WorkspaceError> get successOrFailure =>
 | 
				
			||||||
      throw _privateConstructorUsedError;
 | 
					      throw _privateConstructorUsedError;
 | 
				
			||||||
 | 
				
			|||||||
							
								
								
									
										85
									
								
								app_flowy/lib/workspace/presentation/app/app_header.dart
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										85
									
								
								app_flowy/lib/workspace/presentation/app/app_header.dart
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,85 @@
 | 
				
			|||||||
 | 
					import 'package:app_flowy/workspace/application/app/app_bloc.dart';
 | 
				
			||||||
 | 
					import 'package:expandable/expandable.dart';
 | 
				
			||||||
 | 
					import 'package:flowy_infra_ui/style_widget/icon_button.dart';
 | 
				
			||||||
 | 
					import 'package:flowy_infra_ui/widget/spacing.dart';
 | 
				
			||||||
 | 
					import 'package:flowy_infra_ui/style_widget/text_button.dart';
 | 
				
			||||||
 | 
					import 'package:flowy_sdk/protobuf/flowy-workspace/app_create.pb.dart';
 | 
				
			||||||
 | 
					import 'package:flowy_sdk/protobuf/flowy-workspace/view_create.pb.dart';
 | 
				
			||||||
 | 
					import 'package:flutter/material.dart';
 | 
				
			||||||
 | 
					import 'package:flutter_bloc/flutter_bloc.dart';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import 'app_page.dart';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					class AppHeader extends StatelessWidget {
 | 
				
			||||||
 | 
					  final App app;
 | 
				
			||||||
 | 
					  const AppHeader(
 | 
				
			||||||
 | 
					    this.app, {
 | 
				
			||||||
 | 
					    Key? key,
 | 
				
			||||||
 | 
					  }) : super(key: key);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  @override
 | 
				
			||||||
 | 
					  Widget build(BuildContext context) {
 | 
				
			||||||
 | 
					    return Row(
 | 
				
			||||||
 | 
					      mainAxisAlignment: MainAxisAlignment.center,
 | 
				
			||||||
 | 
					      crossAxisAlignment: CrossAxisAlignment.center,
 | 
				
			||||||
 | 
					      children: [
 | 
				
			||||||
 | 
					        InkWell(
 | 
				
			||||||
 | 
					          onTap: () {
 | 
				
			||||||
 | 
					            ExpandableController.of(context,
 | 
				
			||||||
 | 
					                    rebuildOnChange: false, required: true)
 | 
				
			||||||
 | 
					                ?.toggle();
 | 
				
			||||||
 | 
					          },
 | 
				
			||||||
 | 
					          child: ExpandableIcon(
 | 
				
			||||||
 | 
					            theme: ExpandableThemeData(
 | 
				
			||||||
 | 
					              expandIcon: Icons.arrow_drop_up,
 | 
				
			||||||
 | 
					              collapseIcon: Icons.arrow_drop_down,
 | 
				
			||||||
 | 
					              iconColor: Colors.black,
 | 
				
			||||||
 | 
					              iconSize: AppPageSize.expandedIconSize,
 | 
				
			||||||
 | 
					              iconPadding: EdgeInsets.zero,
 | 
				
			||||||
 | 
					              hasIcon: false,
 | 
				
			||||||
 | 
					            ),
 | 
				
			||||||
 | 
					          ),
 | 
				
			||||||
 | 
					        ),
 | 
				
			||||||
 | 
					        HSpace(AppPageSize.expandedIconRightSpace),
 | 
				
			||||||
 | 
					        Expanded(
 | 
				
			||||||
 | 
					          child: FlowyTextButton(
 | 
				
			||||||
 | 
					            app.name,
 | 
				
			||||||
 | 
					            onPressed: () {
 | 
				
			||||||
 | 
					              debugPrint('show app document');
 | 
				
			||||||
 | 
					            },
 | 
				
			||||||
 | 
					          ),
 | 
				
			||||||
 | 
					        ),
 | 
				
			||||||
 | 
					        // FlowyIconButton(
 | 
				
			||||||
 | 
					        //   icon: const Icon(Icons.add),
 | 
				
			||||||
 | 
					        //   onPressed: () {
 | 
				
			||||||
 | 
					        //     debugPrint('add view');
 | 
				
			||||||
 | 
					        //   },
 | 
				
			||||||
 | 
					        // ),
 | 
				
			||||||
 | 
					        PopupMenuButton(
 | 
				
			||||||
 | 
					            iconSize: 20,
 | 
				
			||||||
 | 
					            tooltip: 'create new view',
 | 
				
			||||||
 | 
					            icon: const Icon(Icons.add),
 | 
				
			||||||
 | 
					            padding: EdgeInsets.zero,
 | 
				
			||||||
 | 
					            onSelected: (viewType) =>
 | 
				
			||||||
 | 
					                _createView(viewType as ViewType, context),
 | 
				
			||||||
 | 
					            itemBuilder: (context) => menuItemBuilder())
 | 
				
			||||||
 | 
					      ],
 | 
				
			||||||
 | 
					    );
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  List<PopupMenuEntry> menuItemBuilder() {
 | 
				
			||||||
 | 
					    return ViewType.values
 | 
				
			||||||
 | 
					        .where((element) => element != ViewType.Blank)
 | 
				
			||||||
 | 
					        .map((ty) {
 | 
				
			||||||
 | 
					      return PopupMenuItem<ViewType>(
 | 
				
			||||||
 | 
					          value: ty,
 | 
				
			||||||
 | 
					          child: Row(
 | 
				
			||||||
 | 
					            children: <Widget>[Text(ty.name)],
 | 
				
			||||||
 | 
					          ));
 | 
				
			||||||
 | 
					    }).toList();
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  void _createView(ViewType viewType, BuildContext context) {
 | 
				
			||||||
 | 
					    context.read<AppBloc>().add(AppEvent.createView("New view", "", viewType));
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
@ -1,4 +1,3 @@
 | 
				
			|||||||
import 'package:dartz/dartz.dart';
 | 
					 | 
				
			||||||
import 'package:expandable/expandable.dart';
 | 
					import 'package:expandable/expandable.dart';
 | 
				
			||||||
import 'package:flowy_infra_ui/widget/error_page.dart';
 | 
					import 'package:flowy_infra_ui/widget/error_page.dart';
 | 
				
			||||||
import 'package:flowy_sdk/protobuf/flowy-workspace/app_create.pb.dart';
 | 
					import 'package:flowy_sdk/protobuf/flowy-workspace/app_create.pb.dart';
 | 
				
			||||||
@ -9,12 +8,13 @@ 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_watch_bloc.dart';
 | 
				
			||||||
import 'package:app_flowy/workspace/presentation/app/view_list.dart';
 | 
					import 'package:app_flowy/workspace/presentation/app/view_list_page.dart';
 | 
				
			||||||
import 'package:app_flowy/workspace/presentation/widgets/menu/menu_list.dart';
 | 
					import 'package:app_flowy/workspace/presentation/widgets/menu/menu_list.dart';
 | 
				
			||||||
import 'package:provider/provider.dart';
 | 
					import 'package:provider/provider.dart';
 | 
				
			||||||
 | 
					import 'package:styled_widget/styled_widget.dart';
 | 
				
			||||||
import 'app_header.dart';
 | 
					import 'app_header.dart';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
class AppWidgetSize {
 | 
					class AppPageSize {
 | 
				
			||||||
  static double expandedIconSize = 24;
 | 
					  static double expandedIconSize = 24;
 | 
				
			||||||
  static double expandedIconRightSpace = 8;
 | 
					  static double expandedIconRightSpace = 8;
 | 
				
			||||||
  static double scale = 1;
 | 
					  static double scale = 1;
 | 
				
			||||||
@ -34,20 +34,20 @@ class ViewListData extends ChangeNotifier {
 | 
				
			|||||||
  List<View> get views => innerViews ?? [];
 | 
					  List<View> get views => innerViews ?? [];
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
class AppWidgetContext {
 | 
					class AppPageContext {
 | 
				
			||||||
  final App app;
 | 
					  final App app;
 | 
				
			||||||
  final viewListData = ViewListData();
 | 
					  final viewListData = ViewListData();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  AppWidgetContext(
 | 
					  AppPageContext(
 | 
				
			||||||
    this.app,
 | 
					    this.app,
 | 
				
			||||||
  );
 | 
					  );
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  Key valueKey() => ValueKey("${app.id}${app.version}");
 | 
					  Key valueKey() => ValueKey("${app.id}${app.version}");
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
class AppWidget extends MenuItem {
 | 
					class AppPage extends MenuItem {
 | 
				
			||||||
  final AppWidgetContext appCtx;
 | 
					  final AppPageContext appCtx;
 | 
				
			||||||
  AppWidget(this.appCtx, {Key? key}) : super(key: appCtx.valueKey());
 | 
					  AppPage(this.appCtx, {Key? key}) : super(key: appCtx.valueKey());
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  @override
 | 
					  @override
 | 
				
			||||||
  Widget build(BuildContext context) {
 | 
					  Widget build(BuildContext context) {
 | 
				
			||||||
@ -70,7 +70,7 @@ class AppWidget extends MenuItem {
 | 
				
			|||||||
            initial: (_) => BlocBuilder<AppBloc, AppState>(
 | 
					            initial: (_) => BlocBuilder<AppBloc, AppState>(
 | 
				
			||||||
              builder: (context, state) => _renderViewList(state.views),
 | 
					              builder: (context, state) => _renderViewList(state.views),
 | 
				
			||||||
            ),
 | 
					            ),
 | 
				
			||||||
            loadViews: (s) => _renderViewList(some(s.views)),
 | 
					            loadViews: (s) => _renderViewList(s.views),
 | 
				
			||||||
            loadFail: (s) => FlowyErrorPage(s.error.toString()),
 | 
					            loadFail: (s) => FlowyErrorPage(s.error.toString()),
 | 
				
			||||||
          );
 | 
					          );
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -106,24 +106,14 @@ class AppWidget extends MenuItem {
 | 
				
			|||||||
    );
 | 
					    );
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  Widget _renderViewList(Option<List<View>> some) {
 | 
					  Widget _renderViewList(List<View>? views) {
 | 
				
			||||||
    some.fold(
 | 
					    appCtx.viewListData.views = views ?? List.empty(growable: false);
 | 
				
			||||||
      () {
 | 
					 | 
				
			||||||
        appCtx.viewListData.views = List.empty(growable: true);
 | 
					 | 
				
			||||||
      },
 | 
					 | 
				
			||||||
      (views) {
 | 
					 | 
				
			||||||
        appCtx.viewListData.views = views;
 | 
					 | 
				
			||||||
      },
 | 
					 | 
				
			||||||
    );
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    return MultiProvider(
 | 
					    return MultiProvider(
 | 
				
			||||||
      providers: [
 | 
					      providers: [
 | 
				
			||||||
        ChangeNotifierProvider.value(value: appCtx.viewListData),
 | 
					        ChangeNotifierProvider.value(value: appCtx.viewListData),
 | 
				
			||||||
      ],
 | 
					      ],
 | 
				
			||||||
      child: Consumer(builder: (context, ViewListData notifier, child) {
 | 
					      child: Consumer(builder: (context, ViewListData notifier, child) {
 | 
				
			||||||
        return Padding(
 | 
					        return ViewListPage(notifier.views).padding(vertical: 8);
 | 
				
			||||||
            padding: const EdgeInsets.symmetric(vertical: 8),
 | 
					 | 
				
			||||||
            child: ViewList(notifier.views));
 | 
					 | 
				
			||||||
      }),
 | 
					      }),
 | 
				
			||||||
    );
 | 
					    );
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
@ -1,4 +1,4 @@
 | 
				
			|||||||
import 'package:app_flowy/workspace/presentation/app/app_widget.dart';
 | 
					import 'package:app_flowy/workspace/presentation/app/app_page.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/foundation.dart';
 | 
					import 'package:flutter/foundation.dart';
 | 
				
			||||||
import 'package:flutter/material.dart';
 | 
					import 'package:flutter/material.dart';
 | 
				
			||||||
@ -6,7 +6,7 @@ import 'package:flutter_bloc/flutter_bloc.dart';
 | 
				
			|||||||
import 'package:provider/provider.dart';
 | 
					import 'package:provider/provider.dart';
 | 
				
			||||||
import 'package:app_flowy/startup/startup.dart';
 | 
					import 'package:app_flowy/startup/startup.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/view/view_widget.dart';
 | 
					import 'package:app_flowy/workspace/presentation/view/view_page.dart';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
class ViewListNotifier with ChangeNotifier {
 | 
					class ViewListNotifier with ChangeNotifier {
 | 
				
			||||||
  List<View> innerViews;
 | 
					  List<View> innerViews;
 | 
				
			||||||
@ -16,7 +16,7 @@ class ViewListNotifier with ChangeNotifier {
 | 
				
			|||||||
  set views(List<View> views) => innerViews = views;
 | 
					  set views(List<View> views) => innerViews = views;
 | 
				
			||||||
  List<View> get views => innerViews;
 | 
					  List<View> get views => innerViews;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  void openView(View view) {
 | 
					  void setSelectedView(View view) {
 | 
				
			||||||
    _selectedView = view;
 | 
					    _selectedView = view;
 | 
				
			||||||
    notifyListeners();
 | 
					    notifyListeners();
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
@ -29,9 +29,9 @@ class ViewListNotifier with ChangeNotifier {
 | 
				
			|||||||
  }
 | 
					  }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
class ViewList extends StatelessWidget {
 | 
					class ViewListPage extends StatelessWidget {
 | 
				
			||||||
  final List<View> views;
 | 
					  final List<View> views;
 | 
				
			||||||
  const ViewList(this.views, {Key? key}) : super(key: key);
 | 
					  const ViewListPage(this.views, {Key? key}) : super(key: key);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  @override
 | 
					  @override
 | 
				
			||||||
  Widget build(BuildContext context) {
 | 
					  Widget build(BuildContext context) {
 | 
				
			||||||
@ -51,13 +51,13 @@ class ViewList extends StatelessWidget {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
  Widget _renderViews(BuildContext context, List<View> views) {
 | 
					  Widget _renderViews(BuildContext context, List<View> views) {
 | 
				
			||||||
    var viewWidgets = views.map((view) {
 | 
					    var viewWidgets = views.map((view) {
 | 
				
			||||||
      final viewCtx = ViewWidgetContext(view,
 | 
					      final viewCtx = ViewWidgetContext(view);
 | 
				
			||||||
          isSelected: _isViewSelected(context, view.id));
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
      final viewWidget = ViewWidget(
 | 
					      final viewWidget = ViewPage(
 | 
				
			||||||
        viewCtx: viewCtx,
 | 
					        viewCtx: viewCtx,
 | 
				
			||||||
 | 
					        isSelected: _isViewSelected(context, view.id),
 | 
				
			||||||
        onOpen: (view) {
 | 
					        onOpen: (view) {
 | 
				
			||||||
          context.read<ViewListNotifier>().openView(view);
 | 
					          context.read<ViewListNotifier>().setSelectedView(view);
 | 
				
			||||||
          final stackView = stackViewFromView(viewCtx.view);
 | 
					          final stackView = stackViewFromView(viewCtx.view);
 | 
				
			||||||
          getIt<HomePageStack>().setStackView(stackView);
 | 
					          getIt<HomePageStack>().setStackView(stackView);
 | 
				
			||||||
        },
 | 
					        },
 | 
				
			||||||
@ -1,7 +1,7 @@
 | 
				
			|||||||
import 'package:app_flowy/startup/startup.dart';
 | 
					import 'package:app_flowy/startup/startup.dart';
 | 
				
			||||||
import 'package:app_flowy/workspace/application/view/doc_watch_bloc.dart';
 | 
					import 'package:app_flowy/workspace/application/view/doc_watch_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/doc/editor_widget.dart';
 | 
					import 'package:app_flowy/workspace/presentation/doc/editor_page.dart';
 | 
				
			||||||
import 'package:flowy_infra_ui/widget/error_page.dart';
 | 
					import 'package:flowy_infra_ui/widget/error_page.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';
 | 
				
			||||||
@ -31,7 +31,7 @@ class _DocPageState extends State<DocPage> {
 | 
				
			|||||||
        assert(widget.stackView is DocPageStackView);
 | 
					        assert(widget.stackView is DocPageStackView);
 | 
				
			||||||
        return state.map(
 | 
					        return state.map(
 | 
				
			||||||
          loading: (_) => const FlowyProgressIndicator(),
 | 
					          loading: (_) => const FlowyProgressIndicator(),
 | 
				
			||||||
          loadDoc: (s) => EditorWdiget(doc: s.doc),
 | 
					          loadDoc: (s) => EditorPage(doc: s.doc),
 | 
				
			||||||
          loadFail: (s) => FlowyErrorPage(s.error.toString()),
 | 
					          loadFail: (s) => FlowyErrorPage(s.error.toString()),
 | 
				
			||||||
        );
 | 
					        );
 | 
				
			||||||
      }),
 | 
					      }),
 | 
				
			||||||
 | 
				
			|||||||
@ -7,12 +7,12 @@ import 'package:flowy_editor/flowy_editor.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';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
class EditorWdiget extends StatelessWidget {
 | 
					class EditorPage extends StatelessWidget {
 | 
				
			||||||
  final FocusNode _focusNode = FocusNode();
 | 
					  final FocusNode _focusNode = FocusNode();
 | 
				
			||||||
  late EditorController controller;
 | 
					  late EditorController controller;
 | 
				
			||||||
  final Doc doc;
 | 
					  final Doc doc;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  EditorWdiget({Key? key, required this.doc}) : super(key: key) {
 | 
					  EditorPage({Key? key, required this.doc}) : super(key: key) {
 | 
				
			||||||
    controller = EditorController(
 | 
					    controller = EditorController(
 | 
				
			||||||
      document: doc.data,
 | 
					      document: doc.data,
 | 
				
			||||||
      selection: const TextSelection.collapsed(offset: 0),
 | 
					      selection: const TextSelection.collapsed(offset: 0),
 | 
				
			||||||
@ -4,27 +4,28 @@ import 'package:flowy_infra_ui/widget/spacing.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';
 | 
				
			||||||
import 'package:app_flowy/workspace/domain/image.dart';
 | 
					import 'package:app_flowy/workspace/domain/image.dart';
 | 
				
			||||||
import 'package:app_flowy/workspace/presentation/app/app_widget.dart';
 | 
					import 'package:app_flowy/workspace/presentation/app/app_page.dart';
 | 
				
			||||||
import 'package:styled_widget/styled_widget.dart';
 | 
					import 'package:styled_widget/styled_widget.dart';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
class ViewWidgetContext {
 | 
					class ViewWidgetContext {
 | 
				
			||||||
  final View view;
 | 
					  final View view;
 | 
				
			||||||
  bool isSelected;
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
  ViewWidgetContext(
 | 
					  ViewWidgetContext(this.view);
 | 
				
			||||||
    this.view, {
 | 
					 | 
				
			||||||
    this.isSelected = false,
 | 
					 | 
				
			||||||
  });
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
  Key valueKey() => ValueKey("${view.id}${view.version}");
 | 
					  Key valueKey() => ValueKey("${view.id}${view.version}");
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
typedef OpenViewCallback = void Function(View);
 | 
					typedef OpenViewCallback = void Function(View);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
class ViewWidget extends StatelessWidget {
 | 
					class ViewPage extends StatelessWidget {
 | 
				
			||||||
  final ViewWidgetContext viewCtx;
 | 
					  final ViewWidgetContext viewCtx;
 | 
				
			||||||
 | 
					  final bool isSelected;
 | 
				
			||||||
  final OpenViewCallback onOpen;
 | 
					  final OpenViewCallback onOpen;
 | 
				
			||||||
  ViewWidget({Key? key, required this.viewCtx, required this.onOpen})
 | 
					  ViewPage(
 | 
				
			||||||
 | 
					      {Key? key,
 | 
				
			||||||
 | 
					      required this.viewCtx,
 | 
				
			||||||
 | 
					      required this.onOpen,
 | 
				
			||||||
 | 
					      required this.isSelected})
 | 
				
			||||||
      : super(key: viewCtx.valueKey());
 | 
					      : super(key: viewCtx.valueKey());
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  @override
 | 
					  @override
 | 
				
			||||||
@ -62,11 +63,11 @@ class ViewWidget extends StatelessWidget {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    Widget widget = Row(children: children).padding(
 | 
					    Widget widget = Row(children: children).padding(
 | 
				
			||||||
      vertical: 5,
 | 
					      vertical: 5,
 | 
				
			||||||
      left: AppWidgetSize.expandedPadding,
 | 
					      left: AppPageSize.expandedPadding,
 | 
				
			||||||
      right: 5,
 | 
					      right: 5,
 | 
				
			||||||
    );
 | 
					    );
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if (viewCtx.isSelected) {
 | 
					    if (isSelected) {
 | 
				
			||||||
      widget = FlowyHoverBackground(child: widget, config: config);
 | 
					      widget = FlowyHoverBackground(child: widget, config: config);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -13,7 +13,7 @@ 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_watch.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/app/app_widget.dart';
 | 
					import 'package:app_flowy/workspace/presentation/app/app_page.dart';
 | 
				
			||||||
import 'package:app_flowy/workspace/presentation/home/home_sizes.dart';
 | 
					import 'package:app_flowy/workspace/presentation/home/home_sizes.dart';
 | 
				
			||||||
import 'package:app_flowy/workspace/presentation/widgets/menu/menu_user.dart';
 | 
					import 'package:app_flowy/workspace/presentation/widgets/menu/menu_user.dart';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -130,7 +130,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) => AppWidget(AppWidgetContext(app))).toList(),
 | 
					      (apps, _) => apps.map((app) => AppPage(AppPageContext(app))).toList(),
 | 
				
			||||||
    );
 | 
					    );
 | 
				
			||||||
    items.addAll(appWidgets);
 | 
					    items.addAll(appWidgets);
 | 
				
			||||||
    return this;
 | 
					    return this;
 | 
				
			||||||
@ -1 +1 @@
 | 
				
			|||||||
export 'menu.dart';
 | 
					export 'menu_page.dart';
 | 
				
			||||||
 | 
				
			|||||||
@ -2,4 +2,4 @@ export './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.dart';
 | 
					export 'menu/menu_page.dart';
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user