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>
<string>1.0</string>
<key>MinimumOSVersion</key>
<string>8.0</string>
<string>9.0</string>
</dict>
</plist>

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -26,8 +26,10 @@ class _$MenuEventTearOff {
);
}
_CreateApp createApp() {
return const _CreateApp();
_CreateApp createApp(String appName) {
return _CreateApp(
appName,
);
}
}
@ -40,14 +42,14 @@ mixin _$MenuEvent {
TResult when<TResult extends Object?>({
required TResult Function() collapse,
required TResult Function(PageContext context) openPage,
required TResult Function() createApp,
required TResult Function(String appName) createApp,
}) =>
throw _privateConstructorUsedError;
@optionalTypeArgs
TResult maybeWhen<TResult extends Object?>({
TResult Function()? collapse,
TResult Function(PageContext context)? openPage,
TResult Function()? createApp,
TResult Function(String appName)? createApp,
required TResult orElse(),
}) =>
throw _privateConstructorUsedError;
@ -122,7 +124,7 @@ class _$Collapse implements Collapse {
TResult when<TResult extends Object?>({
required TResult Function() collapse,
required TResult Function(PageContext context) openPage,
required TResult Function() createApp,
required TResult Function(String appName) createApp,
}) {
return collapse();
}
@ -132,7 +134,7 @@ class _$Collapse implements Collapse {
TResult maybeWhen<TResult extends Object?>({
TResult Function()? collapse,
TResult Function(PageContext context)? openPage,
TResult Function()? createApp,
TResult Function(String appName)? createApp,
required TResult orElse(),
}) {
if (collapse != null) {
@ -234,7 +236,7 @@ class _$_OpenPage implements _OpenPage {
TResult when<TResult extends Object?>({
required TResult Function() collapse,
required TResult Function(PageContext context) openPage,
required TResult Function() createApp,
required TResult Function(String appName) createApp,
}) {
return openPage(context);
}
@ -244,7 +246,7 @@ class _$_OpenPage implements _OpenPage {
TResult maybeWhen<TResult extends Object?>({
TResult Function()? collapse,
TResult Function(PageContext context)? openPage,
TResult Function()? createApp,
TResult Function(String appName)? createApp,
required TResult orElse(),
}) {
if (openPage != null) {
@ -292,6 +294,7 @@ abstract class _$CreateAppCopyWith<$Res> {
factory _$CreateAppCopyWith(
_CreateApp value, $Res Function(_CreateApp) then) =
__$CreateAppCopyWithImpl<$Res>;
$Res call({String appName});
}
/// @nodoc
@ -302,34 +305,58 @@ class __$CreateAppCopyWithImpl<$Res> extends _$MenuEventCopyWithImpl<$Res>
@override
_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
class _$_CreateApp implements _CreateApp {
const _$_CreateApp();
const _$_CreateApp(this.appName);
@override
final String appName;
@override
String toString() {
return 'MenuEvent.createApp()';
return 'MenuEvent.createApp(appName: $appName)';
}
@override
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
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
@optionalTypeArgs
TResult when<TResult extends Object?>({
required TResult Function() collapse,
required TResult Function(PageContext context) openPage,
required TResult Function() createApp,
required TResult Function(String appName) createApp,
}) {
return createApp();
return createApp(appName);
}
@override
@ -337,11 +364,11 @@ class _$_CreateApp implements _CreateApp {
TResult maybeWhen<TResult extends Object?>({
TResult Function()? collapse,
TResult Function(PageContext context)? openPage,
TResult Function()? createApp,
TResult Function(String appName)? createApp,
required TResult orElse(),
}) {
if (createApp != null) {
return createApp();
return createApp(appName);
}
return orElse();
}
@ -372,7 +399,12 @@ class _$_CreateApp implements _CreateApp {
}
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

View File

@ -4,5 +4,5 @@ part of 'menu_bloc.dart';
abstract class MenuEvent with _$MenuEvent {
const factory MenuEvent.collapse() = Collapse;
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 Duration animDuration;
HomeLayout(BuildContext context, BoxConstraints homeScreenConstraint) {
HomeLayout(BuildContext context, BoxConstraints homeScreenConstraint,
bool forceCollapse) {
final homeBlocState = context.read<HomeBloc>().state;
showEditPannel = homeBlocState.editContext.isSome();
@ -27,12 +28,11 @@ class HomeLayout {
menuWidth = Sizes.sideBarLg;
}
// if (menuBlocState.isCollapse) {
// showMenu = false;
// } else {
// showMenu = context.widthPx > PageBreaks.TabletPortrait;
// }
showMenu = context.widthPx > PageBreaks.tabletPortrait;
if (forceCollapse) {
showMenu = false;
} else {
showMenu = context.widthPx > PageBreaks.tabletPortrait;
}
homePageLOffset = showMenu ? menuWidth : 0.0;
animDuration = .35.seconds;

View File

@ -29,10 +29,12 @@ class HomeScreen extends StatelessWidget {
child: Scaffold(
key: HomeScreen.scaffoldKey,
body: BlocBuilder<HomeBloc, HomeState>(
buildWhen: (previous, current) => previous != current,
builder: (context, state) {
return StyledContainer(
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(
builder: (BuildContext context, BoxConstraints constraints) {
final layout = HomeLayout(context, constraints);
final layout = HomeLayout(context, constraints, forceCollapse);
const homePage = HomePage();
final menu = _buildHomeMenu(
layout: layout,
@ -76,7 +78,7 @@ class HomeScreen extends StatelessWidget {
);
},
isCollapseChanged: (isCollapse) {
homeBloc.add(HomeEvent.showMenu(!isCollapse));
homeBloc.add(HomeEvent.forceCollapse(isCollapse));
},
);
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/domain/page_context.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: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_bloc/flutter_bloc.dart';
import '../../home_sizes.dart';
import 'package:styled_widget/styled_widget.dart';
import 'package:textstyle_extensions/textstyle_extensions.dart';
class HomeMenu extends StatelessWidget {
final Function(Option<PageContext>) pageContextChanged;
@ -20,41 +28,41 @@ class HomeMenu extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MultiBlocProvider(
providers: [
BlocProvider<MenuBloc>(create: (context) => getIt<MenuBloc>()),
],
child: MultiBlocListener(
listeners: bind(),
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(),
],
),
),
return BlocProvider(
create: (context) => getIt<MenuBloc>(),
child: MultiBlocListener(
listeners: [
BlocListener<MenuBloc, MenuState>(
listenWhen: (p, c) => p.pageContext != c.pageContext,
listener: (context, state) => pageContextChanged(state.pageContext),
),
));
BlocListener<MenuBloc, MenuState>(
listenWhen: (p, c) => p.isCollapse != c.isCollapse,
listener: (context, state) => isCollapseChanged(state.isCollapse),
)
],
child: BlocBuilder<MenuBloc, MenuState>(
builder: (context, state) => _renderBody(context),
),
),
);
}
// bind the function passed by ooutter with the bloc listener
List<BlocListener<MenuBloc, MenuState>> bind() {
return [
BlocListener<MenuBloc, MenuState>(
listenWhen: (p, c) => p.pageContext != c.pageContext,
listener: (context, state) => pageContextChanged(state.pageContext),
),
BlocListener<MenuBloc, MenuState>(
listenWhen: (p, c) => p.isCollapse != c.isCollapse,
listener: (context, state) => isCollapseChanged(state.isCollapse),
)
];
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 {
const NewAppButton({Key? key}) : super(key: key);
final Function(String)? createAppCallback;
const NewAppButton({this.createAppCallback, Key? key}) : super(key: key);
@override
Widget build(BuildContext context) {
return SizedBox(
@ -100,22 +110,82 @@ class NewAppButton extends StatelessWidget {
width: 10,
),
TextButton(
onPressed: () async {
// Dialogs.show(OkCancelDialog(
// 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)),
onPressed: () async => await _showCreateAppDialog(context),
child: _buttonTitle(),
)
],
),
);
}
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
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 {
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/protobuf/flowy-user/protobuf.dart';
import 'package:flowy_sdk/protobuf/dart-ffi/protobuf.dart';
import 'package:flowy_sdk/protobuf/flowy-workspace/protobuf.dart';
// ignore: unused_import
import 'package:flowy_sdk/protobuf/flowy-infra/protobuf.dart';
import 'package:protobuf/protobuf.dart';

View File

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

View File

@ -29,7 +29,7 @@ impl<'a> ASTContainer<'a> {
},
syn::Data::Enum(data) => {
// 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>(
cx: &Ctxt,
ident: &syn::Ident,
variants: &'a Punctuated<syn::Variant, Token![,]>,
enum_attrs: &Vec<syn::Attribute>,
) -> Vec<ASTEnumVariant<'a>> {
variants
.iter()
.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);
Some(ASTEnumVariant {
ident: variant.ident.clone(),

View File

@ -266,14 +266,21 @@ pub struct EventAttrs {
#[derive(Debug, Clone)]
pub struct ASTEnumAttrVariant {
pub name: String,
pub enum_name: String,
pub enum_item_name: String,
pub value: String,
pub event_attrs: EventAttrs,
}
impl ASTEnumAttrVariant {
pub fn from_ast(ctxt: &Ctxt, variant: &syn::Variant, enum_attrs: &Vec<syn::Attribute>) -> Self {
let name = variant.ident.to_string();
pub fn from_ast(
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();
if variant.discriminant.is_some() {
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);
ASTEnumAttrVariant {
name,
enum_name,
enum_item_name,
value,
event_attrs,
}

View File

@ -11,15 +11,15 @@ pub struct EventASTContext {
impl 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() {
panic!("Invalid command name: {}", variant.name);
panic!("Invalid command name: {}", variant.enum_item_name);
}
let event = format_ident!("{}", &command_name);
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_input = variant.event_input();

View File

@ -5,7 +5,7 @@ use flowy_derive::{Flowy_Event, ProtoBuf_Enum};
#[event_err = "WorkspaceError"]
pub enum WorkspaceEvent {
#[display(fmt = "Create workspace")]
#[event(input = "CreateSpaceRequest", output = "WorkspaceDetail")]
#[event(input = "CreateWorkspaceRequest", output = "Workspace")]
CreateWorkspace = 0,
#[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 {
Item::Enum(item_enum) => {
let ctxt = Ctxt::new();
let attrs =
flowy_ast::enum_from_ast(&ctxt, &item_enum.variants, &item_enum.attrs);
let attrs = flowy_ast::enum_from_ast(
&ctxt,
&item_enum.ident,
&item_enum.variants,
&item_enum.attrs,
);
ctxt.check().unwrap();
attrs
.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> {
let mut flowy_enums: Vec<FlowyEnum> = vec![];
let ctxt = Ctxt::new();
let enum_attrs = &ast.attrs;
ast.items.iter().for_each(|item| {
// https://docs.rs/syn/1.0.54/syn/enum.Item.html
match item {
Item::Enum(item_enum) => {
let attrs = flowy_ast::enum_from_ast(
&ctxt,
&item_enum.ident,
&item_enum.variants,
&ast.attrs,
);
flowy_enums.push(FlowyEnum {
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) {
self.context.insert("enum_name", &flowy_enum.name);
flowy_enum.attrs.iter().for_each(|item| {
self.items
.push(format!("{} = {};", item.attrs.name, item.attrs.value))
self.items.push(format!(
"{} = {};",
item.attrs.enum_item_name, item.attrs.value
))
})
}

View File

@ -34,7 +34,7 @@ condition = { platforms = ["mac"] }
dependencies = ["restore-crate-type"]
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 \
${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 = [
"""
target_path = set ${TMPDIR}/appflowy_client/lib${CARGO_MAKE_CRATE_FS_NAME}.dylib
echo "remove old dylib"
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}
""",
]