add hover

This commit is contained in:
appflowy 2021-07-27 09:11:53 +08:00
parent 6394ea2dd8
commit 5d520d7217
9 changed files with 100 additions and 16 deletions

View File

@ -9,7 +9,7 @@
"request": "launch",
"program": "${workspaceRoot}/lib/main.dart",
"type": "dart",
"preLaunchTask": "BuildRust",
"preLaunchTask": "build_flowy_sdk",
"cwd": "${workspaceRoot}"
},
{

View File

@ -1,8 +1,6 @@
{
"version": "2.0.0",
"tasks": [
{
// https://code.visualstudio.com/docs/editor/tasks
// https://code.visualstudio.com/docs/editor/tasks
//https://gist.github.com/deadalusai/9e13e36d61ec7fb72148
// ${workspaceRoot}: the root folder of the team
@ -11,7 +9,8 @@
// ${fileDirname}: the current opened file's dirname
// ${fileExtname}: the current opened file's extension
// ${cwd}: the current working directory of the spawned process
"tasks": [
{
"type": "shell",
"command": "sh ./scripts/build_sdk.sh",
"group": "build",
@ -21,7 +20,19 @@
// "problemMatcher": [
// "$rustc"
// ],
"label": "BuildRust"
"label": "build_flowy_sdk"
},
{
"type": "shell",
"command": "sh ./scripts/code_gen.sh",
"group": "build",
"options": {
"cwd": "${workspaceFolder}/../"
},
"problemMatcher": [
"$rustc"
],
"label": "generate events"
}
]
}

View File

@ -76,10 +76,7 @@ class AppWidget extends MenuItem {
hasIcon: false,
),
header: AppHeader(app),
expanded: Padding(
padding: EdgeInsets.only(left: AppWidgetSize.expandedPadding),
child: child,
),
expanded: child,
collapsed: const SizedBox(),
),
],

View File

@ -1,6 +1,7 @@
import 'package:app_flowy/workspace/presentation/view/view_widget.dart';
import 'package:flowy_infra/flowy_logger.dart';
import 'package:flowy_sdk/protobuf/flowy-workspace/view_create.pb.dart';
import 'package:flowy_infra_ui/style_widget/styled_hover.dart';
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:dartz/dartz.dart';
@ -26,11 +27,15 @@ class ViewList extends StatelessWidget {
var targetViews = views.map((view) {
return Padding(
padding: const EdgeInsets.symmetric(vertical: 6),
child: ViewWidget(
view: view,
child: StyledHover(
color: Colors.red,
borderRadius: BorderRadius.circular(8),
child: ViewWidget(
view: view,
),
),
);
}).toList(growable: true);
}).toList(growable: false);
return targetViews;
}

View File

@ -1,6 +1,7 @@
import 'package:app_flowy/startup/startup.dart';
import 'package:app_flowy/workspace/domain/image.dart';
import 'package:app_flowy/workspace/domain/page_stack/page_stack.dart';
import 'package:app_flowy/workspace/presentation/app/app_widget.dart';
import 'package:flowy_infra_ui/widget/spacing.dart';
import 'package:flowy_sdk/protobuf/flowy-workspace/view_create.pb.dart';
import 'package:flutter/material.dart';
@ -11,7 +12,15 @@ class ViewWidget extends StatelessWidget {
@override
Widget build(BuildContext context) {
return InkWell(onTap: _openView(context), child: buildContent());
final contentPadding = EdgeInsets.only(
left: AppWidgetSize.expandedPadding, top: 5, bottom: 5, right: 5);
return InkWell(
onTap: _openView(context),
child: Padding(
padding: contentPadding,
child: buildContent(),
),
);
}
Row buildContent() {

View File

@ -111,6 +111,7 @@ class EditorController extends ChangeNotifier {
Delta? delta;
if (length > 0 || data is! String || data.isNotEmpty) {
delta = document.replace(index, length, data);
print(delta);
var shouldRetainDelta = toggledStyle.isNotEmpty &&
delta.isNotEmpty &&
delta.length <= 2 &&

View File

@ -0,0 +1,59 @@
import 'package:flowy_infra_ui/widget/mouse_hover_builder.dart';
import 'package:flutter/material.dart';
import 'package:flowy_infra/time/duration.dart';
class StyledHover extends StatelessWidget {
final Color color;
final Color borderColor;
final double borderWidth;
final Widget child;
final BorderRadius borderRadius;
const StyledHover({
Key? key,
required this.color,
required this.child,
this.borderColor = Colors.transparent,
this.borderWidth = 0,
this.borderRadius = BorderRadius.zero,
}) : super(key: key);
@override
Widget build(BuildContext context) {
return MouseHoverBuilder(
builder: (_, isHovered) => AnimatedContainer(
decoration: BoxDecoration(
border: Border.all(color: borderColor, width: borderWidth),
color: isHovered ? color : Colors.transparent,
borderRadius: borderRadius,
),
duration: .1.seconds,
child: child,
),
);
}
}
// @override
// Widget build(BuildContext context) {
// return GestureDetector(
// behavior: HitTestBehavior.translucent,
// onTap: () {
// context
// .read<HomeBloc>()
// .add(HomeEvent.setEditPannel(CellEditPannelContext()));
// },
// child: MouseHoverBuilder(
// builder: (_, isHovered) => Container(
// width: width,
// decoration: CellDecoration.box(
// color: isHovered ? Colors.red.withOpacity(.1) : Colors.transparent,
// ),
// padding: EdgeInsets.symmetric(
// vertical: GridInsets.vertical, horizontal: GridInsets.horizontal),
// child: child,
// ),
// ),
// );
// }

View File

@ -12,5 +12,4 @@ rustup show
# 2. ~/.bashrc
# 3. ~/.profile
# 4. ~/.zshrc
cargo make desktop
cargo make desktop

3
scripts/code_gen.sh Executable file
View File

@ -0,0 +1,3 @@
#!/bin/sh
#!/usr/bin/env fish
cargo make gen_dart_event