load svg asset

This commit is contained in:
appflowy 2021-08-14 15:45:00 +08:00
parent 07268291d1
commit b03dcde824
6 changed files with 55 additions and 6 deletions

View File

@ -0,0 +1,4 @@
<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M9 2.5V6C9 6.55228 9.44772 7 10 7H12" stroke="#333333"/>
<path d="M3.5 3.5C3.5 2.94771 3.94772 2.5 4.5 2.5H8H8.5C9.12951 2.5 9.72229 2.79639 10.1 3.3L12.1 5.96667C12.3596 6.31286 12.5 6.73393 12.5 7.16667V8V12.5C12.5 13.0523 12.0523 13.5 11.5 13.5H4.5C3.94772 13.5 3.5 13.0523 3.5 12.5V3.5Z" stroke="#333333"/>
</svg>

After

Width:  |  Height:  |  Size: 423 B

View File

@ -1,16 +1,27 @@
import 'package:flowy_sdk/protobuf/flowy-workspace/view_create.pb.dart';
import 'package:flutter/material.dart';
import 'package:flutter_svg/flutter_svg.dart';
AssetImage assetImageForViewType(ViewType type) {
final imageName = imageNameForViewType(type);
return AssetImage('assets/images/$imageName');
}
Widget svgImageForViewType(ViewType type) {
final imageName = imageNameForViewType(type);
final Widget svg = SvgPicture.asset(
'assets/images/$imageName',
);
return svg;
}
String imageNameForViewType(ViewType type) {
switch (type) {
case ViewType.Doc:
return "file_icon.jpg";
return "file_icon.svg";
default:
return "file_icon.jpg";
return "file_icon.svg";
}
}

View File

@ -44,11 +44,10 @@ class ViewPage extends StatelessWidget {
BuildContext context, bool onHover, HoverDisplayConfig config) {
const double width = 22;
List<Widget> children = [
Image(
fit: BoxFit.cover,
SizedBox(
width: width,
height: width,
image: assetImageForViewType(viewCtx.view.viewType)),
child: svgImageForViewType(viewCtx.view.viewType)),
const HSpace(6),
Text(
viewCtx.view.name,

View File

@ -111,7 +111,6 @@ 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

@ -321,6 +321,13 @@ packages:
url: "https://pub.dartlang.org"
source: hosted
version: "1.0.4"
flutter_svg:
dependency: "direct main"
description:
name: flutter_svg
url: "https://pub.dartlang.org"
source: hosted
version: "0.22.0"
flutter_test:
dependency: "direct dev"
description: flutter
@ -492,6 +499,20 @@ packages:
url: "https://pub.dartlang.org"
source: hosted
version: "1.8.0"
path_drawing:
dependency: transitive
description:
name: path_drawing
url: "https://pub.dartlang.org"
source: hosted
version: "0.5.1"
path_parsing:
dependency: transitive
description:
name: path_parsing
url: "https://pub.dartlang.org"
source: hosted
version: "0.2.1"
path_provider:
dependency: "direct main"
description:
@ -534,6 +555,13 @@ packages:
url: "https://pub.dartlang.org"
source: hosted
version: "1.11.1"
petitparser:
dependency: transitive
description:
name: petitparser
url: "https://pub.dartlang.org"
source: hosted
version: "4.2.0"
photo_view:
dependency: transitive
description:
@ -844,6 +872,13 @@ packages:
url: "https://pub.dartlang.org"
source: hosted
version: "0.2.0"
xml:
dependency: transitive
description:
name: xml
url: "https://pub.dartlang.org"
source: hosted
version: "5.1.2"
yaml:
dependency: transitive
description:

View File

@ -53,6 +53,7 @@ dependencies:
sized_context: ^1.0.0+1
styled_widget: '>=0.3.1'
expandable: ^5.0.1
flutter_svg: ^0.22.0
# The following adds the Cupertino Icons font to your application.