Skip to content

Commit

Permalink
fix bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
denny.deng committed Nov 16, 2020
1 parent 6e45674 commit fcdfa53
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 30 deletions.
71 changes: 41 additions & 30 deletions example/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ import 'package:dynamic_widget/dynamic_widget/drop_cap_text.dart';
import 'package:dynamic_widget/dynamic_widget/scrolling/gridview_widget_parser.dart';
import 'package:dynamic_widget/dynamic_widget/scrolling/listview_widget_parser.dart';
import 'package:flutter/material.dart';
import 'package:flutter/rendering.dart';
import 'package:flutter/widgets.dart';

void main() => runApp(MyApp());

Expand Down Expand Up @@ -479,11 +481,7 @@ class _JSONExporterState extends State<JSONExporter> {

@override
Widget build(BuildContext context) {
ListViewParams params = ListViewParams();
params.padding = EdgeInsets.all(10.0);
params.children = [
DropCapText(selectable: true, data: "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ac turpis egestas maecenas pharetra convallis posuere morbi leo. Fermentum odio eu feugiat pretium. Lacinia quis vel eros donec ac. At elementum eu facilisis sed odio morbi quis commodo odio. Augue lacus viverra vitae congue eu consequat ac felis. Blandit aliquam etiam erat velit. Morbi tincidunt augue interdum velit euismod. Sed libero enim sed faucibus turpis. Sagittis eu volutpat odio facilisis. Ultricies mi eget mauris pharetra et ultrices neque. Urna cursus eget nunc scelerisque viverra. Orci phasellus egestas tellus rutrum tellus. Et magnis dis parturient montes nascetur ridiculus mus. Arcu cursus vitae congue mauris rhoncus aenean. Varius morbi enim nunc faucibus. Semper eget duis at tellus at urna condimentum mattis. Massa sapien faucibus et molestie ac feugiat sed. Convallis aenean et tortor at risus. Massa ultricies mi quis hendrerit dolor magna eget est lorem. Vulputate odio ut enim blandit. Velit ut tortor pretium viverra suspendisse. Lacus laoreet non curabitur gravida arcu ac tortor dignissim convallis. Egestas egestas fringilla phasellus faucibus scelerisque eleifend donec pretium. Vitae tempus quam pellentesque nec nam aliquam sem et tortor. Tincidunt ornare massa eget egestas purus viverra accumsan in. Non consectetur a erat nam at lectus urna duis convallis. Et magnis dis parturient montes nascetur ridiculus mus mauris. Elit eget gravida cum sociis natoque. Sit amet consectetur adipiscing elit ut aliquam purus sit amet. Fringilla urna porttitor rhoncus dolor purus non. Dui accumsan sit amet nulla facilisi morbi tempus. Tellus in hac habitasse platea dictumst vestibulum. Ultricies integer quis auctor elit sed vulputate mi sit amet.", style: TextStyle(fontSize: 18.1),)
];

return Scaffold(
appBar: AppBar(
// Here we take the value from the MyHomePage object that was created by
Expand All @@ -492,33 +490,46 @@ class _JSONExporterState extends State<JSONExporter> {
),

body: Builder(
builder: (context) => Column(
children: [
Expanded(
child: DynamicWidgetJsonExportor(
key: key,
child: ListViewWidget(
params, context
builder: (context) => Container(
width: double.infinity,
child: Column(
children: [
Expanded(
child: DynamicWidgetJsonExportor(
key: key,
child: Stack(
alignment: Alignment.topLeft,
children: [
Image.asset("assets/vip.png"),
Positioned(
child: Image.asset("assets/vip.png"),
top:50,
left: 50,
)
],
),
),
),
),
RaisedButton(
child: Text("Export"),
onPressed: () {
var exportor = key.currentWidget as DynamicWidgetJsonExportor;
var exportJsonString = exportor.exportJsonString();
Scaffold.of(context).showSnackBar(SnackBar(
content: Text("json string was exported to editor page.")));
Future.delayed(Duration(seconds: 3), (){
Navigator.push(
context,
MaterialPageRoute(
builder: (context) =>
CodeEditorPage(exportJsonString)));
});
},
)
],
Container(
child: RaisedButton(
child: Text("Export"),
onPressed: () {
var exportor = key.currentWidget as DynamicWidgetJsonExportor;
var exportJsonString = exportor.exportJsonString();
Scaffold.of(context).showSnackBar(SnackBar(
content: Text("json string was exported to editor page.")));
Future.delayed(Duration(seconds: 1), (){
Navigator.push(
context,
MaterialPageRoute(
builder: (context) =>
CodeEditorPage(exportJsonString)));
});
},
),
)
],
),
),
),
);
Expand Down
1 change: 1 addition & 0 deletions lib/dynamic_widget/basic/image_widget_parser.dart
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ class AssetImageWidgetParser extends WidgetParser {

}
return <String, dynamic>{
"type": widgetName,
"name": assetImage.assetName,
"semanticLabel": realWidget.semanticLabel,
"width": realWidget.width,
Expand Down
3 changes: 3 additions & 0 deletions lib/dynamic_widget/utils.dart
Original file line number Diff line number Diff line change
Expand Up @@ -719,6 +719,9 @@ String exportImageRepeat(ImageRepeat imageRepeat){
}

Rect parseRect(String fromLTRBString) {
if (fromLTRBString == null) {
return null;
}
var strings = fromLTRBString.split(',');
return Rect.fromLTRB(double.parse(strings[0]), double.parse(strings[1]),
double.parse(strings[2]), double.parse(strings[3]));
Expand Down

0 comments on commit fcdfa53

Please sign in to comment.