config create app ui

This commit is contained in:
appflowy 2021-07-20 23:51:08 +08:00
parent 7868305a32
commit b89958a551
22 changed files with 445 additions and 202 deletions

View File

@ -21,6 +21,6 @@
<key>CFBundleVersion</key> <key>CFBundleVersion</key>
<string>1.0</string> <string>1.0</string>
<key>MinimumOSVersion</key> <key>MinimumOSVersion</key>
<string>8.0</string> <string>9.0</string>
</dict> </dict>
</plist> </plist>

View File

@ -29,8 +29,8 @@ class HomeBloc extends Bloc<HomeEvent, HomeState> {
dismissEditPannel: (value) async* { dismissEditPannel: (value) async* {
yield state.copyWith(editContext: none()); yield state.copyWith(editContext: none());
}, },
showMenu: (e) async* { forceCollapse: (e) async* {
yield state.copyWith(showMenu: e.isShow); yield state.copyWith(forceCollapse: e.forceCollapse);
}, },
); );
} }

View File

@ -22,9 +22,9 @@ class _$HomeEventTearOff {
); );
} }
_ShowMenu showMenu(bool isShow) { _ForceCollapse forceCollapse(bool forceCollapse) {
return _ShowMenu( return _ForceCollapse(
isShow, forceCollapse,
); );
} }
@ -53,7 +53,7 @@ mixin _$HomeEvent {
@optionalTypeArgs @optionalTypeArgs
TResult when<TResult extends Object?>({ TResult when<TResult extends Object?>({
required TResult Function(bool isLoading) showLoading, required TResult Function(bool isLoading) showLoading,
required TResult Function(bool isShow) showMenu, required TResult Function(bool forceCollapse) forceCollapse,
required TResult Function(PageContext context) setPage, required TResult Function(PageContext context) setPage,
required TResult Function(EditPannelContext editContext) setEditPannel, required TResult Function(EditPannelContext editContext) setEditPannel,
required TResult Function() dismissEditPannel, required TResult Function() dismissEditPannel,
@ -62,7 +62,7 @@ mixin _$HomeEvent {
@optionalTypeArgs @optionalTypeArgs
TResult maybeWhen<TResult extends Object?>({ TResult maybeWhen<TResult extends Object?>({
TResult Function(bool isLoading)? showLoading, TResult Function(bool isLoading)? showLoading,
TResult Function(bool isShow)? showMenu, TResult Function(bool forceCollapse)? forceCollapse,
TResult Function(PageContext context)? setPage, TResult Function(PageContext context)? setPage,
TResult Function(EditPannelContext editContext)? setEditPannel, TResult Function(EditPannelContext editContext)? setEditPannel,
TResult Function()? dismissEditPannel, TResult Function()? dismissEditPannel,
@ -72,7 +72,7 @@ mixin _$HomeEvent {
@optionalTypeArgs @optionalTypeArgs
TResult map<TResult extends Object?>({ TResult map<TResult extends Object?>({
required TResult Function(_ShowLoading value) showLoading, required TResult Function(_ShowLoading value) showLoading,
required TResult Function(_ShowMenu value) showMenu, required TResult Function(_ForceCollapse value) forceCollapse,
required TResult Function(SetCurrentPage value) setPage, required TResult Function(SetCurrentPage value) setPage,
required TResult Function(_ShowEditPannel value) setEditPannel, required TResult Function(_ShowEditPannel value) setEditPannel,
required TResult Function(_DismissEditPannel value) dismissEditPannel, required TResult Function(_DismissEditPannel value) dismissEditPannel,
@ -81,7 +81,7 @@ mixin _$HomeEvent {
@optionalTypeArgs @optionalTypeArgs
TResult maybeMap<TResult extends Object?>({ TResult maybeMap<TResult extends Object?>({
TResult Function(_ShowLoading value)? showLoading, TResult Function(_ShowLoading value)? showLoading,
TResult Function(_ShowMenu value)? showMenu, TResult Function(_ForceCollapse value)? forceCollapse,
TResult Function(SetCurrentPage value)? setPage, TResult Function(SetCurrentPage value)? setPage,
TResult Function(_ShowEditPannel value)? setEditPannel, TResult Function(_ShowEditPannel value)? setEditPannel,
TResult Function(_DismissEditPannel value)? dismissEditPannel, TResult Function(_DismissEditPannel value)? dismissEditPannel,
@ -171,7 +171,7 @@ class _$_ShowLoading implements _ShowLoading {
@optionalTypeArgs @optionalTypeArgs
TResult when<TResult extends Object?>({ TResult when<TResult extends Object?>({
required TResult Function(bool isLoading) showLoading, required TResult Function(bool isLoading) showLoading,
required TResult Function(bool isShow) showMenu, required TResult Function(bool forceCollapse) forceCollapse,
required TResult Function(PageContext context) setPage, required TResult Function(PageContext context) setPage,
required TResult Function(EditPannelContext editContext) setEditPannel, required TResult Function(EditPannelContext editContext) setEditPannel,
required TResult Function() dismissEditPannel, required TResult Function() dismissEditPannel,
@ -183,7 +183,7 @@ class _$_ShowLoading implements _ShowLoading {
@optionalTypeArgs @optionalTypeArgs
TResult maybeWhen<TResult extends Object?>({ TResult maybeWhen<TResult extends Object?>({
TResult Function(bool isLoading)? showLoading, TResult Function(bool isLoading)? showLoading,
TResult Function(bool isShow)? showMenu, TResult Function(bool forceCollapse)? forceCollapse,
TResult Function(PageContext context)? setPage, TResult Function(PageContext context)? setPage,
TResult Function(EditPannelContext editContext)? setEditPannel, TResult Function(EditPannelContext editContext)? setEditPannel,
TResult Function()? dismissEditPannel, TResult Function()? dismissEditPannel,
@ -199,7 +199,7 @@ class _$_ShowLoading implements _ShowLoading {
@optionalTypeArgs @optionalTypeArgs
TResult map<TResult extends Object?>({ TResult map<TResult extends Object?>({
required TResult Function(_ShowLoading value) showLoading, required TResult Function(_ShowLoading value) showLoading,
required TResult Function(_ShowMenu value) showMenu, required TResult Function(_ForceCollapse value) forceCollapse,
required TResult Function(SetCurrentPage value) setPage, required TResult Function(SetCurrentPage value) setPage,
required TResult Function(_ShowEditPannel value) setEditPannel, required TResult Function(_ShowEditPannel value) setEditPannel,
required TResult Function(_DismissEditPannel value) dismissEditPannel, required TResult Function(_DismissEditPannel value) dismissEditPannel,
@ -211,7 +211,7 @@ class _$_ShowLoading implements _ShowLoading {
@optionalTypeArgs @optionalTypeArgs
TResult maybeMap<TResult extends Object?>({ TResult maybeMap<TResult extends Object?>({
TResult Function(_ShowLoading value)? showLoading, TResult Function(_ShowLoading value)? showLoading,
TResult Function(_ShowMenu value)? showMenu, TResult Function(_ForceCollapse value)? forceCollapse,
TResult Function(SetCurrentPage value)? setPage, TResult Function(SetCurrentPage value)? setPage,
TResult Function(_ShowEditPannel value)? setEditPannel, TResult Function(_ShowEditPannel value)? setEditPannel,
TResult Function(_DismissEditPannel value)? dismissEditPannel, TResult Function(_DismissEditPannel value)? dismissEditPannel,
@ -234,29 +234,31 @@ abstract class _ShowLoading implements HomeEvent {
} }
/// @nodoc /// @nodoc
abstract class _$ShowMenuCopyWith<$Res> { abstract class _$ForceCollapseCopyWith<$Res> {
factory _$ShowMenuCopyWith(_ShowMenu value, $Res Function(_ShowMenu) then) = factory _$ForceCollapseCopyWith(
__$ShowMenuCopyWithImpl<$Res>; _ForceCollapse value, $Res Function(_ForceCollapse) then) =
$Res call({bool isShow}); __$ForceCollapseCopyWithImpl<$Res>;
$Res call({bool forceCollapse});
} }
/// @nodoc /// @nodoc
class __$ShowMenuCopyWithImpl<$Res> extends _$HomeEventCopyWithImpl<$Res> class __$ForceCollapseCopyWithImpl<$Res> extends _$HomeEventCopyWithImpl<$Res>
implements _$ShowMenuCopyWith<$Res> { implements _$ForceCollapseCopyWith<$Res> {
__$ShowMenuCopyWithImpl(_ShowMenu _value, $Res Function(_ShowMenu) _then) __$ForceCollapseCopyWithImpl(
: super(_value, (v) => _then(v as _ShowMenu)); _ForceCollapse _value, $Res Function(_ForceCollapse) _then)
: super(_value, (v) => _then(v as _ForceCollapse));
@override @override
_ShowMenu get _value => super._value as _ShowMenu; _ForceCollapse get _value => super._value as _ForceCollapse;
@override @override
$Res call({ $Res call({
Object? isShow = freezed, Object? forceCollapse = freezed,
}) { }) {
return _then(_ShowMenu( return _then(_ForceCollapse(
isShow == freezed forceCollapse == freezed
? _value.isShow ? _value.forceCollapse
: isShow // ignore: cast_nullable_to_non_nullable : forceCollapse // ignore: cast_nullable_to_non_nullable
as bool, as bool,
)); ));
} }
@ -264,58 +266,59 @@ class __$ShowMenuCopyWithImpl<$Res> extends _$HomeEventCopyWithImpl<$Res>
/// @nodoc /// @nodoc
class _$_ShowMenu implements _ShowMenu { class _$_ForceCollapse implements _ForceCollapse {
const _$_ShowMenu(this.isShow); const _$_ForceCollapse(this.forceCollapse);
@override @override
final bool isShow; final bool forceCollapse;
@override @override
String toString() { String toString() {
return 'HomeEvent.showMenu(isShow: $isShow)'; return 'HomeEvent.forceCollapse(forceCollapse: $forceCollapse)';
} }
@override @override
bool operator ==(dynamic other) { bool operator ==(dynamic other) {
return identical(this, other) || return identical(this, other) ||
(other is _ShowMenu && (other is _ForceCollapse &&
(identical(other.isShow, isShow) || (identical(other.forceCollapse, forceCollapse) ||
const DeepCollectionEquality().equals(other.isShow, isShow))); const DeepCollectionEquality()
.equals(other.forceCollapse, forceCollapse)));
} }
@override @override
int get hashCode => int get hashCode =>
runtimeType.hashCode ^ const DeepCollectionEquality().hash(isShow); runtimeType.hashCode ^ const DeepCollectionEquality().hash(forceCollapse);
@JsonKey(ignore: true) @JsonKey(ignore: true)
@override @override
_$ShowMenuCopyWith<_ShowMenu> get copyWith => _$ForceCollapseCopyWith<_ForceCollapse> get copyWith =>
__$ShowMenuCopyWithImpl<_ShowMenu>(this, _$identity); __$ForceCollapseCopyWithImpl<_ForceCollapse>(this, _$identity);
@override @override
@optionalTypeArgs @optionalTypeArgs
TResult when<TResult extends Object?>({ TResult when<TResult extends Object?>({
required TResult Function(bool isLoading) showLoading, required TResult Function(bool isLoading) showLoading,
required TResult Function(bool isShow) showMenu, required TResult Function(bool forceCollapse) forceCollapse,
required TResult Function(PageContext context) setPage, required TResult Function(PageContext context) setPage,
required TResult Function(EditPannelContext editContext) setEditPannel, required TResult Function(EditPannelContext editContext) setEditPannel,
required TResult Function() dismissEditPannel, required TResult Function() dismissEditPannel,
}) { }) {
return showMenu(isShow); return forceCollapse(this.forceCollapse);
} }
@override @override
@optionalTypeArgs @optionalTypeArgs
TResult maybeWhen<TResult extends Object?>({ TResult maybeWhen<TResult extends Object?>({
TResult Function(bool isLoading)? showLoading, TResult Function(bool isLoading)? showLoading,
TResult Function(bool isShow)? showMenu, TResult Function(bool forceCollapse)? forceCollapse,
TResult Function(PageContext context)? setPage, TResult Function(PageContext context)? setPage,
TResult Function(EditPannelContext editContext)? setEditPannel, TResult Function(EditPannelContext editContext)? setEditPannel,
TResult Function()? dismissEditPannel, TResult Function()? dismissEditPannel,
required TResult orElse(), required TResult orElse(),
}) { }) {
if (showMenu != null) { if (forceCollapse != null) {
return showMenu(isShow); return forceCollapse(this.forceCollapse);
} }
return orElse(); return orElse();
} }
@ -324,37 +327,37 @@ class _$_ShowMenu implements _ShowMenu {
@optionalTypeArgs @optionalTypeArgs
TResult map<TResult extends Object?>({ TResult map<TResult extends Object?>({
required TResult Function(_ShowLoading value) showLoading, required TResult Function(_ShowLoading value) showLoading,
required TResult Function(_ShowMenu value) showMenu, required TResult Function(_ForceCollapse value) forceCollapse,
required TResult Function(SetCurrentPage value) setPage, required TResult Function(SetCurrentPage value) setPage,
required TResult Function(_ShowEditPannel value) setEditPannel, required TResult Function(_ShowEditPannel value) setEditPannel,
required TResult Function(_DismissEditPannel value) dismissEditPannel, required TResult Function(_DismissEditPannel value) dismissEditPannel,
}) { }) {
return showMenu(this); return forceCollapse(this);
} }
@override @override
@optionalTypeArgs @optionalTypeArgs
TResult maybeMap<TResult extends Object?>({ TResult maybeMap<TResult extends Object?>({
TResult Function(_ShowLoading value)? showLoading, TResult Function(_ShowLoading value)? showLoading,
TResult Function(_ShowMenu value)? showMenu, TResult Function(_ForceCollapse value)? forceCollapse,
TResult Function(SetCurrentPage value)? setPage, TResult Function(SetCurrentPage value)? setPage,
TResult Function(_ShowEditPannel value)? setEditPannel, TResult Function(_ShowEditPannel value)? setEditPannel,
TResult Function(_DismissEditPannel value)? dismissEditPannel, TResult Function(_DismissEditPannel value)? dismissEditPannel,
required TResult orElse(), required TResult orElse(),
}) { }) {
if (showMenu != null) { if (forceCollapse != null) {
return showMenu(this); return forceCollapse(this);
} }
return orElse(); return orElse();
} }
} }
abstract class _ShowMenu implements HomeEvent { abstract class _ForceCollapse implements HomeEvent {
const factory _ShowMenu(bool isShow) = _$_ShowMenu; const factory _ForceCollapse(bool forceCollapse) = _$_ForceCollapse;
bool get isShow => throw _privateConstructorUsedError; bool get forceCollapse => throw _privateConstructorUsedError;
@JsonKey(ignore: true) @JsonKey(ignore: true)
_$ShowMenuCopyWith<_ShowMenu> get copyWith => _$ForceCollapseCopyWith<_ForceCollapse> get copyWith =>
throw _privateConstructorUsedError; throw _privateConstructorUsedError;
} }
@ -423,7 +426,7 @@ class _$SetCurrentPage implements SetCurrentPage {
@optionalTypeArgs @optionalTypeArgs
TResult when<TResult extends Object?>({ TResult when<TResult extends Object?>({
required TResult Function(bool isLoading) showLoading, required TResult Function(bool isLoading) showLoading,
required TResult Function(bool isShow) showMenu, required TResult Function(bool forceCollapse) forceCollapse,
required TResult Function(PageContext context) setPage, required TResult Function(PageContext context) setPage,
required TResult Function(EditPannelContext editContext) setEditPannel, required TResult Function(EditPannelContext editContext) setEditPannel,
required TResult Function() dismissEditPannel, required TResult Function() dismissEditPannel,
@ -435,7 +438,7 @@ class _$SetCurrentPage implements SetCurrentPage {
@optionalTypeArgs @optionalTypeArgs
TResult maybeWhen<TResult extends Object?>({ TResult maybeWhen<TResult extends Object?>({
TResult Function(bool isLoading)? showLoading, TResult Function(bool isLoading)? showLoading,
TResult Function(bool isShow)? showMenu, TResult Function(bool forceCollapse)? forceCollapse,
TResult Function(PageContext context)? setPage, TResult Function(PageContext context)? setPage,
TResult Function(EditPannelContext editContext)? setEditPannel, TResult Function(EditPannelContext editContext)? setEditPannel,
TResult Function()? dismissEditPannel, TResult Function()? dismissEditPannel,
@ -451,7 +454,7 @@ class _$SetCurrentPage implements SetCurrentPage {
@optionalTypeArgs @optionalTypeArgs
TResult map<TResult extends Object?>({ TResult map<TResult extends Object?>({
required TResult Function(_ShowLoading value) showLoading, required TResult Function(_ShowLoading value) showLoading,
required TResult Function(_ShowMenu value) showMenu, required TResult Function(_ForceCollapse value) forceCollapse,
required TResult Function(SetCurrentPage value) setPage, required TResult Function(SetCurrentPage value) setPage,
required TResult Function(_ShowEditPannel value) setEditPannel, required TResult Function(_ShowEditPannel value) setEditPannel,
required TResult Function(_DismissEditPannel value) dismissEditPannel, required TResult Function(_DismissEditPannel value) dismissEditPannel,
@ -463,7 +466,7 @@ class _$SetCurrentPage implements SetCurrentPage {
@optionalTypeArgs @optionalTypeArgs
TResult maybeMap<TResult extends Object?>({ TResult maybeMap<TResult extends Object?>({
TResult Function(_ShowLoading value)? showLoading, TResult Function(_ShowLoading value)? showLoading,
TResult Function(_ShowMenu value)? showMenu, TResult Function(_ForceCollapse value)? forceCollapse,
TResult Function(SetCurrentPage value)? setPage, TResult Function(SetCurrentPage value)? setPage,
TResult Function(_ShowEditPannel value)? setEditPannel, TResult Function(_ShowEditPannel value)? setEditPannel,
TResult Function(_DismissEditPannel value)? dismissEditPannel, TResult Function(_DismissEditPannel value)? dismissEditPannel,
@ -551,7 +554,7 @@ class _$_ShowEditPannel implements _ShowEditPannel {
@optionalTypeArgs @optionalTypeArgs
TResult when<TResult extends Object?>({ TResult when<TResult extends Object?>({
required TResult Function(bool isLoading) showLoading, required TResult Function(bool isLoading) showLoading,
required TResult Function(bool isShow) showMenu, required TResult Function(bool forceCollapse) forceCollapse,
required TResult Function(PageContext context) setPage, required TResult Function(PageContext context) setPage,
required TResult Function(EditPannelContext editContext) setEditPannel, required TResult Function(EditPannelContext editContext) setEditPannel,
required TResult Function() dismissEditPannel, required TResult Function() dismissEditPannel,
@ -563,7 +566,7 @@ class _$_ShowEditPannel implements _ShowEditPannel {
@optionalTypeArgs @optionalTypeArgs
TResult maybeWhen<TResult extends Object?>({ TResult maybeWhen<TResult extends Object?>({
TResult Function(bool isLoading)? showLoading, TResult Function(bool isLoading)? showLoading,
TResult Function(bool isShow)? showMenu, TResult Function(bool forceCollapse)? forceCollapse,
TResult Function(PageContext context)? setPage, TResult Function(PageContext context)? setPage,
TResult Function(EditPannelContext editContext)? setEditPannel, TResult Function(EditPannelContext editContext)? setEditPannel,
TResult Function()? dismissEditPannel, TResult Function()? dismissEditPannel,
@ -579,7 +582,7 @@ class _$_ShowEditPannel implements _ShowEditPannel {
@optionalTypeArgs @optionalTypeArgs
TResult map<TResult extends Object?>({ TResult map<TResult extends Object?>({
required TResult Function(_ShowLoading value) showLoading, required TResult Function(_ShowLoading value) showLoading,
required TResult Function(_ShowMenu value) showMenu, required TResult Function(_ForceCollapse value) forceCollapse,
required TResult Function(SetCurrentPage value) setPage, required TResult Function(SetCurrentPage value) setPage,
required TResult Function(_ShowEditPannel value) setEditPannel, required TResult Function(_ShowEditPannel value) setEditPannel,
required TResult Function(_DismissEditPannel value) dismissEditPannel, required TResult Function(_DismissEditPannel value) dismissEditPannel,
@ -591,7 +594,7 @@ class _$_ShowEditPannel implements _ShowEditPannel {
@optionalTypeArgs @optionalTypeArgs
TResult maybeMap<TResult extends Object?>({ TResult maybeMap<TResult extends Object?>({
TResult Function(_ShowLoading value)? showLoading, TResult Function(_ShowLoading value)? showLoading,
TResult Function(_ShowMenu value)? showMenu, TResult Function(_ForceCollapse value)? forceCollapse,
TResult Function(SetCurrentPage value)? setPage, TResult Function(SetCurrentPage value)? setPage,
TResult Function(_ShowEditPannel value)? setEditPannel, TResult Function(_ShowEditPannel value)? setEditPannel,
TResult Function(_DismissEditPannel value)? dismissEditPannel, TResult Function(_DismissEditPannel value)? dismissEditPannel,
@ -655,7 +658,7 @@ class _$_DismissEditPannel implements _DismissEditPannel {
@optionalTypeArgs @optionalTypeArgs
TResult when<TResult extends Object?>({ TResult when<TResult extends Object?>({
required TResult Function(bool isLoading) showLoading, required TResult Function(bool isLoading) showLoading,
required TResult Function(bool isShow) showMenu, required TResult Function(bool forceCollapse) forceCollapse,
required TResult Function(PageContext context) setPage, required TResult Function(PageContext context) setPage,
required TResult Function(EditPannelContext editContext) setEditPannel, required TResult Function(EditPannelContext editContext) setEditPannel,
required TResult Function() dismissEditPannel, required TResult Function() dismissEditPannel,
@ -667,7 +670,7 @@ class _$_DismissEditPannel implements _DismissEditPannel {
@optionalTypeArgs @optionalTypeArgs
TResult maybeWhen<TResult extends Object?>({ TResult maybeWhen<TResult extends Object?>({
TResult Function(bool isLoading)? showLoading, TResult Function(bool isLoading)? showLoading,
TResult Function(bool isShow)? showMenu, TResult Function(bool forceCollapse)? forceCollapse,
TResult Function(PageContext context)? setPage, TResult Function(PageContext context)? setPage,
TResult Function(EditPannelContext editContext)? setEditPannel, TResult Function(EditPannelContext editContext)? setEditPannel,
TResult Function()? dismissEditPannel, TResult Function()? dismissEditPannel,
@ -683,7 +686,7 @@ class _$_DismissEditPannel implements _DismissEditPannel {
@optionalTypeArgs @optionalTypeArgs
TResult map<TResult extends Object?>({ TResult map<TResult extends Object?>({
required TResult Function(_ShowLoading value) showLoading, required TResult Function(_ShowLoading value) showLoading,
required TResult Function(_ShowMenu value) showMenu, required TResult Function(_ForceCollapse value) forceCollapse,
required TResult Function(SetCurrentPage value) setPage, required TResult Function(SetCurrentPage value) setPage,
required TResult Function(_ShowEditPannel value) setEditPannel, required TResult Function(_ShowEditPannel value) setEditPannel,
required TResult Function(_DismissEditPannel value) dismissEditPannel, required TResult Function(_DismissEditPannel value) dismissEditPannel,
@ -695,7 +698,7 @@ class _$_DismissEditPannel implements _DismissEditPannel {
@optionalTypeArgs @optionalTypeArgs
TResult maybeMap<TResult extends Object?>({ TResult maybeMap<TResult extends Object?>({
TResult Function(_ShowLoading value)? showLoading, TResult Function(_ShowLoading value)? showLoading,
TResult Function(_ShowMenu value)? showMenu, TResult Function(_ForceCollapse value)? forceCollapse,
TResult Function(SetCurrentPage value)? setPage, TResult Function(SetCurrentPage value)? setPage,
TResult Function(_ShowEditPannel value)? setEditPannel, TResult Function(_ShowEditPannel value)? setEditPannel,
TResult Function(_DismissEditPannel value)? dismissEditPannel, TResult Function(_DismissEditPannel value)? dismissEditPannel,
@ -718,12 +721,12 @@ class _$HomeStateTearOff {
_HomeState call( _HomeState call(
{required bool isLoading, {required bool isLoading,
required bool showMenu, required bool forceCollapse,
required PageContext pageContext, required PageContext pageContext,
required Option<EditPannelContext> editContext}) { required Option<EditPannelContext> editContext}) {
return _HomeState( return _HomeState(
isLoading: isLoading, isLoading: isLoading,
showMenu: showMenu, forceCollapse: forceCollapse,
pageContext: pageContext, pageContext: pageContext,
editContext: editContext, editContext: editContext,
); );
@ -736,7 +739,7 @@ const $HomeState = _$HomeStateTearOff();
/// @nodoc /// @nodoc
mixin _$HomeState { mixin _$HomeState {
bool get isLoading => throw _privateConstructorUsedError; bool get isLoading => throw _privateConstructorUsedError;
bool get showMenu => throw _privateConstructorUsedError; bool get forceCollapse => throw _privateConstructorUsedError;
PageContext get pageContext => throw _privateConstructorUsedError; PageContext get pageContext => throw _privateConstructorUsedError;
Option<EditPannelContext> get editContext => Option<EditPannelContext> get editContext =>
throw _privateConstructorUsedError; throw _privateConstructorUsedError;
@ -752,7 +755,7 @@ abstract class $HomeStateCopyWith<$Res> {
_$HomeStateCopyWithImpl<$Res>; _$HomeStateCopyWithImpl<$Res>;
$Res call( $Res call(
{bool isLoading, {bool isLoading,
bool showMenu, bool forceCollapse,
PageContext pageContext, PageContext pageContext,
Option<EditPannelContext> editContext}); Option<EditPannelContext> editContext});
} }
@ -768,7 +771,7 @@ class _$HomeStateCopyWithImpl<$Res> implements $HomeStateCopyWith<$Res> {
@override @override
$Res call({ $Res call({
Object? isLoading = freezed, Object? isLoading = freezed,
Object? showMenu = freezed, Object? forceCollapse = freezed,
Object? pageContext = freezed, Object? pageContext = freezed,
Object? editContext = freezed, Object? editContext = freezed,
}) { }) {
@ -777,9 +780,9 @@ class _$HomeStateCopyWithImpl<$Res> implements $HomeStateCopyWith<$Res> {
? _value.isLoading ? _value.isLoading
: isLoading // ignore: cast_nullable_to_non_nullable : isLoading // ignore: cast_nullable_to_non_nullable
as bool, as bool,
showMenu: showMenu == freezed forceCollapse: forceCollapse == freezed
? _value.showMenu ? _value.forceCollapse
: showMenu // ignore: cast_nullable_to_non_nullable : forceCollapse // ignore: cast_nullable_to_non_nullable
as bool, as bool,
pageContext: pageContext == freezed pageContext: pageContext == freezed
? _value.pageContext ? _value.pageContext
@ -801,7 +804,7 @@ abstract class _$HomeStateCopyWith<$Res> implements $HomeStateCopyWith<$Res> {
@override @override
$Res call( $Res call(
{bool isLoading, {bool isLoading,
bool showMenu, bool forceCollapse,
PageContext pageContext, PageContext pageContext,
Option<EditPannelContext> editContext}); Option<EditPannelContext> editContext});
} }
@ -818,7 +821,7 @@ class __$HomeStateCopyWithImpl<$Res> extends _$HomeStateCopyWithImpl<$Res>
@override @override
$Res call({ $Res call({
Object? isLoading = freezed, Object? isLoading = freezed,
Object? showMenu = freezed, Object? forceCollapse = freezed,
Object? pageContext = freezed, Object? pageContext = freezed,
Object? editContext = freezed, Object? editContext = freezed,
}) { }) {
@ -827,9 +830,9 @@ class __$HomeStateCopyWithImpl<$Res> extends _$HomeStateCopyWithImpl<$Res>
? _value.isLoading ? _value.isLoading
: isLoading // ignore: cast_nullable_to_non_nullable : isLoading // ignore: cast_nullable_to_non_nullable
as bool, as bool,
showMenu: showMenu == freezed forceCollapse: forceCollapse == freezed
? _value.showMenu ? _value.forceCollapse
: showMenu // ignore: cast_nullable_to_non_nullable : forceCollapse // ignore: cast_nullable_to_non_nullable
as bool, as bool,
pageContext: pageContext == freezed pageContext: pageContext == freezed
? _value.pageContext ? _value.pageContext
@ -848,14 +851,14 @@ class __$HomeStateCopyWithImpl<$Res> extends _$HomeStateCopyWithImpl<$Res>
class _$_HomeState implements _HomeState { class _$_HomeState implements _HomeState {
const _$_HomeState( const _$_HomeState(
{required this.isLoading, {required this.isLoading,
required this.showMenu, required this.forceCollapse,
required this.pageContext, required this.pageContext,
required this.editContext}); required this.editContext});
@override @override
final bool isLoading; final bool isLoading;
@override @override
final bool showMenu; final bool forceCollapse;
@override @override
final PageContext pageContext; final PageContext pageContext;
@override @override
@ -863,7 +866,7 @@ class _$_HomeState implements _HomeState {
@override @override
String toString() { String toString() {
return 'HomeState(isLoading: $isLoading, showMenu: $showMenu, pageContext: $pageContext, editContext: $editContext)'; return 'HomeState(isLoading: $isLoading, forceCollapse: $forceCollapse, pageContext: $pageContext, editContext: $editContext)';
} }
@override @override
@ -873,9 +876,9 @@ class _$_HomeState implements _HomeState {
(identical(other.isLoading, isLoading) || (identical(other.isLoading, isLoading) ||
const DeepCollectionEquality() const DeepCollectionEquality()
.equals(other.isLoading, isLoading)) && .equals(other.isLoading, isLoading)) &&
(identical(other.showMenu, showMenu) || (identical(other.forceCollapse, forceCollapse) ||
const DeepCollectionEquality() const DeepCollectionEquality()
.equals(other.showMenu, showMenu)) && .equals(other.forceCollapse, forceCollapse)) &&
(identical(other.pageContext, pageContext) || (identical(other.pageContext, pageContext) ||
const DeepCollectionEquality() const DeepCollectionEquality()
.equals(other.pageContext, pageContext)) && .equals(other.pageContext, pageContext)) &&
@ -888,7 +891,7 @@ class _$_HomeState implements _HomeState {
int get hashCode => int get hashCode =>
runtimeType.hashCode ^ runtimeType.hashCode ^
const DeepCollectionEquality().hash(isLoading) ^ const DeepCollectionEquality().hash(isLoading) ^
const DeepCollectionEquality().hash(showMenu) ^ const DeepCollectionEquality().hash(forceCollapse) ^
const DeepCollectionEquality().hash(pageContext) ^ const DeepCollectionEquality().hash(pageContext) ^
const DeepCollectionEquality().hash(editContext); const DeepCollectionEquality().hash(editContext);
@ -901,14 +904,14 @@ class _$_HomeState implements _HomeState {
abstract class _HomeState implements HomeState { abstract class _HomeState implements HomeState {
const factory _HomeState( const factory _HomeState(
{required bool isLoading, {required bool isLoading,
required bool showMenu, required bool forceCollapse,
required PageContext pageContext, required PageContext pageContext,
required Option<EditPannelContext> editContext}) = _$_HomeState; required Option<EditPannelContext> editContext}) = _$_HomeState;
@override @override
bool get isLoading => throw _privateConstructorUsedError; bool get isLoading => throw _privateConstructorUsedError;
@override @override
bool get showMenu => throw _privateConstructorUsedError; bool get forceCollapse => throw _privateConstructorUsedError;
@override @override
PageContext get pageContext => throw _privateConstructorUsedError; PageContext get pageContext => throw _privateConstructorUsedError;
@override @override

View File

@ -3,7 +3,7 @@ part of 'home_bloc.dart';
@freezed @freezed
abstract class HomeEvent with _$HomeEvent { abstract class HomeEvent with _$HomeEvent {
const factory HomeEvent.showLoading(bool isLoading) = _ShowLoading; const factory HomeEvent.showLoading(bool isLoading) = _ShowLoading;
const factory HomeEvent.showMenu(bool isShow) = _ShowMenu; const factory HomeEvent.forceCollapse(bool forceCollapse) = _ForceCollapse;
//page //page
const factory HomeEvent.setPage(PageContext context) = SetCurrentPage; const factory HomeEvent.setPage(PageContext context) = SetCurrentPage;

View File

@ -4,14 +4,14 @@ part of 'home_bloc.dart';
abstract class HomeState implements _$HomeState { abstract class HomeState implements _$HomeState {
const factory HomeState({ const factory HomeState({
required bool isLoading, required bool isLoading,
required bool showMenu, required bool forceCollapse,
required PageContext pageContext, required PageContext pageContext,
required Option<EditPannelContext> editContext, required Option<EditPannelContext> editContext,
}) = _HomeState; }) = _HomeState;
factory HomeState.initial() => HomeState( factory HomeState.initial() => HomeState(
isLoading: false, isLoading: false,
showMenu: true, forceCollapse: false,
pageContext: const BlankPageContext(), pageContext: const BlankPageContext(),
editContext: none(), editContext: none(),
); );

View File

@ -33,7 +33,7 @@ class MenuBloc extends Bloc<MenuEvent, MenuState> {
yield state.copyWith(pageContext: some(e.context)); yield state.copyWith(pageContext: some(e.context));
} }
Stream<MenuState> _performActionOnCreateApp(_CreateApp e) async* { Stream<MenuState> _performActionOnCreateApp(_CreateApp val) async* {
yield state; yield state;
} }

View File

@ -26,8 +26,10 @@ class _$MenuEventTearOff {
); );
} }
_CreateApp createApp() { _CreateApp createApp(String appName) {
return const _CreateApp(); return _CreateApp(
appName,
);
} }
} }
@ -40,14 +42,14 @@ mixin _$MenuEvent {
TResult when<TResult extends Object?>({ TResult when<TResult extends Object?>({
required TResult Function() collapse, required TResult Function() collapse,
required TResult Function(PageContext context) openPage, required TResult Function(PageContext context) openPage,
required TResult Function() createApp, required TResult Function(String appName) createApp,
}) => }) =>
throw _privateConstructorUsedError; throw _privateConstructorUsedError;
@optionalTypeArgs @optionalTypeArgs
TResult maybeWhen<TResult extends Object?>({ TResult maybeWhen<TResult extends Object?>({
TResult Function()? collapse, TResult Function()? collapse,
TResult Function(PageContext context)? openPage, TResult Function(PageContext context)? openPage,
TResult Function()? createApp, TResult Function(String appName)? createApp,
required TResult orElse(), required TResult orElse(),
}) => }) =>
throw _privateConstructorUsedError; throw _privateConstructorUsedError;
@ -122,7 +124,7 @@ class _$Collapse implements Collapse {
TResult when<TResult extends Object?>({ TResult when<TResult extends Object?>({
required TResult Function() collapse, required TResult Function() collapse,
required TResult Function(PageContext context) openPage, required TResult Function(PageContext context) openPage,
required TResult Function() createApp, required TResult Function(String appName) createApp,
}) { }) {
return collapse(); return collapse();
} }
@ -132,7 +134,7 @@ class _$Collapse implements Collapse {
TResult maybeWhen<TResult extends Object?>({ TResult maybeWhen<TResult extends Object?>({
TResult Function()? collapse, TResult Function()? collapse,
TResult Function(PageContext context)? openPage, TResult Function(PageContext context)? openPage,
TResult Function()? createApp, TResult Function(String appName)? createApp,
required TResult orElse(), required TResult orElse(),
}) { }) {
if (collapse != null) { if (collapse != null) {
@ -234,7 +236,7 @@ class _$_OpenPage implements _OpenPage {
TResult when<TResult extends Object?>({ TResult when<TResult extends Object?>({
required TResult Function() collapse, required TResult Function() collapse,
required TResult Function(PageContext context) openPage, required TResult Function(PageContext context) openPage,
required TResult Function() createApp, required TResult Function(String appName) createApp,
}) { }) {
return openPage(context); return openPage(context);
} }
@ -244,7 +246,7 @@ class _$_OpenPage implements _OpenPage {
TResult maybeWhen<TResult extends Object?>({ TResult maybeWhen<TResult extends Object?>({
TResult Function()? collapse, TResult Function()? collapse,
TResult Function(PageContext context)? openPage, TResult Function(PageContext context)? openPage,
TResult Function()? createApp, TResult Function(String appName)? createApp,
required TResult orElse(), required TResult orElse(),
}) { }) {
if (openPage != null) { if (openPage != null) {
@ -292,6 +294,7 @@ abstract class _$CreateAppCopyWith<$Res> {
factory _$CreateAppCopyWith( factory _$CreateAppCopyWith(
_CreateApp value, $Res Function(_CreateApp) then) = _CreateApp value, $Res Function(_CreateApp) then) =
__$CreateAppCopyWithImpl<$Res>; __$CreateAppCopyWithImpl<$Res>;
$Res call({String appName});
} }
/// @nodoc /// @nodoc
@ -302,34 +305,58 @@ class __$CreateAppCopyWithImpl<$Res> extends _$MenuEventCopyWithImpl<$Res>
@override @override
_CreateApp get _value => super._value as _CreateApp; _CreateApp get _value => super._value as _CreateApp;
@override
$Res call({
Object? appName = freezed,
}) {
return _then(_CreateApp(
appName == freezed
? _value.appName
: appName // ignore: cast_nullable_to_non_nullable
as String,
));
}
} }
/// @nodoc /// @nodoc
class _$_CreateApp implements _CreateApp { class _$_CreateApp implements _CreateApp {
const _$_CreateApp(); const _$_CreateApp(this.appName);
@override
final String appName;
@override @override
String toString() { String toString() {
return 'MenuEvent.createApp()'; return 'MenuEvent.createApp(appName: $appName)';
} }
@override @override
bool operator ==(dynamic other) { bool operator ==(dynamic other) {
return identical(this, other) || (other is _CreateApp); return identical(this, other) ||
(other is _CreateApp &&
(identical(other.appName, appName) ||
const DeepCollectionEquality().equals(other.appName, appName)));
} }
@override @override
int get hashCode => runtimeType.hashCode; int get hashCode =>
runtimeType.hashCode ^ const DeepCollectionEquality().hash(appName);
@JsonKey(ignore: true)
@override
_$CreateAppCopyWith<_CreateApp> get copyWith =>
__$CreateAppCopyWithImpl<_CreateApp>(this, _$identity);
@override @override
@optionalTypeArgs @optionalTypeArgs
TResult when<TResult extends Object?>({ TResult when<TResult extends Object?>({
required TResult Function() collapse, required TResult Function() collapse,
required TResult Function(PageContext context) openPage, required TResult Function(PageContext context) openPage,
required TResult Function() createApp, required TResult Function(String appName) createApp,
}) { }) {
return createApp(); return createApp(appName);
} }
@override @override
@ -337,11 +364,11 @@ class _$_CreateApp implements _CreateApp {
TResult maybeWhen<TResult extends Object?>({ TResult maybeWhen<TResult extends Object?>({
TResult Function()? collapse, TResult Function()? collapse,
TResult Function(PageContext context)? openPage, TResult Function(PageContext context)? openPage,
TResult Function()? createApp, TResult Function(String appName)? createApp,
required TResult orElse(), required TResult orElse(),
}) { }) {
if (createApp != null) { if (createApp != null) {
return createApp(); return createApp(appName);
} }
return orElse(); return orElse();
} }
@ -372,7 +399,12 @@ class _$_CreateApp implements _CreateApp {
} }
abstract class _CreateApp implements MenuEvent { abstract class _CreateApp implements MenuEvent {
const factory _CreateApp() = _$_CreateApp; const factory _CreateApp(String appName) = _$_CreateApp;
String get appName => throw _privateConstructorUsedError;
@JsonKey(ignore: true)
_$CreateAppCopyWith<_CreateApp> get copyWith =>
throw _privateConstructorUsedError;
} }
/// @nodoc /// @nodoc

View File

@ -4,5 +4,5 @@ part of 'menu_bloc.dart';
abstract class MenuEvent with _$MenuEvent { abstract class MenuEvent with _$MenuEvent {
const factory MenuEvent.collapse() = Collapse; const factory MenuEvent.collapse() = Collapse;
const factory MenuEvent.openPage(PageContext context) = _OpenPage; const factory MenuEvent.openPage(PageContext context) = _OpenPage;
const factory MenuEvent.createApp() = _CreateApp; const factory MenuEvent.createApp(String appName) = _CreateApp;
} }

View File

@ -17,7 +17,8 @@ class HomeLayout {
late double homePageROffset; late double homePageROffset;
late Duration animDuration; late Duration animDuration;
HomeLayout(BuildContext context, BoxConstraints homeScreenConstraint) { HomeLayout(BuildContext context, BoxConstraints homeScreenConstraint,
bool forceCollapse) {
final homeBlocState = context.read<HomeBloc>().state; final homeBlocState = context.read<HomeBloc>().state;
showEditPannel = homeBlocState.editContext.isSome(); showEditPannel = homeBlocState.editContext.isSome();
@ -27,12 +28,11 @@ class HomeLayout {
menuWidth = Sizes.sideBarLg; menuWidth = Sizes.sideBarLg;
} }
// if (menuBlocState.isCollapse) { if (forceCollapse) {
// showMenu = false; showMenu = false;
// } else { } else {
// showMenu = context.widthPx > PageBreaks.TabletPortrait;
// }
showMenu = context.widthPx > PageBreaks.tabletPortrait; showMenu = context.widthPx > PageBreaks.tabletPortrait;
}
homePageLOffset = showMenu ? menuWidth : 0.0; homePageLOffset = showMenu ? menuWidth : 0.0;
animDuration = .35.seconds; animDuration = .35.seconds;

View File

@ -29,10 +29,12 @@ class HomeScreen extends StatelessWidget {
child: Scaffold( child: Scaffold(
key: HomeScreen.scaffoldKey, key: HomeScreen.scaffoldKey,
body: BlocBuilder<HomeBloc, HomeState>( body: BlocBuilder<HomeBloc, HomeState>(
buildWhen: (previous, current) => previous != current,
builder: (context, state) { builder: (context, state) {
return StyledContainer( return StyledContainer(
Theme.of(context).colorScheme.background, Theme.of(context).colorScheme.background,
child: _buildBody(state), child: _buildBody(
state, context.read<HomeBloc>().state.forceCollapse),
); );
}, },
), ),
@ -40,10 +42,10 @@ class HomeScreen extends StatelessWidget {
); );
} }
Widget _buildBody(HomeState state) { Widget _buildBody(HomeState state, bool forceCollapse) {
return LayoutBuilder( return LayoutBuilder(
builder: (BuildContext context, BoxConstraints constraints) { builder: (BuildContext context, BoxConstraints constraints) {
final layout = HomeLayout(context, constraints); final layout = HomeLayout(context, constraints, forceCollapse);
const homePage = HomePage(); const homePage = HomePage();
final menu = _buildHomeMenu( final menu = _buildHomeMenu(
layout: layout, layout: layout,
@ -76,7 +78,7 @@ class HomeScreen extends StatelessWidget {
); );
}, },
isCollapseChanged: (isCollapse) { isCollapseChanged: (isCollapse) {
homeBloc.add(HomeEvent.showMenu(!isCollapse)); homeBloc.add(HomeEvent.forceCollapse(isCollapse));
}, },
); );
homeMenu = RepaintBoundary(child: homeMenu); homeMenu = RepaintBoundary(child: homeMenu);

View File

@ -1,12 +1,20 @@
import 'package:app_flowy/home/application/menu/menu_bloc.dart'; import 'package:app_flowy/home/application/menu/menu_bloc.dart';
import 'package:app_flowy/home/domain/page_context.dart'; import 'package:app_flowy/home/domain/page_context.dart';
import 'package:app_flowy/startup/startup.dart'; import 'package:app_flowy/startup/startup.dart';
import 'package:app_flowy/startup/tasks/app_widget_task.dart';
import 'package:dartz/dartz.dart'; import 'package:dartz/dartz.dart';
import 'package:flowy_infra/size.dart'; import 'package:flowy_infra/size.dart';
import 'package:flowy_infra/text_style.dart';
import 'package:flowy_infra/theme.dart';
import 'package:flowy_infra_ui/style_widget/styled_text_input.dart';
import 'package:flowy_infra_ui/widget/buttons/ok_cancel_button.dart';
import 'package:flowy_infra_ui/widget/dialog/styled_dialogs.dart';
import 'package:flowy_infra_ui/widget/spacing.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 '../../home_sizes.dart'; import '../../home_sizes.dart';
import 'package:styled_widget/styled_widget.dart'; import 'package:styled_widget/styled_widget.dart';
import 'package:textstyle_extensions/textstyle_extensions.dart';
class HomeMenu extends StatelessWidget { class HomeMenu extends StatelessWidget {
final Function(Option<PageContext>) pageContextChanged; final Function(Option<PageContext>) pageContextChanged;
@ -20,32 +28,10 @@ class HomeMenu extends StatelessWidget {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return MultiBlocProvider( return BlocProvider(
providers: [ create: (context) => getIt<MenuBloc>(),
BlocProvider<MenuBloc>(create: (context) => getIt<MenuBloc>()),
],
child: MultiBlocListener( child: MultiBlocListener(
listeners: bind(), listeners: [
child: Container(
color: Theme.of(context).colorScheme.primaryVariant,
child: Padding(
padding: EdgeInsets.symmetric(horizontal: Insets.sm),
child: Column(
mainAxisAlignment: MainAxisAlignment.start,
children: [
const MenuTopBar(),
Container(),
const NewAppButton(),
],
),
),
),
));
}
// bind the function passed by ooutter with the bloc listener
List<BlocListener<MenuBloc, MenuState>> bind() {
return [
BlocListener<MenuBloc, MenuState>( BlocListener<MenuBloc, MenuState>(
listenWhen: (p, c) => p.pageContext != c.pageContext, listenWhen: (p, c) => p.pageContext != c.pageContext,
listener: (context, state) => pageContextChanged(state.pageContext), listener: (context, state) => pageContextChanged(state.pageContext),
@ -54,7 +40,29 @@ class HomeMenu extends StatelessWidget {
listenWhen: (p, c) => p.isCollapse != c.isCollapse, listenWhen: (p, c) => p.isCollapse != c.isCollapse,
listener: (context, state) => isCollapseChanged(state.isCollapse), listener: (context, state) => isCollapseChanged(state.isCollapse),
) )
]; ],
child: BlocBuilder<MenuBloc, MenuState>(
builder: (context, state) => _renderBody(context),
),
),
);
}
Widget _renderBody(BuildContext context) {
return Container(
color: Theme.of(context).colorScheme.primaryVariant,
child: Column(
mainAxisAlignment: MainAxisAlignment.start,
children: [
const MenuTopBar(),
Expanded(child: Container()),
NewAppButton(
createAppCallback: (appName) =>
context.read<MenuBloc>().add(MenuEvent.createApp(appName)),
),
],
).padding(horizontal: Insets.sm),
);
} }
} }
@ -87,7 +95,9 @@ class MenuTopBar extends StatelessWidget {
} }
class NewAppButton extends StatelessWidget { class NewAppButton extends StatelessWidget {
const NewAppButton({Key? key}) : super(key: key); final Function(String)? createAppCallback;
const NewAppButton({this.createAppCallback, Key? key}) : super(key: key);
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return SizedBox( return SizedBox(
@ -100,22 +110,82 @@ class NewAppButton extends StatelessWidget {
width: 10, width: 10,
), ),
TextButton( TextButton(
onPressed: () async { onPressed: () async => await _showCreateAppDialog(context),
// Dialogs.show(OkCancelDialog( child: _buttonTitle(),
// title: "No Connection",
// message:
// "It appears your device is offline. Please check your connection and try again.",
// onOkPressed: () => AppGlobals.nav.pop(),
// ));
},
child: const Text('New App',
style: TextStyle(
color: Colors.black,
fontWeight: FontWeight.bold,
fontSize: 20)),
) )
], ],
), ),
); );
} }
Widget _buttonTitle() {
return const Text('New App',
style: TextStyle(
color: Colors.black,
fontWeight: FontWeight.bold,
fontSize: 20,
));
}
Future<void> _showCreateAppDialog(BuildContext context) async {
await Dialogs.showWithContext(CreateAppDialogContext(
confirm: (appName) {
if (appName.isNotEmpty && createAppCallback != null) {
createAppCallback!(appName);
}
},
), context);
}
}
//ignore: must_be_immutable
class CreateAppDialogContext extends DialogContext {
String appName;
final Function(String)? confirm;
CreateAppDialogContext({this.appName = "", this.confirm})
: super(identifier: 'CreateAppDialogContext');
@override
Widget buildWiget(BuildContext context) {
final theme = context.watch<AppTheme>();
return StyledDialog(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
...[
Text('Create App'.toUpperCase(),
style: TextStyles.T1.textColor(theme.accent1Darker)),
VSpace(Insets.sm * 1.5),
// Container(color: theme.greyWeak.withOpacity(.35), height: 1),
VSpace(Insets.m * 1.5),
],
StyledFormTextInput(
hintText: "App name",
onChanged: (text) {
appName = text;
},
),
SizedBox(height: Insets.l),
OkCancelButton(
onOkPressed: () {
if (confirm != null) {
confirm!(appName);
AppGlobals.nav.pop();
}
},
onCancelPressed: () {
AppGlobals.nav.pop();
},
)
],
),
);
}
@override
List<Object> get props => [identifier];
@override
bool get barrierDismissable => false;
} }

View File

@ -2,6 +2,105 @@
/// Auto gen code from rust ast, do not edit /// Auto gen code from rust ast, do not edit
part of 'dispatch.dart'; part of 'dispatch.dart';
class WorkspaceEventCreateWorkspace {
CreateWorkspaceRequest request;
WorkspaceEventCreateWorkspace(this.request);
Future<Either<Workspace, WorkspaceError>> send() {
final request = FFIRequest.create()
..event = WorkspaceEvent.CreateWorkspace.toString()
..payload = requestToBytes(this.request);
return Dispatch.asyncRequest(request)
.then((bytesResult) => bytesResult.fold(
(okBytes) => left(Workspace.fromBuffer(okBytes)),
(errBytes) => right(WorkspaceError.fromBuffer(errBytes)),
));
}
}
class WorkspaceEventGetCurWorkspace {
WorkspaceEventGetCurWorkspace();
Future<Either<Workspace, WorkspaceError>> send() {
final request = FFIRequest.create()
..event = WorkspaceEvent.GetCurWorkspace.toString();
return Dispatch.asyncRequest(request).then((bytesResult) => bytesResult.fold(
(okBytes) => left(Workspace.fromBuffer(okBytes)),
(errBytes) => right(WorkspaceError.fromBuffer(errBytes)),
));
}
}
class WorkspaceEventGetWorkspace {
QueryWorkspaceRequest request;
WorkspaceEventGetWorkspace(this.request);
Future<Either<Workspace, WorkspaceError>> send() {
final request = FFIRequest.create()
..event = WorkspaceEvent.GetWorkspace.toString()
..payload = requestToBytes(this.request);
return Dispatch.asyncRequest(request)
.then((bytesResult) => bytesResult.fold(
(okBytes) => left(Workspace.fromBuffer(okBytes)),
(errBytes) => right(WorkspaceError.fromBuffer(errBytes)),
));
}
}
class WorkspaceEventCreateApp {
CreateAppRequest request;
WorkspaceEventCreateApp(this.request);
Future<Either<App, WorkspaceError>> send() {
final request = FFIRequest.create()
..event = WorkspaceEvent.CreateApp.toString()
..payload = requestToBytes(this.request);
return Dispatch.asyncRequest(request)
.then((bytesResult) => bytesResult.fold(
(okBytes) => left(App.fromBuffer(okBytes)),
(errBytes) => right(WorkspaceError.fromBuffer(errBytes)),
));
}
}
class WorkspaceEventGetApp {
QueryAppRequest request;
WorkspaceEventGetApp(this.request);
Future<Either<App, WorkspaceError>> send() {
final request = FFIRequest.create()
..event = WorkspaceEvent.GetApp.toString()
..payload = requestToBytes(this.request);
return Dispatch.asyncRequest(request)
.then((bytesResult) => bytesResult.fold(
(okBytes) => left(App.fromBuffer(okBytes)),
(errBytes) => right(WorkspaceError.fromBuffer(errBytes)),
));
}
}
class WorkspaceEventCreateView {
CreateViewRequest request;
WorkspaceEventCreateView(this.request);
Future<Either<View, WorkspaceError>> send() {
final request = FFIRequest.create()
..event = WorkspaceEvent.CreateView.toString()
..payload = requestToBytes(this.request);
return Dispatch.asyncRequest(request)
.then((bytesResult) => bytesResult.fold(
(okBytes) => left(View.fromBuffer(okBytes)),
(errBytes) => right(WorkspaceError.fromBuffer(errBytes)),
));
}
}
class UserEventGetStatus { class UserEventGetStatus {
UserEventGetStatus(); UserEventGetStatus();
@ -64,3 +163,20 @@ class UserEventSignOut {
} }
} }
class UserEventUpdateUser {
UpdateUserRequest request;
UserEventUpdateUser(this.request);
Future<Either<UserDetail, UserError>> send() {
final request = FFIRequest.create()
..event = UserEvent.UpdateUser.toString()
..payload = requestToBytes(this.request);
return Dispatch.asyncRequest(request)
.then((bytesResult) => bytesResult.fold(
(okBytes) => left(UserDetail.fromBuffer(okBytes)),
(errBytes) => right(UserError.fromBuffer(errBytes)),
));
}
}

View File

@ -12,6 +12,7 @@ import 'dart:typed_data';
import 'package:flowy_sdk/ffi.dart' as ffi; import 'package:flowy_sdk/ffi.dart' as ffi;
import 'package:flowy_sdk/protobuf/flowy-user/protobuf.dart'; import 'package:flowy_sdk/protobuf/flowy-user/protobuf.dart';
import 'package:flowy_sdk/protobuf/dart-ffi/protobuf.dart'; import 'package:flowy_sdk/protobuf/dart-ffi/protobuf.dart';
import 'package:flowy_sdk/protobuf/flowy-workspace/protobuf.dart';
// ignore: unused_import // ignore: unused_import
import 'package:flowy_sdk/protobuf/flowy-infra/protobuf.dart'; import 'package:flowy_sdk/protobuf/flowy-infra/protobuf.dart';
import 'package:protobuf/protobuf.dart'; import 'package:protobuf/protobuf.dart';

View File

@ -56,7 +56,7 @@ packages:
name: build name: build
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "2.0.2" version: "2.0.3"
build_config: build_config:
dependency: transitive dependency: transitive
description: description:
@ -77,21 +77,21 @@ packages:
name: build_resolvers name: build_resolvers
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "2.0.3" version: "2.0.4"
build_runner: build_runner:
dependency: "direct dev" dependency: "direct dev"
description: description:
name: build_runner name: build_runner
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "2.0.4" version: "2.0.6"
build_runner_core: build_runner_core:
dependency: transitive dependency: transitive
description: description:
name: build_runner_core name: build_runner_core
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "7.0.0" version: "7.0.1"
built_collection: built_collection:
dependency: transitive dependency: transitive
description: description:
@ -105,7 +105,7 @@ packages:
name: built_value name: built_value
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "8.1.0" version: "8.1.1"
characters: characters:
dependency: transitive dependency: transitive
description: description:
@ -133,7 +133,7 @@ packages:
name: cli_util name: cli_util
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "0.3.0" version: "0.3.3"
clock: clock:
dependency: transitive dependency: transitive
description: description:
@ -161,7 +161,7 @@ packages:
name: convert name: convert
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "3.0.0" version: "3.0.1"
crypto: crypto:
dependency: transitive dependency: transitive
description: description:
@ -182,7 +182,7 @@ packages:
name: dart_style name: dart_style
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "2.0.1" version: "2.0.2"
dartz: dartz:
dependency: transitive dependency: transitive
description: description:
@ -320,7 +320,7 @@ packages:
name: flutter_lints name: flutter_lints
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "1.0.3" version: "1.0.4"
flutter_test: flutter_test:
dependency: "direct dev" dependency: "direct dev"
description: flutter description: flutter
@ -344,7 +344,7 @@ packages:
name: freezed_annotation name: freezed_annotation
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "0.14.2" version: "0.14.3"
frontend_server_client: frontend_server_client:
dependency: transitive dependency: transitive
description: description:
@ -358,7 +358,7 @@ packages:
name: get_it name: get_it
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "7.1.3" version: "7.2.0"
glob: glob:
dependency: transitive dependency: transitive
description: description:
@ -393,7 +393,7 @@ packages:
name: io name: io
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "1.0.0" version: "1.0.3"
isolates: isolates:
dependency: transitive dependency: transitive
description: description:
@ -414,7 +414,7 @@ packages:
name: json_annotation name: json_annotation
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "4.0.1" version: "4.1.0"
lint: lint:
dependency: transitive dependency: transitive
description: description:
@ -456,7 +456,7 @@ packages:
name: meta name: meta
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "1.4.0" version: "1.7.0"
mime: mime:
dependency: transitive dependency: transitive
description: description:
@ -549,7 +549,7 @@ packages:
name: plugin_platform_interface name: plugin_platform_interface
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "2.0.0" version: "2.0.1"
pool: pool:
dependency: transitive dependency: transitive
description: description:
@ -612,7 +612,7 @@ packages:
name: shelf name: shelf
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "1.1.4" version: "1.2.0"
shelf_web_socket: shelf_web_socket:
dependency: transitive dependency: transitive
description: description:
@ -638,7 +638,7 @@ packages:
name: source_gen name: source_gen
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "1.0.2" version: "1.0.3"
source_span: source_span:
dependency: transitive dependency: transitive
description: description:
@ -820,7 +820,7 @@ packages:
name: win32 name: win32
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "2.2.0" version: "2.2.5"
window_size: window_size:
dependency: "direct main" dependency: "direct main"
description: description:

View File

@ -29,7 +29,7 @@ impl<'a> ASTContainer<'a> {
}, },
syn::Data::Enum(data) => { syn::Data::Enum(data) => {
// https://docs.rs/syn/1.0.48/syn/struct.DataEnum.html // https://docs.rs/syn/1.0.48/syn/struct.DataEnum.html
ASTData::Enum(enum_from_ast(cx, &data.variants, &ast.attrs)) ASTData::Enum(enum_from_ast(cx, &ast.ident, &data.variants, &ast.attrs))
}, },
}; };
@ -208,14 +208,14 @@ pub fn struct_from_ast<'a>(cx: &Ctxt, fields: &'a syn::Fields) -> (ASTStyle, Vec
pub fn enum_from_ast<'a>( pub fn enum_from_ast<'a>(
cx: &Ctxt, cx: &Ctxt,
ident: &syn::Ident,
variants: &'a Punctuated<syn::Variant, Token![,]>, variants: &'a Punctuated<syn::Variant, Token![,]>,
enum_attrs: &Vec<syn::Attribute>, enum_attrs: &Vec<syn::Attribute>,
) -> Vec<ASTEnumVariant<'a>> { ) -> Vec<ASTEnumVariant<'a>> {
variants variants
.iter() .iter()
.flat_map(|variant| { .flat_map(|variant| {
let attrs = attr::ASTEnumAttrVariant::from_ast(cx, variant, enum_attrs); let attrs = attr::ASTEnumAttrVariant::from_ast(cx, ident, variant, enum_attrs);
let (style, fields) = struct_from_ast(cx, &variant.fields); let (style, fields) = struct_from_ast(cx, &variant.fields);
Some(ASTEnumVariant { Some(ASTEnumVariant {
ident: variant.ident.clone(), ident: variant.ident.clone(),

View File

@ -266,14 +266,21 @@ pub struct EventAttrs {
#[derive(Debug, Clone)] #[derive(Debug, Clone)]
pub struct ASTEnumAttrVariant { pub struct ASTEnumAttrVariant {
pub name: String, pub enum_name: String,
pub enum_item_name: String,
pub value: String, pub value: String,
pub event_attrs: EventAttrs, pub event_attrs: EventAttrs,
} }
impl ASTEnumAttrVariant { impl ASTEnumAttrVariant {
pub fn from_ast(ctxt: &Ctxt, variant: &syn::Variant, enum_attrs: &Vec<syn::Attribute>) -> Self { pub fn from_ast(
let name = variant.ident.to_string(); ctxt: &Ctxt,
ident: &syn::Ident,
variant: &syn::Variant,
enum_attrs: &Vec<syn::Attribute>,
) -> Self {
let enum_item_name = variant.ident.to_string();
let enum_name = ident.to_string();
let mut value = String::new(); let mut value = String::new();
if variant.discriminant.is_some() { if variant.discriminant.is_some() {
match variant.discriminant.as_ref().unwrap().1 { match variant.discriminant.as_ref().unwrap().1 {
@ -290,7 +297,8 @@ impl ASTEnumAttrVariant {
} }
let event_attrs = get_event_attrs_from(ctxt, &variant.attrs, enum_attrs); let event_attrs = get_event_attrs_from(ctxt, &variant.attrs, enum_attrs);
ASTEnumAttrVariant { ASTEnumAttrVariant {
name, enum_name,
enum_item_name,
value, value,
event_attrs, event_attrs,
} }

View File

@ -11,15 +11,15 @@ pub struct EventASTContext {
impl EventASTContext { impl EventASTContext {
pub fn from(variant: &ASTEnumAttrVariant) -> EventASTContext { pub fn from(variant: &ASTEnumAttrVariant) -> EventASTContext {
let command_name = variant.name.clone(); let command_name = variant.enum_item_name.clone();
if command_name.is_empty() { if command_name.is_empty() {
panic!("Invalid command name: {}", variant.name); panic!("Invalid command name: {}", variant.enum_item_name);
} }
let event = format_ident!("{}", &command_name); let event = format_ident!("{}", &command_name);
let splits = command_name.split("_").collect::<Vec<&str>>(); let splits = command_name.split("_").collect::<Vec<&str>>();
let event_ty = format_ident!("UserEvent"); let event_ty = format_ident!("{}", variant.enum_name);
let event_request_struct = format_ident!("{}Event", &splits.join("")); let event_request_struct = format_ident!("{}Event", &splits.join(""));
let event_input = variant.event_input(); let event_input = variant.event_input();

View File

@ -5,7 +5,7 @@ use flowy_derive::{Flowy_Event, ProtoBuf_Enum};
#[event_err = "WorkspaceError"] #[event_err = "WorkspaceError"]
pub enum WorkspaceEvent { pub enum WorkspaceEvent {
#[display(fmt = "Create workspace")] #[display(fmt = "Create workspace")]
#[event(input = "CreateSpaceRequest", output = "WorkspaceDetail")] #[event(input = "CreateWorkspaceRequest", output = "Workspace")]
CreateWorkspace = 0, CreateWorkspace = 0,
#[display(fmt = "Get user's current workspace")] #[display(fmt = "Get user's current workspace")]

View File

@ -79,8 +79,12 @@ pub fn parse_event_crate(event_crate: &DartEventCrate) -> Vec<EventASTContext> {
.map(|item| match item { .map(|item| match item {
Item::Enum(item_enum) => { Item::Enum(item_enum) => {
let ctxt = Ctxt::new(); let ctxt = Ctxt::new();
let attrs = let attrs = flowy_ast::enum_from_ast(
flowy_ast::enum_from_ast(&ctxt, &item_enum.variants, &item_enum.attrs); &ctxt,
&item_enum.ident,
&item_enum.variants,
&item_enum.attrs,
);
ctxt.check().unwrap(); ctxt.check().unwrap();
attrs attrs
.iter() .iter()

View File

@ -130,14 +130,20 @@ pub fn get_ast_structs(ast: &syn::File) -> Vec<Struct> {
pub fn get_ast_enums(ast: &syn::File) -> Vec<FlowyEnum> { pub fn get_ast_enums(ast: &syn::File) -> Vec<FlowyEnum> {
let mut flowy_enums: Vec<FlowyEnum> = vec![]; let mut flowy_enums: Vec<FlowyEnum> = vec![];
let ctxt = Ctxt::new(); let ctxt = Ctxt::new();
let enum_attrs = &ast.attrs;
ast.items.iter().for_each(|item| { ast.items.iter().for_each(|item| {
// https://docs.rs/syn/1.0.54/syn/enum.Item.html // https://docs.rs/syn/1.0.54/syn/enum.Item.html
match item { match item {
Item::Enum(item_enum) => { Item::Enum(item_enum) => {
let attrs = flowy_ast::enum_from_ast(
&ctxt,
&item_enum.ident,
&item_enum.variants,
&ast.attrs,
);
flowy_enums.push(FlowyEnum { flowy_enums.push(FlowyEnum {
name: item_enum.ident.to_string(), name: item_enum.ident.to_string(),
attrs: flowy_ast::enum_from_ast(&ctxt, &item_enum.variants, enum_attrs), attrs,
}); });
} }
_ => {} _ => {}

View File

@ -19,8 +19,10 @@ impl EnumTemplate {
pub fn set_message_enum(&mut self, flowy_enum: &FlowyEnum) { pub fn set_message_enum(&mut self, flowy_enum: &FlowyEnum) {
self.context.insert("enum_name", &flowy_enum.name); self.context.insert("enum_name", &flowy_enum.name);
flowy_enum.attrs.iter().for_each(|item| { flowy_enum.attrs.iter().for_each(|item| {
self.items self.items.push(format!(
.push(format!("{} = {};", item.attrs.name, item.attrs.value)) "{} = {};",
item.attrs.enum_item_name, item.attrs.value
))
}) })
} }

View File

@ -34,7 +34,7 @@ condition = { platforms = ["mac"] }
dependencies = ["restore-crate-type"] dependencies = ["restore-crate-type"]
script = [ script = [
""" """
echo ${CARGO_MAKE_WORKSPACE_WORKING_DIRECTORY} echo "🚀 🚀 🚀 Copy Flowy-SDK to flutter"
cp ${CARGO_MAKE_WORKSPACE_WORKING_DIRECTORY}/rust-lib/target/x86_64-apple-darwin/${LIB_OUT_DIR}/lib${CARGO_MAKE_CRATE_FS_NAME}.dylib \ cp ${CARGO_MAKE_WORKSPACE_WORKING_DIRECTORY}/rust-lib/target/x86_64-apple-darwin/${LIB_OUT_DIR}/lib${CARGO_MAKE_CRATE_FS_NAME}.dylib \
${CARGO_MAKE_WORKSPACE_WORKING_DIRECTORY}/app_flowy/packages/flowy_sdk/macos/lib${CARGO_MAKE_CRATE_FS_NAME}.dylib ${CARGO_MAKE_WORKSPACE_WORKING_DIRECTORY}/app_flowy/packages/flowy_sdk/macos/lib${CARGO_MAKE_CRATE_FS_NAME}.dylib
""", """,
@ -63,9 +63,8 @@ condition = { platforms = ["mac"] }
script = [ script = [
""" """
target_path = set ${TMPDIR}/appflowy_client/lib${CARGO_MAKE_CRATE_FS_NAME}.dylib target_path = set ${TMPDIR}/appflowy_client/lib${CARGO_MAKE_CRATE_FS_NAME}.dylib
echo "remove old dylib"
rm ${target_path} rm ${target_path}
echo "copy new dylib to system" # echo "🚀 🚀 🚀 Copy Flowy-SDK to system"
cp ${CARGO_MAKE_WORKSPACE_WORKING_DIRECTORY}/rust-lib/target/x86_64-apple-darwin/${LIB_OUT_DIR}/lib${CARGO_MAKE_CRATE_FS_NAME}.dylib ${target_path} cp ${CARGO_MAKE_WORKSPACE_WORKING_DIRECTORY}/rust-lib/target/x86_64-apple-darwin/${LIB_OUT_DIR}/lib${CARGO_MAKE_CRATE_FS_NAME}.dylib ${target_path}
""", """,
] ]