mirror of
https://github.com/alibaba/flutter-go.git
synced 2025-07-15 03:04:25 +08:00
build: code format
This commit is contained in:
@ -10,16 +10,17 @@ class Api{
|
||||
|
||||
static const String GET_USER_INFO = BASE_URL + 'getUserInfo'; //获取用户信息
|
||||
|
||||
|
||||
static const String VERSION = BASE_URL + 'getAppVersion'; //检查版本
|
||||
|
||||
static const String FEEDBACK = BASE_URL + 'auth/feedback'; //建议反馈
|
||||
|
||||
// static const String LOTOUT = BASE_URL+'logout';//退出登陆
|
||||
|
||||
static const String GET_ALL_COLLECTION = BASE_URL+'auth/getAllUserCollection';//获取全部收藏
|
||||
static const String GET_ALL_COLLECTION =
|
||||
BASE_URL + 'auth/getAllUserCollection'; //获取全部收藏
|
||||
|
||||
static const String REMOVE_COLLECTION = BASE_URL+'auth/removeCollection';//移除收藏
|
||||
static const String REMOVE_COLLECTION =
|
||||
BASE_URL + 'auth/removeCollection'; //移除收藏
|
||||
|
||||
static const String ADD_COLLECTION = BASE_URL + 'auth/addCollection'; //添加收藏
|
||||
|
||||
@ -33,4 +34,3 @@ class Api{
|
||||
|
||||
static const String SEARCH_WIDGET = BASE_URL + 'searchWidget'; //搜索组件
|
||||
}
|
||||
|
||||
|
@ -12,6 +12,7 @@ import 'package:html/parser.dart' show parse;
|
||||
import './search_result.dart';
|
||||
|
||||
var dio = new Dio();
|
||||
|
||||
//class Api2 {
|
||||
// /// 关键字提示(起点)
|
||||
// Future<List<String>> suggestion(String query) async {
|
||||
@ -42,9 +43,11 @@ class Api {
|
||||
// http.Response response = await http.get(
|
||||
// "https://www.qidian.com/ajax/Search/AutoComplete?siteid=1&query=$query");
|
||||
/// var response = await dio.get("https://www.qidian.com/ajax/Search/AutoComplete?siteid=1&query=$query", data: {});
|
||||
var response = await dio.get("https://www.so.com/s?ie=utf-8&q=$query flutter");
|
||||
var response =
|
||||
await dio.get("https://www.so.com/s?ie=utf-8&q=$query flutter");
|
||||
var document = parse(response.data);
|
||||
var app = document.querySelectorAll('.res-title a');
|
||||
|
||||
///print('1=====>${query}');
|
||||
///print('2=====>${response.data}');
|
||||
////print('3=====>${app}');
|
||||
|
@ -8,6 +8,7 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import './industry_bloc.dart';
|
||||
|
||||
/// import './industry_event.dart';
|
||||
import './industry_state.dart';
|
||||
|
||||
@ -46,9 +47,7 @@ class _IndustryState extends State<IndustryPage> {
|
||||
}
|
||||
}
|
||||
}
|
||||
return Center(
|
||||
child: Text('没有适合的结果,更换查询条件试试')
|
||||
);
|
||||
return Center(child: Text('没有适合的结果,更换查询条件试试'));
|
||||
}
|
||||
|
||||
@override
|
||||
|
@ -21,8 +21,6 @@ class _CateCardState extends State<CateCard> {
|
||||
_firstChildList = widget.category.children;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
double screenWidth = MediaQuery.of(context).size.width;
|
||||
@ -101,13 +99,10 @@ class _CateCardState extends State<CateCard> {
|
||||
decoration: BoxDecoration(
|
||||
image: DecorationImage(
|
||||
image: AssetImage('assets/images/paimaiLogo.png'),
|
||||
alignment: Alignment.bottomRight
|
||||
),
|
||||
alignment: Alignment.bottomRight),
|
||||
),
|
||||
child: WidgetItemContainer(
|
||||
commonItems: this._firstChildList,
|
||||
columnCount: 3
|
||||
),
|
||||
commonItems: this._firstChildList, columnCount: 3),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -3,18 +3,16 @@ import 'dart:async';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../routers/application.dart';
|
||||
|
||||
/// import '../model/cat.dart';
|
||||
import '../model/widget.dart';
|
||||
import '../widgets/index.dart';
|
||||
import '../components/widget_item_container.dart';
|
||||
|
||||
|
||||
|
||||
class CategoryHome extends StatefulWidget {
|
||||
CategoryHome(this.token);
|
||||
final String token;
|
||||
|
||||
|
||||
@override
|
||||
_CategoryHome createState() => new _CategoryHome();
|
||||
}
|
||||
@ -26,7 +24,6 @@ class _CategoryHome extends State<CategoryHome> {
|
||||
List<Object> widgetPoints = [];
|
||||
List<CommonItem> catHistory = new List();
|
||||
|
||||
|
||||
// 所有的可用demos;
|
||||
List widgetDemosList = new WidgetDemoList().getDemos();
|
||||
|
||||
@ -39,17 +36,13 @@ class _CategoryHome extends State<CategoryHome> {
|
||||
CommonItem targetGroup = Application.widgetTree.find(widget.token) ?? [];
|
||||
print("targetGroup::: $targetGroup");
|
||||
|
||||
catHistory.add(
|
||||
targetGroup
|
||||
);
|
||||
catHistory.add(targetGroup);
|
||||
this.setState(() {
|
||||
items = targetGroup.children;
|
||||
});
|
||||
searchCatOrWidget();
|
||||
}
|
||||
|
||||
|
||||
|
||||
Future<bool> back() {
|
||||
// if (catHistory.length == 1) {
|
||||
// return Future<bool>.value(true);
|
||||
@ -69,7 +62,6 @@ class _CategoryHome extends State<CategoryHome> {
|
||||
// 假设进入这个界面的parent一定存在
|
||||
CommonItem targetGroup = catHistory.last;
|
||||
|
||||
|
||||
this.setState(() {
|
||||
title = targetGroup.name;
|
||||
});
|
||||
@ -79,14 +71,9 @@ class _CategoryHome extends State<CategoryHome> {
|
||||
go(cat);
|
||||
}
|
||||
|
||||
|
||||
|
||||
Widget _buildContent() {
|
||||
WidgetItemContainer wiContaienr = WidgetItemContainer(
|
||||
columnCount: 3,
|
||||
commonItems: items
|
||||
);
|
||||
|
||||
WidgetItemContainer wiContaienr =
|
||||
WidgetItemContainer(columnCount: 3, commonItems: items);
|
||||
|
||||
return Container(
|
||||
padding: const EdgeInsets.only(bottom: 10.0, top: 5.0),
|
||||
@ -102,14 +89,11 @@ class _CategoryHome extends State<CategoryHome> {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
|
||||
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
title: Text("$title"),
|
||||
),
|
||||
body: WillPopScope(
|
||||
|
||||
onWillPop: () {
|
||||
return back();
|
||||
},
|
||||
@ -124,4 +108,3 @@ class _CategoryHome extends State<CategoryHome> {
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -22,7 +22,6 @@ class DisclaimerMsg extends StatefulWidget {
|
||||
DisclaimerMsgState createState() => DisclaimerMsgState();
|
||||
}
|
||||
|
||||
|
||||
class DisclaimerMsgState extends State<DisclaimerMsg> {
|
||||
Future<SharedPreferences> _prefs = SharedPreferences.getInstance();
|
||||
Future<bool> _unKnow;
|
||||
@ -70,8 +69,6 @@ class DisclaimerMsgState extends State<DisclaimerMsg> {
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
|
||||
Widget build(BuildContext context) {
|
||||
return GestureDetector(
|
||||
onTap: () {
|
||||
@ -102,14 +99,11 @@ class DisclaimerMsgState extends State<DisclaimerMsg> {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
class DisclaimerMsgDialog extends StatefulWidget {
|
||||
|
||||
final bool valBool;
|
||||
final bool readed;
|
||||
final ValueChanged<bool> onValueChanged;
|
||||
|
||||
|
||||
DisclaimerMsgDialog(this.valBool, this.readed, this.onValueChanged);
|
||||
|
||||
@override
|
||||
@ -117,18 +111,14 @@ class DisclaimerMsgDialog extends StatefulWidget {
|
||||
}
|
||||
|
||||
class _DisclaimerMsgDialogState extends State<DisclaimerMsgDialog> {
|
||||
|
||||
bool readBool;
|
||||
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
readBool = widget.valBool;
|
||||
}
|
||||
|
||||
|
||||
|
||||
Row _create() {
|
||||
//已读
|
||||
if (widget.readed) {
|
||||
@ -140,9 +130,7 @@ class _DisclaimerMsgDialogState extends State<DisclaimerMsgDialog> {
|
||||
child: Text('已阅读知晓',
|
||||
style: TextStyle(fontSize: 16, color: Colors.white)),
|
||||
//可点击
|
||||
color: Theme
|
||||
.of(context)
|
||||
.primaryColor,
|
||||
color: Theme.of(context).primaryColor,
|
||||
onPressed: () {
|
||||
Navigator.of(context).pop();
|
||||
},
|
||||
@ -175,9 +163,7 @@ class _DisclaimerMsgDialogState extends State<DisclaimerMsgDialog> {
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: <Widget>[
|
||||
Checkbox(
|
||||
activeColor: Theme
|
||||
.of(context)
|
||||
.primaryColor,
|
||||
activeColor: Theme.of(context).primaryColor,
|
||||
tristate: false,
|
||||
value: readBool,
|
||||
onChanged: (bool bol) {
|
||||
@ -192,13 +178,8 @@ class _DisclaimerMsgDialogState extends State<DisclaimerMsgDialog> {
|
||||
style: TextStyle(fontSize: 16, color: Colors.white)),
|
||||
//可点击
|
||||
color: readBool
|
||||
? Theme
|
||||
.of(context)
|
||||
.primaryColor
|
||||
: Theme
|
||||
.of(context)
|
||||
.primaryColor
|
||||
.withAlpha(800),
|
||||
? Theme.of(context).primaryColor
|
||||
: Theme.of(context).primaryColor.withAlpha(800),
|
||||
onPressed: () {
|
||||
widget.onValueChanged(readBool);
|
||||
Navigator.of(context).pop();
|
||||
@ -247,4 +228,5 @@ class _DisclaimerMsgDialogState extends State<DisclaimerMsgDialog> {
|
||||
)
|
||||
],
|
||||
);
|
||||
}}
|
||||
}
|
||||
}
|
||||
|
@ -85,12 +85,8 @@ abstract class MarkdownBuilderDelegate {
|
||||
/// * [Markdown], which is a widget that parses and displays Markdown.
|
||||
class MarkdownBuilder implements md.NodeVisitor {
|
||||
/// Creates an object that builds a [Widget] tree from parsed Markdown.
|
||||
MarkdownBuilder({
|
||||
this.delegate,
|
||||
this.styleSheet,
|
||||
this.imageDirectory,
|
||||
this.demoParser
|
||||
});
|
||||
MarkdownBuilder(
|
||||
{this.delegate, this.styleSheet, this.imageDirectory, this.demoParser});
|
||||
|
||||
/// A delegate that controls how link and `pre` elements behave.
|
||||
final MarkdownBuilderDelegate delegate;
|
||||
@ -99,6 +95,7 @@ class MarkdownBuilder implements md.NodeVisitor {
|
||||
final MarkdownStyleSheet styleSheet;
|
||||
|
||||
final DemoBuilder demoParser;
|
||||
|
||||
/// The base directory holding images referenced by Img tags with local file paths.
|
||||
final Directory imageDirectory;
|
||||
|
||||
@ -107,7 +104,6 @@ class MarkdownBuilder implements md.NodeVisitor {
|
||||
final List<_InlineElement> _inlines = <_InlineElement>[];
|
||||
final List<GestureRecognizer> _linkHandlers = <GestureRecognizer>[];
|
||||
|
||||
|
||||
/// Returns widgets that display the given Markdown nodes.
|
||||
///
|
||||
/// The returned widgets are typically used as children in a [ListView].
|
||||
@ -155,8 +151,7 @@ class MarkdownBuilder implements md.NodeVisitor {
|
||||
final String tag = element.tag;
|
||||
if (_isBlockTag(tag)) {
|
||||
_addAnonymousBlockIfNeeded(styleSheet.styles[tag]);
|
||||
if (_isListTag(tag))
|
||||
_listIndents.add(tag);
|
||||
if (_isListTag(tag)) _listIndents.add(tag);
|
||||
_blocks.add(new _BlockElement(tag));
|
||||
} else {
|
||||
_addParentInlineIfNeeded(_blocks.last.tag);
|
||||
@ -232,7 +227,6 @@ class MarkdownBuilder implements md.NodeVisitor {
|
||||
}
|
||||
_addBlockChild(child);
|
||||
} else {
|
||||
|
||||
final _InlineElement current = _inlines.removeLast();
|
||||
final _InlineElement parent = _inlines.last;
|
||||
|
||||
@ -245,12 +239,12 @@ class MarkdownBuilder implements md.NodeVisitor {
|
||||
current.children.add(_buildGoDemos(element.attributes));
|
||||
}
|
||||
|
||||
|
||||
if (current.children.isNotEmpty) {
|
||||
parent.children.addAll(current.children);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Widget _buildGoDemos(Map<String, dynamic> attrs) {
|
||||
Widget targetGoDemos;
|
||||
|
||||
@ -263,8 +257,7 @@ class MarkdownBuilder implements md.NodeVisitor {
|
||||
|
||||
Widget _buildImage(String src) {
|
||||
final List<String> parts = src.split('#');
|
||||
if (parts.isEmpty)
|
||||
return const SizedBox();
|
||||
if (parts.isEmpty) return const SizedBox();
|
||||
|
||||
final String path = parts.first;
|
||||
double width;
|
||||
@ -300,10 +293,12 @@ class MarkdownBuilder implements md.NodeVisitor {
|
||||
}
|
||||
}
|
||||
|
||||
Widget _handleDataSchemeUri(Uri uri, final double width, final double height) {
|
||||
Widget _handleDataSchemeUri(
|
||||
Uri uri, final double width, final double height) {
|
||||
final String mimeType = uri.data.mimeType;
|
||||
if (mimeType.startsWith('image/')) {
|
||||
return new Image.memory(uri.data.contentAsBytes(), width: width, height: height);
|
||||
return new Image.memory(uri.data.contentAsBytes(),
|
||||
width: width, height: height);
|
||||
} else if (mimeType.startsWith('text/')) {
|
||||
return new Text(uri.data.contentAsString());
|
||||
}
|
||||
@ -312,12 +307,14 @@ class MarkdownBuilder implements md.NodeVisitor {
|
||||
|
||||
Widget _buildBullet(String listTag) {
|
||||
if (listTag == 'ul')
|
||||
return new Text('•', textAlign: TextAlign.center, style: styleSheet.styles['li']);
|
||||
return new Text('•',
|
||||
textAlign: TextAlign.center, style: styleSheet.styles['li']);
|
||||
|
||||
final int index = _blocks.last.nextListIndex;
|
||||
return new Padding(
|
||||
padding: const EdgeInsets.only(right: 5.0),
|
||||
child: new Text('${index + 1}.', textAlign: TextAlign.right, style: styleSheet.styles['li']),
|
||||
child: new Text('${index + 1}.',
|
||||
textAlign: TextAlign.right, style: styleSheet.styles['li']),
|
||||
);
|
||||
}
|
||||
|
||||
@ -356,7 +353,9 @@ class MarkdownBuilder implements md.NodeVisitor {
|
||||
List<Widget> _mergeInlineChildren(_InlineElement inline) {
|
||||
List<Widget> mergedTexts = <Widget>[];
|
||||
for (Widget child in inline.children) {
|
||||
if (mergedTexts.isNotEmpty && mergedTexts.last is RichText && child is RichText) {
|
||||
if (mergedTexts.isNotEmpty &&
|
||||
mergedTexts.last is RichText &&
|
||||
child is RichText) {
|
||||
RichText previous = mergedTexts.removeLast();
|
||||
List<TextSpan> children = previous.text.children != null
|
||||
? new List.from(previous.text.children)
|
||||
|
@ -7,8 +7,8 @@ import 'package:flutter/material.dart';
|
||||
/// Defines which [TextStyle] objects to use for which Markdown elements.
|
||||
class MarkdownStyleSheet {
|
||||
/// Creates an explicit mapping of [TextStyle] objects to Markdown elements.
|
||||
MarkdownStyleSheet({
|
||||
this.a,
|
||||
MarkdownStyleSheet(
|
||||
{this.a,
|
||||
this.p,
|
||||
this.code,
|
||||
this.h1,
|
||||
@ -28,8 +28,8 @@ class MarkdownStyleSheet {
|
||||
this.codeblockPadding,
|
||||
this.codeblockDecoration,
|
||||
this.horizontalRuleDecoration,
|
||||
this.textScaleFactor = 1.0
|
||||
}) : _styles = <String, TextStyle>{
|
||||
this.textScaleFactor = 1.0})
|
||||
: _styles = <String, TextStyle>{
|
||||
'a': a,
|
||||
'p': p,
|
||||
'li': p,
|
||||
@ -56,8 +56,7 @@ class MarkdownStyleSheet {
|
||||
code: new TextStyle(
|
||||
color: Colors.grey.shade700,
|
||||
fontFamily: "monospace",
|
||||
fontSize: theme.textTheme.body1.fontSize * 0.85
|
||||
),
|
||||
fontSize: theme.textTheme.body1.fontSize * 0.85),
|
||||
h1: theme.textTheme.headline,
|
||||
h2: theme.textTheme.title,
|
||||
h3: theme.textTheme.subhead,
|
||||
@ -73,17 +72,14 @@ class MarkdownStyleSheet {
|
||||
blockquotePadding: 8.0,
|
||||
blockquoteDecoration: new BoxDecoration(
|
||||
color: Colors.blue.shade100,
|
||||
borderRadius: new BorderRadius.circular(2.0)
|
||||
),
|
||||
borderRadius: new BorderRadius.circular(2.0)),
|
||||
codeblockPadding: 8.0,
|
||||
codeblockDecoration: new BoxDecoration(
|
||||
color: Colors.grey.shade100,
|
||||
borderRadius: new BorderRadius.circular(2.0)
|
||||
),
|
||||
borderRadius: new BorderRadius.circular(2.0)),
|
||||
horizontalRuleDecoration: new BoxDecoration(
|
||||
border: new Border(
|
||||
top: new BorderSide(width: 5.0, color: Colors.grey.shade300)
|
||||
),
|
||||
top: new BorderSide(width: 5.0, color: Colors.grey.shade300)),
|
||||
),
|
||||
);
|
||||
}
|
||||
@ -99,8 +95,7 @@ class MarkdownStyleSheet {
|
||||
code: new TextStyle(
|
||||
color: Colors.grey.shade700,
|
||||
fontFamily: "monospace",
|
||||
fontSize: theme.textTheme.body1.fontSize * 0.85
|
||||
),
|
||||
fontSize: theme.textTheme.body1.fontSize * 0.85),
|
||||
h1: theme.textTheme.display3,
|
||||
h2: theme.textTheme.display2,
|
||||
h3: theme.textTheme.display1,
|
||||
@ -116,17 +111,14 @@ class MarkdownStyleSheet {
|
||||
blockquotePadding: 8.0,
|
||||
blockquoteDecoration: new BoxDecoration(
|
||||
color: Colors.blue.shade100,
|
||||
borderRadius: new BorderRadius.circular(2.0)
|
||||
),
|
||||
borderRadius: new BorderRadius.circular(2.0)),
|
||||
codeblockPadding: 8.0,
|
||||
codeblockDecoration: new BoxDecoration(
|
||||
color: Colors.grey.shade100,
|
||||
borderRadius: new BorderRadius.circular(2.0)
|
||||
),
|
||||
borderRadius: new BorderRadius.circular(2.0)),
|
||||
horizontalRuleDecoration: new BoxDecoration(
|
||||
border: new Border(
|
||||
top: new BorderSide(width: 5.0, color: Colors.grey.shade300)
|
||||
),
|
||||
top: new BorderSide(width: 5.0, color: Colors.grey.shade300)),
|
||||
),
|
||||
);
|
||||
}
|
||||
@ -176,7 +168,8 @@ class MarkdownStyleSheet {
|
||||
blockquoteDecoration: blockquoteDecoration ?? this.blockquoteDecoration,
|
||||
codeblockPadding: codeblockPadding ?? this.codeblockPadding,
|
||||
codeblockDecoration: codeblockDecoration ?? this.codeblockDecoration,
|
||||
horizontalRuleDecoration: horizontalRuleDecoration ?? this.horizontalRuleDecoration,
|
||||
horizontalRuleDecoration:
|
||||
horizontalRuleDecoration ?? this.horizontalRuleDecoration,
|
||||
textScaleFactor: textScaleFactor ?? this.textScaleFactor,
|
||||
);
|
||||
}
|
||||
@ -250,32 +243,30 @@ class MarkdownStyleSheet {
|
||||
|
||||
@override
|
||||
bool operator ==(dynamic other) {
|
||||
if (identical(this, other))
|
||||
return true;
|
||||
if (other.runtimeType != MarkdownStyleSheet)
|
||||
return false;
|
||||
if (identical(this, other)) return true;
|
||||
if (other.runtimeType != MarkdownStyleSheet) return false;
|
||||
final MarkdownStyleSheet typedOther = other;
|
||||
return typedOther.a == a
|
||||
&& typedOther.p == p
|
||||
&& typedOther.code == code
|
||||
&& typedOther.h1 == h1
|
||||
&& typedOther.h2 == h2
|
||||
&& typedOther.h3 == h3
|
||||
&& typedOther.h4 == h4
|
||||
&& typedOther.h5 == h5
|
||||
&& typedOther.h6 == h6
|
||||
&& typedOther.em == em
|
||||
&& typedOther.strong == strong
|
||||
&& typedOther.blockquote == blockquote
|
||||
&& typedOther.img == img
|
||||
&& typedOther.blockSpacing == blockSpacing
|
||||
&& typedOther.listIndent == listIndent
|
||||
&& typedOther.blockquotePadding == blockquotePadding
|
||||
&& typedOther.blockquoteDecoration == blockquoteDecoration
|
||||
&& typedOther.codeblockPadding == codeblockPadding
|
||||
&& typedOther.codeblockDecoration == codeblockDecoration
|
||||
&& typedOther.horizontalRuleDecoration == horizontalRuleDecoration
|
||||
&& typedOther.textScaleFactor == textScaleFactor;
|
||||
return typedOther.a == a &&
|
||||
typedOther.p == p &&
|
||||
typedOther.code == code &&
|
||||
typedOther.h1 == h1 &&
|
||||
typedOther.h2 == h2 &&
|
||||
typedOther.h3 == h3 &&
|
||||
typedOther.h4 == h4 &&
|
||||
typedOther.h5 == h5 &&
|
||||
typedOther.h6 == h6 &&
|
||||
typedOther.em == em &&
|
||||
typedOther.strong == strong &&
|
||||
typedOther.blockquote == blockquote &&
|
||||
typedOther.img == img &&
|
||||
typedOther.blockSpacing == blockSpacing &&
|
||||
typedOther.listIndent == listIndent &&
|
||||
typedOther.blockquotePadding == blockquotePadding &&
|
||||
typedOther.blockquoteDecoration == blockquoteDecoration &&
|
||||
typedOther.codeblockPadding == codeblockPadding &&
|
||||
typedOther.codeblockDecoration == codeblockDecoration &&
|
||||
typedOther.horizontalRuleDecoration == horizontalRuleDecoration &&
|
||||
typedOther.textScaleFactor == textScaleFactor;
|
||||
}
|
||||
|
||||
@override
|
||||
|
@ -11,6 +11,7 @@ import 'package:meta/meta.dart';
|
||||
|
||||
import 'builder.dart';
|
||||
import 'style_sheet.dart';
|
||||
|
||||
//
|
||||
typedef Widget ItemDemoBuilder(Map<String, dynamic> attrs);
|
||||
|
||||
@ -22,7 +23,8 @@ typedef void MarkdownTapLinkCallback(String href);
|
||||
/// Creates a format [TextSpan] given a string.
|
||||
///
|
||||
/// Used by [MarkdownWidget] to highlight the contents of `pre` elements.
|
||||
abstract class SyntaxHighlighter { // ignore: one_member_abstracts
|
||||
abstract class SyntaxHighlighter {
|
||||
// ignore: one_member_abstracts
|
||||
/// Returns the formated [TextSpan] for the given string.
|
||||
TextSpan format(String source);
|
||||
}
|
||||
@ -72,6 +74,7 @@ abstract class MarkdownWidget extends StatefulWidget {
|
||||
final Directory imageDirectory;
|
||||
|
||||
final ItemDemoBuilder demoBuilder;
|
||||
|
||||
/// Subclasses should override this function to display the given children,
|
||||
/// which are the parsed representation of [data].
|
||||
@protected
|
||||
@ -91,7 +94,8 @@ class DemosSyntax extends md.InlineSyntax {
|
||||
}
|
||||
}
|
||||
|
||||
class _MarkdownWidgetState extends State<MarkdownWidget> implements MarkdownBuilderDelegate {
|
||||
class _MarkdownWidgetState extends State<MarkdownWidget>
|
||||
implements MarkdownBuilderDelegate {
|
||||
List<Widget> _children;
|
||||
final List<GestureRecognizer> _recognizers = <GestureRecognizer>[];
|
||||
|
||||
@ -104,9 +108,8 @@ class _MarkdownWidgetState extends State<MarkdownWidget> implements MarkdownBuil
|
||||
@override
|
||||
void didUpdateWidget(MarkdownWidget oldWidget) {
|
||||
super.didUpdateWidget(oldWidget);
|
||||
if (widget.data != oldWidget.data
|
||||
|| widget.styleSheet != oldWidget.styleSheet)
|
||||
_parseMarkdown();
|
||||
if (widget.data != oldWidget.data ||
|
||||
widget.styleSheet != oldWidget.styleSheet) _parseMarkdown();
|
||||
}
|
||||
|
||||
@override
|
||||
@ -116,7 +119,8 @@ class _MarkdownWidgetState extends State<MarkdownWidget> implements MarkdownBuil
|
||||
}
|
||||
|
||||
void _parseMarkdown() {
|
||||
final MarkdownStyleSheet styleSheet = widget.styleSheet ?? new MarkdownStyleSheet.fromTheme(Theme.of(context));
|
||||
final MarkdownStyleSheet styleSheet = widget.styleSheet ??
|
||||
new MarkdownStyleSheet.fromTheme(Theme.of(context));
|
||||
|
||||
_disposeRecognizers();
|
||||
|
||||
@ -128,31 +132,29 @@ class _MarkdownWidgetState extends State<MarkdownWidget> implements MarkdownBuil
|
||||
new DemosSyntax(),
|
||||
new md.InlineHtmlSyntax(),
|
||||
]);
|
||||
final md.Document document = new md.Document(encodeHtml: false, extensionSet: extens);
|
||||
final md.Document document =
|
||||
new md.Document(encodeHtml: false, extensionSet: extens);
|
||||
final MarkdownBuilder builder = new MarkdownBuilder(
|
||||
delegate: this,
|
||||
styleSheet: styleSheet,
|
||||
imageDirectory: widget.imageDirectory,
|
||||
demoParser: widget.demoBuilder
|
||||
);
|
||||
demoParser: widget.demoBuilder);
|
||||
_children = builder.build(document.parseLines(lines));
|
||||
}
|
||||
|
||||
void _disposeRecognizers() {
|
||||
if (_recognizers.isEmpty)
|
||||
return;
|
||||
final List<GestureRecognizer> localRecognizers = new List<GestureRecognizer>.from(_recognizers);
|
||||
if (_recognizers.isEmpty) return;
|
||||
final List<GestureRecognizer> localRecognizers =
|
||||
new List<GestureRecognizer>.from(_recognizers);
|
||||
_recognizers.clear();
|
||||
for (GestureRecognizer recognizer in localRecognizers)
|
||||
recognizer.dispose();
|
||||
for (GestureRecognizer recognizer in localRecognizers) recognizer.dispose();
|
||||
}
|
||||
|
||||
@override
|
||||
GestureRecognizer createLink(String href) {
|
||||
final TapGestureRecognizer recognizer = new TapGestureRecognizer()
|
||||
..onTap = () {
|
||||
if (widget.onTapLink != null)
|
||||
widget.onTapLink(href);
|
||||
if (widget.onTapLink != null) widget.onTapLink(href);
|
||||
};
|
||||
_recognizers.add(recognizer);
|
||||
return recognizer;
|
||||
@ -195,13 +197,11 @@ class MarkdownBody extends MarkdownWidget {
|
||||
syntaxHighlighter: syntaxHighlighter,
|
||||
onTapLink: onTapLink,
|
||||
imageDirectory: imageDirectory,
|
||||
demoBuilder: demoBuilder
|
||||
);
|
||||
demoBuilder: demoBuilder);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context, List<Widget> children) {
|
||||
if (children.length == 1)
|
||||
return children.single;
|
||||
if (children.length == 1) return children.single;
|
||||
return new Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||
children: children,
|
||||
|
@ -24,7 +24,8 @@ class _FullScreenCodeDialogState extends State<FullScreenCodeDialog> {
|
||||
void didChangeDependencies() {
|
||||
print('widget.filePath=======${widget.filePath}');
|
||||
if (widget.filePath != null) {
|
||||
getExampleCode(context,'${widget.filePath}', DefaultAssetBundle.of(context))
|
||||
getExampleCode(
|
||||
context, '${widget.filePath}', DefaultAssetBundle.of(context))
|
||||
.then<void>((String code) {
|
||||
if (mounted) {
|
||||
setState(() {
|
||||
@ -48,6 +49,7 @@ class _FullScreenCodeDialogState extends State<FullScreenCodeDialog> {
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final SyntaxHighlighterStyle style =
|
||||
@ -67,7 +69,8 @@ class _FullScreenCodeDialogState extends State<FullScreenCodeDialog> {
|
||||
style: const TextStyle(fontFamily: 'monospace', fontSize: 10.0),
|
||||
children: <TextSpan>[
|
||||
DartSyntaxHighlighter(style).format(_exampleCode)
|
||||
],),
|
||||
],
|
||||
),
|
||||
);
|
||||
} catch (err) {
|
||||
_codeWidget = Text(_exampleCode);
|
||||
|
@ -8,8 +8,7 @@ class HomeBanner extends StatefulWidget {
|
||||
final List<StoryModel> bannerStories;
|
||||
final OnTapBannerItem onTap;
|
||||
|
||||
HomeBanner(this.bannerStories, this.onTap, {Key key})
|
||||
:super(key: key);
|
||||
HomeBanner(this.bannerStories, this.onTap, {Key key}) : super(key: key);
|
||||
|
||||
@override
|
||||
State<StatefulWidget> createState() {
|
||||
@ -27,11 +26,11 @@ class _BannerState extends State<HomeBanner> {
|
||||
void initState() {
|
||||
super.initState();
|
||||
controller = PageController(initialPage: realIndex);
|
||||
timer = Timer.periodic(Duration(seconds: 5), (timer) { // 自动滚动
|
||||
timer = Timer.periodic(Duration(seconds: 5), (timer) {
|
||||
// 自动滚动
|
||||
/// print(realIndex);
|
||||
controller.animateToPage(realIndex + 1,
|
||||
duration: Duration(milliseconds: 300),
|
||||
curve: Curves.linear);
|
||||
duration: Duration(milliseconds: 300), curve: Curves.linear);
|
||||
});
|
||||
}
|
||||
|
||||
@ -50,7 +49,10 @@ class _BannerState extends State<HomeBanner> {
|
||||
margin: EdgeInsets.only(top: 10.0, right: 5.0),
|
||||
padding: EdgeInsets.symmetric(horizontal: 6.0, vertical: 2.0),
|
||||
child: Text("${++index}/$itemCount",
|
||||
style: TextStyle( color: Colors.white70, fontSize: 12.0, fontWeight:FontWeight.bold )),
|
||||
style: TextStyle(
|
||||
color: Colors.white70,
|
||||
fontSize: 12.0,
|
||||
fontWeight: FontWeight.bold)),
|
||||
);
|
||||
}
|
||||
|
||||
@ -58,43 +60,45 @@ class _BannerState extends State<HomeBanner> {
|
||||
Widget build(BuildContext context) {
|
||||
return Container(
|
||||
height: 226.0,
|
||||
child: Stack(
|
||||
alignment: Alignment.bottomCenter,
|
||||
children: <Widget>[
|
||||
child: Stack(alignment: Alignment.bottomCenter, children: <Widget>[
|
||||
PageView(
|
||||
controller: controller,
|
||||
onPageChanged: _onPageChanged,
|
||||
children: _buildItems(),),
|
||||
children: _buildItems(),
|
||||
),
|
||||
_buildIndicator(), // 下面的小点
|
||||
Positioned(//方法二
|
||||
Positioned(
|
||||
//方法二
|
||||
top: 0.0,
|
||||
right: 0.0,
|
||||
child: _numberIndicator(context,virtualIndex,widget.bannerStories.length),
|
||||
child: _numberIndicator(
|
||||
context, virtualIndex, widget.bannerStories.length),
|
||||
)
|
||||
]),
|
||||
);
|
||||
}
|
||||
|
||||
List<Widget> _buildItems() { // 排列轮播数组
|
||||
List<Widget> _buildItems() {
|
||||
// 排列轮播数组
|
||||
List<Widget> items = [];
|
||||
if (widget.bannerStories.length > 0) {
|
||||
// 头部添加一个尾部Item,模拟循环
|
||||
items.add(
|
||||
_buildItem(widget.bannerStories[widget.bannerStories.length - 1]));
|
||||
// 正常添加Item
|
||||
items.addAll(
|
||||
widget.bannerStories.map((story) => _buildItem(story)).toList(
|
||||
growable: false));
|
||||
items.addAll(widget.bannerStories
|
||||
.map((story) => _buildItem(story))
|
||||
.toList(growable: false));
|
||||
// 尾部
|
||||
items.add(
|
||||
_buildItem(widget.bannerStories[0]));
|
||||
items.add(_buildItem(widget.bannerStories[0]));
|
||||
}
|
||||
return items;
|
||||
}
|
||||
|
||||
Widget _buildItem(StoryModel story) {
|
||||
return GestureDetector(
|
||||
onTap: () { // 按下
|
||||
onTap: () {
|
||||
// 按下
|
||||
if (widget.onTap != null) {
|
||||
widget.onTap(story);
|
||||
}
|
||||
@ -104,12 +108,15 @@ class _BannerState extends State<HomeBanner> {
|
||||
children: <Widget>[
|
||||
Image.network(story.image, fit: BoxFit.cover),
|
||||
_buildItemTitle(story.title), // 内容文字,大意
|
||||
],),);
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildItemTitle(String title) {
|
||||
return Container(
|
||||
decoration: BoxDecoration( /// 背景的渐变色
|
||||
decoration: BoxDecoration(
|
||||
/// 背景的渐变色
|
||||
gradient: LinearGradient(
|
||||
begin: Alignment.bottomCenter,
|
||||
end: const Alignment(0.0, -0.8),
|
||||
@ -120,7 +127,10 @@ class _BannerState extends State<HomeBanner> {
|
||||
child: Container(
|
||||
margin: EdgeInsets.symmetric(vertical: 22.0, horizontal: 16.0),
|
||||
child: Text(
|
||||
title, style: TextStyle(color: Colors.white, fontSize: 18.0),),),
|
||||
title,
|
||||
style: TextStyle(color: Colors.white, fontSize: 18.0),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
@ -136,8 +146,7 @@ class _BannerState extends State<HomeBanner> {
|
||||
color: i == virtualIndex ? Colors.white : Colors.grey)));
|
||||
}
|
||||
return Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: indicators);
|
||||
mainAxisAlignment: MainAxisAlignment.center, children: indicators);
|
||||
}
|
||||
|
||||
_onPageChanged(int index) {
|
||||
|
@ -14,7 +14,8 @@ class ListRefresh extends StatefulWidget {
|
||||
final requestApi;
|
||||
final headerView;
|
||||
|
||||
const ListRefresh([this.requestApi, this.renderItem, this.headerView]) : super();
|
||||
const ListRefresh([this.requestApi, this.renderItem, this.headerView])
|
||||
: super();
|
||||
|
||||
@override
|
||||
State<StatefulWidget> createState() => _ListRefreshState();
|
||||
@ -91,6 +92,7 @@ class _ListRefreshState extends State<ListRefresh> {
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
// 下拉加载的事件,清空之前list内容,取前X个
|
||||
// 其实就是列表重置
|
||||
Future<Null> _handleRefresh() async {
|
||||
|
@ -8,7 +8,6 @@ import '../routers/application.dart';
|
||||
import '../routers/routers.dart';
|
||||
import 'dart:core';
|
||||
|
||||
|
||||
class ListViewItem extends StatelessWidget {
|
||||
final String itemUrl;
|
||||
final String itemTitle;
|
||||
@ -17,7 +16,6 @@ class ListViewItem extends StatelessWidget {
|
||||
const ListViewItem({Key key, this.itemUrl, this.itemTitle, this.data})
|
||||
: super(key: key);
|
||||
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Card(
|
||||
@ -27,7 +25,8 @@ class ListViewItem extends StatelessWidget {
|
||||
child: ListTile(
|
||||
onTap: () {
|
||||
// _launchURL(itemUrl, context);
|
||||
Application.router.navigateTo(context, '${Routes.webViewPage}?title=${Uri.encodeComponent(itemTitle)}&url=${Uri.encodeComponent(itemUrl)}');
|
||||
Application.router.navigateTo(context,
|
||||
'${Routes.webViewPage}?title=${Uri.encodeComponent(itemTitle)}&url=${Uri.encodeComponent(itemUrl)}');
|
||||
},
|
||||
title: Padding(
|
||||
child: Text(
|
||||
|
@ -6,21 +6,18 @@ import 'package:flutter_go/utils/high_light_code.dart';
|
||||
/// 使用方法
|
||||
/// MarkdownBody(markdown)
|
||||
final hightlighter = new HighLight();
|
||||
|
||||
class HighLight extends md.SyntaxHighlighter {
|
||||
@override
|
||||
TextSpan format(String source) {
|
||||
final SyntaxHighlighterStyle style = SyntaxHighlighterStyle.lightThemeStyle();
|
||||
final SyntaxHighlighterStyle style =
|
||||
SyntaxHighlighterStyle.lightThemeStyle();
|
||||
return TextSpan(
|
||||
style: const TextStyle(fontSize: 10.0),
|
||||
children: <TextSpan>[
|
||||
DartSyntaxHighlighter(style).format(source)
|
||||
]
|
||||
);
|
||||
children: <TextSpan>[DartSyntaxHighlighter(style).format(source)]);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
class MarkdownBody extends StatelessWidget {
|
||||
final String data;
|
||||
MarkdownBody(this.data);
|
||||
|
@ -20,10 +20,39 @@ class Pagination extends StatelessWidget {
|
||||
];
|
||||
|
||||
final List<dynamic> arr = [
|
||||
{'image': 'https://img.alicdn.com/tfs/TB1W4hMAwHqK1RjSZJnXXbNLpXa-519-260.jpg', 'type': 0, 'id': 9695909, 'url': 'https://www.zhihu.com/question/294145797/answer/551162834', 'title': '为什么阿里巴巴、腾讯和 Google 之类的企业都在使用 Flutter 开发 App?'},
|
||||
{'image': 'https://img.alicdn.com/tfs/TB1XmFIApzqK1RjSZSgXXcpAVXa-720-338.jpg', 'type': 0, 'id': 9695859, 'url': 'https://zhuanlan.zhihu.com/p/51696594', 'title': 'Flutter 1.0 正式发布: Google 的便携 UI 工具包'},
|
||||
{'image': 'https://img.alicdn.com/tfs/TB1mClCABLoK1RjSZFuXXXn0XXa-600-362.jpg', 'type': 0, 'id': 96956491409, 'url':'https://zhuanlan.zhihu.com/p/53497167','title': 'Flutter 示范应用现已开源 — 万物起源(The History of Everything)'},
|
||||
{'image': 'https://img.alicdn.com/tfs/TB1fXxIAAvoK1RjSZFNXXcxMVXa-600-362.jpg', 'type': 0, 'id': 9695816, 'url': 'https://mp.weixin.qq.com/s?__biz=MzAwODY4OTk2Mg==&mid=2652048101&idx=1&sn=20296088e4bd8ca33c5c9991167d9f7d&chksm=808caaa0b7fb23b65c0e5806209f8d86da6732f3a00a70353f3606018339518b0a8656f14dc5&mpsshare=1&scene=2&srcid=0106SZapVysZdIS6Oc5AhNH6&from=timeline&ascene=2&devicetype=android-27&version=27000038&nettype=WIFI&abtest_cookie=BQABAAgACgALABMAFAAFAJ2GHgAjlx4AV5keAJuZHgCcmR4AAAA%3D&lang=zh_CN&pass_ticket=4K1%2FUpsxP4suPj2iubR17wbAP7r9LW9iYrPAC2dppTqv7j7JO5FWMXtcKeBRxueV&wx_header=1', 'title': 'Flutter 与 Material Design 双剑合璧,助您构建精美应用'}
|
||||
{
|
||||
'image':
|
||||
'https://img.alicdn.com/tfs/TB1W4hMAwHqK1RjSZJnXXbNLpXa-519-260.jpg',
|
||||
'type': 0,
|
||||
'id': 9695909,
|
||||
'url': 'https://www.zhihu.com/question/294145797/answer/551162834',
|
||||
'title': '为什么阿里巴巴、腾讯和 Google 之类的企业都在使用 Flutter 开发 App?'
|
||||
},
|
||||
{
|
||||
'image':
|
||||
'https://img.alicdn.com/tfs/TB1XmFIApzqK1RjSZSgXXcpAVXa-720-338.jpg',
|
||||
'type': 0,
|
||||
'id': 9695859,
|
||||
'url': 'https://zhuanlan.zhihu.com/p/51696594',
|
||||
'title': 'Flutter 1.0 正式发布: Google 的便携 UI 工具包'
|
||||
},
|
||||
{
|
||||
'image':
|
||||
'https://img.alicdn.com/tfs/TB1mClCABLoK1RjSZFuXXXn0XXa-600-362.jpg',
|
||||
'type': 0,
|
||||
'id': 96956491409,
|
||||
'url': 'https://zhuanlan.zhihu.com/p/53497167',
|
||||
'title': 'Flutter 示范应用现已开源 — 万物起源(The History of Everything)'
|
||||
},
|
||||
{
|
||||
'image':
|
||||
'https://img.alicdn.com/tfs/TB1fXxIAAvoK1RjSZFNXXcxMVXa-600-362.jpg',
|
||||
'type': 0,
|
||||
'id': 9695816,
|
||||
'url':
|
||||
'https://mp.weixin.qq.com/s?__biz=MzAwODY4OTk2Mg==&mid=2652048101&idx=1&sn=20296088e4bd8ca33c5c9991167d9f7d&chksm=808caaa0b7fb23b65c0e5806209f8d86da6732f3a00a70353f3606018339518b0a8656f14dc5&mpsshare=1&scene=2&srcid=0106SZapVysZdIS6Oc5AhNH6&from=timeline&ascene=2&devicetype=android-27&version=27000038&nettype=WIFI&abtest_cookie=BQABAAgACgALABMAFAAFAJ2GHgAjlx4AV5keAJuZHgCcmR4AAAA%3D&lang=zh_CN&pass_ticket=4K1%2FUpsxP4suPj2iubR17wbAP7r9LW9iYrPAC2dppTqv7j7JO5FWMXtcKeBRxueV&wx_header=1',
|
||||
'title': 'Flutter 与 Material Design 双剑合璧,助您构建精美应用'
|
||||
}
|
||||
];
|
||||
|
||||
void _launchURL(String url) async {
|
||||
@ -37,12 +66,12 @@ class Pagination extends StatelessWidget {
|
||||
List<Widget> _pageSelector(BuildContext context) {
|
||||
List<Widget> list = [];
|
||||
List<StoryModel> bannerStories = [];
|
||||
|
||||
/// super.initState();
|
||||
arr.forEach((item) {
|
||||
bannerStories.add(StoryModel.fromJson(item));
|
||||
});
|
||||
|
||||
|
||||
if (arr.length > 0) {
|
||||
list.add(HomeBanner(bannerStories, (story) {
|
||||
_launchURL('${story.url}');
|
||||
@ -53,12 +82,10 @@ class Pagination extends StatelessWidget {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return
|
||||
Column(
|
||||
return Column(
|
||||
key: Key('__header__'),
|
||||
//physics: AlwaysScrollableScrollPhysics(),
|
||||
//padding: EdgeInsets.only(),
|
||||
children: _pageSelector(context)
|
||||
);
|
||||
children: _pageSelector(context));
|
||||
}
|
||||
}
|
||||
|
@ -16,7 +16,8 @@ class SingleThemeColor extends StatelessWidget {
|
||||
onTap: () {
|
||||
if (ApplicationEvent.event != null) {
|
||||
print('fire ${this.themeColor}');
|
||||
ApplicationEvent.event.fire(UserSettingThemeColorEvent(this.themeColor));
|
||||
ApplicationEvent.event
|
||||
.fire(UserSettingThemeColorEvent(this.themeColor));
|
||||
Navigator.of(context).pop();
|
||||
}
|
||||
},
|
||||
|
@ -9,6 +9,7 @@ import 'package:flutter_go/utils/data_utils.dart';
|
||||
import '../routers/application.dart';
|
||||
import '../routers/routers.dart';
|
||||
import '../components/markdown.dart';
|
||||
|
||||
/// import '../model/collection.dart';
|
||||
import '../widgets/index.dart';
|
||||
import '../event/event_bus.dart';
|
||||
@ -35,6 +36,7 @@ class WidgetDemo extends StatefulWidget {
|
||||
|
||||
class _WidgetDemoState extends State<WidgetDemo> {
|
||||
bool _hasCollected = false;
|
||||
|
||||
/// CollectionControlModel _collectionControl = new CollectionControlModel();
|
||||
var _collectionIcons;
|
||||
List widgetDemosList = new WidgetDemoList().getDemos();
|
||||
@ -141,11 +143,11 @@ class _WidgetDemoState extends State<WidgetDemo> {
|
||||
'${Routes.codeView}?filePath=${Uri.encodeComponent(widget.codeUrl)}');
|
||||
}
|
||||
}
|
||||
|
||||
List<PopupMenuEntry<String>> buildPopupMenu() {
|
||||
List<PopupMenuEntry<String>> comps = [];
|
||||
if (widget.docUrl != null) {
|
||||
comps.add(
|
||||
PopupMenuItem<String>(
|
||||
comps.add(PopupMenuItem<String>(
|
||||
value: 'doc',
|
||||
child: ListTile(
|
||||
leading: Icon(
|
||||
@ -154,12 +156,10 @@ class _WidgetDemoState extends State<WidgetDemo> {
|
||||
),
|
||||
title: Text('查看文档'),
|
||||
),
|
||||
)
|
||||
);
|
||||
));
|
||||
}
|
||||
if (widget.codeUrl != null) {
|
||||
comps.add(
|
||||
PopupMenuItem<String>(
|
||||
comps.add(PopupMenuItem<String>(
|
||||
value: 'code',
|
||||
child: ListTile(
|
||||
leading: Icon(
|
||||
@ -168,11 +168,11 @@ class _WidgetDemoState extends State<WidgetDemo> {
|
||||
),
|
||||
title: Text('查看Demo'),
|
||||
),
|
||||
)
|
||||
);
|
||||
));
|
||||
}
|
||||
return comps;
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
if (_hasCollected) {
|
||||
@ -196,12 +196,10 @@ class _WidgetDemoState extends State<WidgetDemo> {
|
||||
),
|
||||
];
|
||||
if (menus.length > 0) {
|
||||
actions.add(
|
||||
PopupMenuButton<String>(
|
||||
actions.add(PopupMenuButton<String>(
|
||||
onSelected: _selectValue,
|
||||
itemBuilder: (BuildContext context) => menus,
|
||||
)
|
||||
);
|
||||
));
|
||||
}
|
||||
return Scaffold(
|
||||
key: _scaffoldKey,
|
||||
|
@ -13,23 +13,21 @@ class WidgetItemContainer extends StatelessWidget {
|
||||
// 所有的可用demos;
|
||||
final List widgetDemosList = new WidgetDemoList().getDemos();
|
||||
|
||||
WidgetItemContainer(
|
||||
{Key key,
|
||||
WidgetItemContainer({
|
||||
Key key,
|
||||
@required this.commonItems,
|
||||
@required this.columnCount,
|
||||
// @required this.isWidgetPoint
|
||||
})
|
||||
: super(key: key);
|
||||
}) : super(key: key);
|
||||
|
||||
/// 跳转goup
|
||||
void tapToGroup(CategoryComponent cate, BuildContext context) {
|
||||
Application.router
|
||||
.navigateTo(context, "/category/${cate.token}", transition: TransitionType.inFromRight);
|
||||
Application.router.navigateTo(context, "/category/${cate.token}",
|
||||
transition: TransitionType.inFromRight);
|
||||
}
|
||||
|
||||
/// 跳转到老的widget界面
|
||||
void tapToOldWidget(WidgetLeaf leaf, BuildContext context) {
|
||||
|
||||
String targetName = leaf.name;
|
||||
String targetRouter = '/category/error/404';
|
||||
widgetDemosList.forEach((item) {
|
||||
@ -38,13 +36,15 @@ class WidgetItemContainer extends StatelessWidget {
|
||||
targetRouter = targetRouter.toLowerCase();
|
||||
}
|
||||
});
|
||||
Application.router.navigateTo(context, targetRouter, transition: TransitionType.inFromRight);
|
||||
Application.router.navigateTo(context, targetRouter,
|
||||
transition: TransitionType.inFromRight);
|
||||
}
|
||||
|
||||
/// 跳转到新的标准页
|
||||
void tapToStandardPage(WidgetLeaf leaf, BuildContext context) {
|
||||
String targetRouter = '/standard-page/${leaf.pageId}';
|
||||
Application.router.navigateTo(context, targetRouter, transition: TransitionType.inFromRight);
|
||||
Application.router.navigateTo(context, targetRouter,
|
||||
transition: TransitionType.inFromRight);
|
||||
}
|
||||
|
||||
List<Widget> _buildColumns(context) {
|
||||
@ -58,7 +58,6 @@ class WidgetItemContainer extends StatelessWidget {
|
||||
if (addI < length) {
|
||||
CommonItem item = commonItems[addI];
|
||||
|
||||
|
||||
_listRows.add(
|
||||
Expanded(
|
||||
flex: 1,
|
||||
@ -80,15 +79,16 @@ class WidgetItemContainer extends StatelessWidget {
|
||||
}
|
||||
}
|
||||
|
||||
Application.router
|
||||
.navigateTo(context, "/category/error/404", transition: TransitionType.inFromRight);
|
||||
Application.router.navigateTo(
|
||||
context, "/category/error/404",
|
||||
transition: TransitionType.inFromRight);
|
||||
},
|
||||
index: addI,
|
||||
totalCount: length,
|
||||
rowLength: columnCount,
|
||||
|
||||
/// textSize: true ? 'middle' : 'small',
|
||||
textSize: 'middle'
|
||||
),
|
||||
textSize: 'middle'),
|
||||
),
|
||||
);
|
||||
} else {
|
||||
@ -116,4 +116,3 @@ class WidgetItemContainer extends StatelessWidget {
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -57,7 +57,10 @@ class _MyAppState extends State<MyApp> {
|
||||
try {
|
||||
response = await NetUtils.get(reqs, {});
|
||||
print('response-$response');
|
||||
if(response['status'] == 200 && response['success'] ==true && response['data'] is Map && response['data']['isOpen'] == true) {
|
||||
if (response['status'] == 200 &&
|
||||
response['success'] == true &&
|
||||
response['data'] is Map &&
|
||||
response['data']['isOpen'] == true) {
|
||||
Application.pageIsOpen = true;
|
||||
print('是否需要展开【业界动态】${Application.pageIsOpen}');
|
||||
}
|
||||
@ -210,11 +213,11 @@ void main() async {
|
||||
new SearchHistoryList(sp);
|
||||
|
||||
await DataUtils.getWidgetTreeList().then((List json) {
|
||||
List data = WidgetTree.insertDevPagesToList(json, StandardPages().getLocalList());
|
||||
List data =
|
||||
WidgetTree.insertDevPagesToList(json, StandardPages().getLocalList());
|
||||
Application.widgetTree = WidgetTree.buildWidgetTree(data);
|
||||
print("Application.widgetTree>>>> ${Application.widgetTree}");
|
||||
});
|
||||
db = Provider.db;
|
||||
runApp(new MyApp());
|
||||
}
|
||||
|
||||
|
@ -71,6 +71,7 @@ class CollectionControlModel {
|
||||
Future deleteByName(String name) async {
|
||||
return await sql.delete(name, 'name');
|
||||
}
|
||||
|
||||
// 通过path删除
|
||||
Future deleteByPath(String path) async {
|
||||
return await sql.delete(path, 'router');
|
||||
|
@ -11,15 +11,10 @@ class ResponseData{
|
||||
message = json['message'];
|
||||
|
||||
Map<String, dynamic> toJson() =>
|
||||
{
|
||||
'status': status,
|
||||
'success': success,
|
||||
'messsage': message
|
||||
};
|
||||
{'status': status, 'success': success, 'messsage': message};
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'status: $status ,success: $success,message: ${message.toString()}';
|
||||
}
|
||||
|
||||
}
|
@ -12,7 +12,6 @@ import 'dart:convert';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_go/utils/shared_preferences.dart';
|
||||
|
||||
|
||||
class SearchHistory {
|
||||
final String name;
|
||||
final String targetRouter;
|
||||
|
@ -7,17 +7,18 @@ class StoryModel {
|
||||
StoryModel(this.id, this.title, {this.image, this.url});
|
||||
|
||||
StoryModel.fromJson(Map<String, dynamic> json)
|
||||
: this(json['id'], json['title'],
|
||||
image: json['image'] != null ? json['image'] : (json['images'] != null ? json['images'][0] : null),
|
||||
url: json['url'] != null ? json['url'] : (json['url'] != null ? json['url'][0] : null),
|
||||
: this(
|
||||
json['id'],
|
||||
json['title'],
|
||||
image: json['image'] != null
|
||||
? json['image']
|
||||
: (json['images'] != null ? json['images'][0] : null),
|
||||
url: json['url'] != null
|
||||
? json['url']
|
||||
: (json['url'] != null ? json['url'][0] : null),
|
||||
);
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
return {
|
||||
'id': id,
|
||||
'title': title,
|
||||
'image': image,
|
||||
'url':url
|
||||
};
|
||||
return {'id': id, 'title': title, 'image': image, 'url': url};
|
||||
}
|
||||
}
|
@ -39,8 +39,8 @@ class UserInfoControlModel {
|
||||
|
||||
// 插入新的缓存
|
||||
Future insert(UserInfo userInfo) {
|
||||
var result =
|
||||
sql.insert({'username': userInfo.username, 'password': userInfo.password});
|
||||
var result = sql
|
||||
.insert({'username': userInfo.username, 'password': userInfo.password});
|
||||
return result;
|
||||
}
|
||||
|
||||
@ -59,6 +59,4 @@ class UserInfoControlModel {
|
||||
Future deleteAll() async {
|
||||
return await sql.deleteAll();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@ -1,14 +1,10 @@
|
||||
|
||||
import 'dart:async';
|
||||
|
||||
import "package:flutter/material.dart";
|
||||
import "package:flutter_go/routers/application.dart";
|
||||
import 'package:flutter_go/utils/sql.dart';
|
||||
|
||||
enum treeNode {
|
||||
CategoryComponent,
|
||||
WidgetLeaf
|
||||
}
|
||||
enum treeNode { CategoryComponent, WidgetLeaf }
|
||||
|
||||
//typedef aaa
|
||||
|
||||
@ -135,6 +131,7 @@ class WidgetControlModel {
|
||||
}
|
||||
return new WidgetPoint.fromJSON(json.first);
|
||||
}
|
||||
|
||||
Future<List<WidgetPoint>> search(String name) async {
|
||||
List json = await sql.search(conditions: {'name': name});
|
||||
|
||||
@ -149,6 +146,7 @@ class WidgetControlModel {
|
||||
return widgets;
|
||||
}
|
||||
}
|
||||
|
||||
// 抽象类
|
||||
abstract class CommonItem<T> {
|
||||
int id;
|
||||
@ -179,19 +177,17 @@ class CategoryComponent extends CommonItem {
|
||||
CommonItem parent;
|
||||
String token;
|
||||
|
||||
|
||||
List<CommonItem> children = [];
|
||||
|
||||
String type = 'category';
|
||||
|
||||
CategoryComponent({
|
||||
@required this.id,
|
||||
CategoryComponent(
|
||||
{@required this.id,
|
||||
@required this.name,
|
||||
@required this.parentId,
|
||||
this.type = 'categoryw',
|
||||
this.children,
|
||||
this.parent
|
||||
});
|
||||
this.parent});
|
||||
CategoryComponent.fromJson(Map json) {
|
||||
if (json['id'] != null && json['id'].runtimeType == String) {
|
||||
this.id = int.parse(json['id']);
|
||||
@ -206,21 +202,19 @@ class CategoryComponent extends CommonItem {
|
||||
if (item is CategoryComponent) {
|
||||
CategoryComponent cate = item;
|
||||
cate.parent = this;
|
||||
this.children.add(
|
||||
cate
|
||||
);
|
||||
this.children.add(cate);
|
||||
}
|
||||
if (item is WidgetLeaf) {
|
||||
WidgetLeaf widget = item;
|
||||
widget.parent = this;
|
||||
this.children.add(
|
||||
widget
|
||||
);
|
||||
this.children.add(widget);
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
CommonItem getChild(String token) {
|
||||
return children.firstWhere((CommonItem item) => item.token == token, orElse: () => null);
|
||||
return children.firstWhere((CommonItem item) => item.token == token,
|
||||
orElse: () => null);
|
||||
}
|
||||
|
||||
@override
|
||||
@ -260,14 +254,13 @@ class WidgetLeaf extends CommonItem {
|
||||
CommonItem parent;
|
||||
|
||||
String type = 'widget';
|
||||
WidgetLeaf({
|
||||
@required this.id,
|
||||
WidgetLeaf(
|
||||
{@required this.id,
|
||||
@required this.name,
|
||||
@required this.display,
|
||||
this.author,
|
||||
this.path,
|
||||
this.pageId
|
||||
});
|
||||
this.pageId});
|
||||
|
||||
WidgetLeaf.fromJson(Map json) {
|
||||
if (json['id'] != null && json['id'].runtimeType == String) {
|
||||
@ -286,6 +279,7 @@ class WidgetLeaf extends CommonItem {
|
||||
CommonItem getChild(String token) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@override
|
||||
addChildren(Object item) {
|
||||
// TODO: implement addChildren
|
||||
@ -304,7 +298,8 @@ class WidgetTree {
|
||||
if (parent != null) {
|
||||
current = parent;
|
||||
} else {
|
||||
current = CategoryComponent(id: 0, name: 'root', parentId: null, children: []);
|
||||
current =
|
||||
CategoryComponent(id: 0, name: 'root', parentId: null, children: []);
|
||||
}
|
||||
json.forEach((item) {
|
||||
// 归属分类级别
|
||||
@ -357,10 +352,13 @@ class WidgetTree {
|
||||
});
|
||||
return list;
|
||||
}
|
||||
static CategoryComponent getCommonItemById(List<int> path, CategoryComponent root) {
|
||||
|
||||
static CategoryComponent getCommonItemById(
|
||||
List<int> path, CategoryComponent root) {
|
||||
print("getCommonItemByPath $path");
|
||||
print("root $root");
|
||||
CommonItem childLeaf;
|
||||
|
||||
/// int first = path.first;
|
||||
path = path.sublist(1);
|
||||
print("path:::: $path");
|
||||
@ -368,7 +366,6 @@ class WidgetTree {
|
||||
// childLeaf = root.getChild(path.first);
|
||||
}
|
||||
|
||||
|
||||
return childLeaf;
|
||||
}
|
||||
}
|
@ -8,8 +8,4 @@
|
||||
|
||||
import 'src/index.dart';
|
||||
|
||||
var demoWidgets = [
|
||||
new Demo()
|
||||
];
|
||||
|
||||
|
||||
var demoWidgets = [new Demo()];
|
||||
|
@ -3,7 +3,6 @@ import 'dart:math';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:pull_to_refresh/pull_to_refresh.dart';
|
||||
|
||||
|
||||
class Demo extends StatefulWidget {
|
||||
@override
|
||||
_State createState() => _State();
|
||||
@ -37,32 +36,35 @@ class _PulltorefreshState extends State<Pulltorefresh> {
|
||||
|
||||
void _onLoading() async {
|
||||
await Future.delayed(Duration(milliseconds: 1500));
|
||||
ItemModel model=ItemModel(getRandomColor(), Icons.airplanemode_active, "军事新闻", "俄军大秀战略",
|
||||
"酝酿已久的俄罗斯“中部-2019”战略演习于16日正式启动", 5000);
|
||||
ItemModel model = ItemModel(getRandomColor(), Icons.airplanemode_active,
|
||||
"军事新闻", "俄军大秀战略", "酝酿已久的俄罗斯“中部-2019”战略演习于16日正式启动", 5000);
|
||||
|
||||
this.datas.add(Item(getRandomColor(), model.icon, model.mainTitle, model.subTitle, model.des, model.readCount));
|
||||
this.datas.add(Item(getRandomColor(), model.icon, model.mainTitle, model.subTitle, model.des, model.readCount));
|
||||
this.datas.add(Item(getRandomColor(), model.icon, model.mainTitle, model.subTitle, model.des, model.readCount));
|
||||
this.datas.add(Item(getRandomColor(), model.icon, model.mainTitle, model.subTitle, model.des, model.readCount));
|
||||
this.datas.add(Item(getRandomColor(), model.icon, model.mainTitle, model.subTitle, model.des, model.readCount));
|
||||
this.datas.add(Item(getRandomColor(), model.icon, model.mainTitle, model.subTitle, model.des, model.readCount));
|
||||
this.datas.add(Item(getRandomColor(), model.icon, model.mainTitle, model.subTitle, model.des, model.readCount));
|
||||
this.datas.add(Item(getRandomColor(), model.icon, model.mainTitle, model.subTitle, model.des, model.readCount));
|
||||
if(mounted)
|
||||
setState(() {
|
||||
|
||||
});
|
||||
this.datas.add(Item(getRandomColor(), model.icon, model.mainTitle,
|
||||
model.subTitle, model.des, model.readCount));
|
||||
this.datas.add(Item(getRandomColor(), model.icon, model.mainTitle,
|
||||
model.subTitle, model.des, model.readCount));
|
||||
this.datas.add(Item(getRandomColor(), model.icon, model.mainTitle,
|
||||
model.subTitle, model.des, model.readCount));
|
||||
this.datas.add(Item(getRandomColor(), model.icon, model.mainTitle,
|
||||
model.subTitle, model.des, model.readCount));
|
||||
this.datas.add(Item(getRandomColor(), model.icon, model.mainTitle,
|
||||
model.subTitle, model.des, model.readCount));
|
||||
this.datas.add(Item(getRandomColor(), model.icon, model.mainTitle,
|
||||
model.subTitle, model.des, model.readCount));
|
||||
this.datas.add(Item(getRandomColor(), model.icon, model.mainTitle,
|
||||
model.subTitle, model.des, model.readCount));
|
||||
this.datas.add(Item(getRandomColor(), model.icon, model.mainTitle,
|
||||
model.subTitle, model.des, model.readCount));
|
||||
if (mounted) setState(() {});
|
||||
_controller.loadComplete();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
|
||||
Widget _itemBuilder(BuildContext context, int position) {
|
||||
|
||||
return Card(child: this.datas[position]);
|
||||
|
||||
}
|
||||
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
title: Text("Pulltorefresh"),
|
||||
@ -78,30 +80,29 @@ class _PulltorefreshState extends State<Pulltorefresh> {
|
||||
onRefresh: _onRefresh,
|
||||
onLoading: _onLoading,
|
||||
controller: _controller,
|
||||
child: ListView.builder(itemBuilder: _itemBuilder,itemCount: this.datas.length),
|
||||
|
||||
|
||||
child: ListView.builder(
|
||||
itemBuilder: _itemBuilder, itemCount: this.datas.length),
|
||||
),
|
||||
|
||||
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
Color getRandomColor() {
|
||||
List<Color> colors=[Colors.deepOrange,Colors.amber,Colors.cyan,Colors.green,Colors.red,Colors.yellow];
|
||||
List<Color> colors = [
|
||||
Colors.deepOrange,
|
||||
Colors.amber,
|
||||
Colors.cyan,
|
||||
Colors.green,
|
||||
Colors.red,
|
||||
Colors.yellow
|
||||
];
|
||||
int randomValue = Random().nextInt(colors.length);
|
||||
if (randomValue == colors.length) {
|
||||
randomValue = colors.length - 1;
|
||||
}
|
||||
return colors[randomValue];
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
class Item extends StatelessWidget {
|
||||
Color color;
|
||||
IconData icon;
|
||||
@ -202,40 +203,44 @@ class ItemModel{
|
||||
set color(Color value) {
|
||||
_color = value;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
class ListData {
|
||||
static List<Widget> getList() {
|
||||
List<Widget> models = [];
|
||||
ItemModel model1= ItemModel(Colors.red, Icons.airplanemode_active, "军事新闻", "俄军大秀战略",
|
||||
"酝酿已久的俄罗斯“中部-2019”战略演习于16日正式启动", 2999);
|
||||
ItemModel model2= ItemModel(Colors.red, Icons.airplanemode_active, "军事新闻", "俄“中部”演习",
|
||||
"俄罗斯卫星网报道称,俄罗斯国防部长绍伊古表示,“中央-2019”战略演习是", 4588);
|
||||
ItemModel model3= ItemModel(Colors.red, Icons.airplanemode_active, "军事新闻", "中国2.7万吨坞登舰",
|
||||
"据印度新德里电视台16日报道,印度海军发现7艘中国军舰在印度洋", 7777);
|
||||
ItemModel model4= ItemModel(Colors.red, Icons.airplanemode_active, "军事新闻", "针对中国?",
|
||||
"美国空军着力打造军用5G网络,5G+VR,飞行员无需上天就能操控战机;美军濒海", 8888);
|
||||
ItemModel model5= ItemModel(Colors.red, Icons.airplanemode_active, "军事新闻", "“凯旋”防空导弹系统",
|
||||
"俄罗斯卫星通讯社报道,俄罗斯北方舰队(Russian Northern Fleet)新闻处", 9999);
|
||||
ItemModel model6= ItemModel(Colors.red, Icons.airplanemode_active, "军事新闻", "火箭军还有骑兵连",
|
||||
"迅速对禁区“敌特分子”活动区域进行侦察定位,战斗小分队", 104754);
|
||||
ItemModel model7= ItemModel(Colors.red, Icons.airplanemode_active, "军事新闻", "侦察兵跨越冰川",
|
||||
"在海拔5000多米的雪域高原,第77集团军某合成旅的侦察兵们正在进行野外驻训", 47545);
|
||||
ItemModel model8= ItemModel(Colors.red, Icons.airplanemode_active, "军事新闻", "香港被护商船",
|
||||
"新京报快讯 据北海舰队官微消息:“感谢海军!”“祖国万岁!”,当地时", 124574);
|
||||
ItemModel model1 = ItemModel(Colors.red, Icons.airplanemode_active, "军事新闻",
|
||||
"俄军大秀战略", "酝酿已久的俄罗斯“中部-2019”战略演习于16日正式启动", 2999);
|
||||
ItemModel model2 = ItemModel(Colors.red, Icons.airplanemode_active, "军事新闻",
|
||||
"俄“中部”演习", "俄罗斯卫星网报道称,俄罗斯国防部长绍伊古表示,“中央-2019”战略演习是", 4588);
|
||||
ItemModel model3 = ItemModel(Colors.red, Icons.airplanemode_active, "军事新闻",
|
||||
"中国2.7万吨坞登舰", "据印度新德里电视台16日报道,印度海军发现7艘中国军舰在印度洋", 7777);
|
||||
ItemModel model4 = ItemModel(Colors.red, Icons.airplanemode_active, "军事新闻",
|
||||
"针对中国?", "美国空军着力打造军用5G网络,5G+VR,飞行员无需上天就能操控战机;美军濒海", 8888);
|
||||
ItemModel model5 = ItemModel(Colors.red, Icons.airplanemode_active, "军事新闻",
|
||||
"“凯旋”防空导弹系统", "俄罗斯卫星通讯社报道,俄罗斯北方舰队(Russian Northern Fleet)新闻处", 9999);
|
||||
ItemModel model6 = ItemModel(Colors.red, Icons.airplanemode_active, "军事新闻",
|
||||
"火箭军还有骑兵连", "迅速对禁区“敌特分子”活动区域进行侦察定位,战斗小分队", 104754);
|
||||
ItemModel model7 = ItemModel(Colors.red, Icons.airplanemode_active, "军事新闻",
|
||||
"侦察兵跨越冰川", "在海拔5000多米的雪域高原,第77集团军某合成旅的侦察兵们正在进行野外驻训", 47545);
|
||||
ItemModel model8 = ItemModel(Colors.red, Icons.airplanemode_active, "军事新闻",
|
||||
"香港被护商船", "新京报快讯 据北海舰队官微消息:“感谢海军!”“祖国万岁!”,当地时", 124574);
|
||||
|
||||
models.add(Item(model1.color, model1.icon, model1.mainTitle, model1.subTitle, model1.des, model1.readCount));
|
||||
models.add(Item(model2.color, model2.icon, model2.mainTitle, model2.subTitle, model2.des, model2.readCount));
|
||||
models.add(Item(model3.color, model3.icon, model3.mainTitle, model3.subTitle, model3.des, model3.readCount));
|
||||
models.add(Item(model4.color, model4.icon, model4.mainTitle, model4.subTitle, model4.des, model4.readCount));
|
||||
models.add(Item(model5.color, model5.icon, model5.mainTitle, model5.subTitle, model5.des, model5.readCount));
|
||||
models.add(Item(model6.color, model6.icon, model6.mainTitle, model6.subTitle, model6.des, model6.readCount));
|
||||
models.add(Item(model7.color, model7.icon, model7.mainTitle, model7.subTitle, model7.des, model7.readCount));
|
||||
models.add(Item(model8.color, model8.icon, model8.mainTitle, model8.subTitle, model8.des, model8.readCount));
|
||||
models.add(Item(model1.color, model1.icon, model1.mainTitle,
|
||||
model1.subTitle, model1.des, model1.readCount));
|
||||
models.add(Item(model2.color, model2.icon, model2.mainTitle,
|
||||
model2.subTitle, model2.des, model2.readCount));
|
||||
models.add(Item(model3.color, model3.icon, model3.mainTitle,
|
||||
model3.subTitle, model3.des, model3.readCount));
|
||||
models.add(Item(model4.color, model4.icon, model4.mainTitle,
|
||||
model4.subTitle, model4.des, model4.readCount));
|
||||
models.add(Item(model5.color, model5.icon, model5.mainTitle,
|
||||
model5.subTitle, model5.des, model5.readCount));
|
||||
models.add(Item(model6.color, model6.icon, model6.mainTitle,
|
||||
model6.subTitle, model6.des, model6.readCount));
|
||||
models.add(Item(model7.color, model7.icon, model7.mainTitle,
|
||||
model7.subTitle, model7.des, model7.readCount));
|
||||
models.add(Item(model8.color, model8.icon, model8.mainTitle,
|
||||
model8.subTitle, model8.des, model8.readCount));
|
||||
return models;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -8,8 +8,4 @@
|
||||
|
||||
import 'src/index.dart';
|
||||
|
||||
var demoWidgets = [
|
||||
new Demo()
|
||||
];
|
||||
|
||||
|
||||
var demoWidgets = [new Demo()];
|
||||
|
@ -8,8 +8,4 @@
|
||||
|
||||
import 'src/index.dart';
|
||||
|
||||
var demoWidgets = [
|
||||
new Demo()
|
||||
];
|
||||
|
||||
|
||||
var demoWidgets = [new Demo()];
|
||||
|
@ -9,8 +9,6 @@ class _State extends State<Demo> {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Container(
|
||||
child: RaisedButton(onPressed: () {}, child: Text('我是md中引入的demo'))
|
||||
);
|
||||
child: RaisedButton(onPressed: () {}, child: Text('我是md中引入的demo')));
|
||||
}
|
||||
}
|
||||
|
@ -1,10 +1,20 @@
|
||||
import 'PullToRefresh_chenfeihu_5553db80_52ae_4241_9c8a_5c9e1f92b096/index.dart' as StandardDemo_PullToRefresh_5553db80_52ae_4241_9c8a_5c9e1f92b096;
|
||||
import 'RangeSlider_RangeSlider_e5f958bc_52ae_4241_9c8a_5c9e1f92b096/index.dart' as StandardDemo_RangeSlider_e5f958bc_52ae_4241_9c8a_5c9e1f92b096;
|
||||
import 'demoName_yourName_1a29aa8e_32ae_4241_9c8a_5c9e1f92b096/index.dart' as StandardDemo_demoName_1a29aa8e_32ae_4241_9c8a_5c9e1f92b096;
|
||||
import 'local_ab_2c1d57d0_42ae_4241_9c8a_5c9e1f92b096/index.dart' as StandardDemo_local_2c1d57d0_42ae_4241_9c8a_5c9e1f92b096;
|
||||
import 'PullToRefresh_chenfeihu_5553db80_52ae_4241_9c8a_5c9e1f92b096/index.dart'
|
||||
as StandardDemo_PullToRefresh_5553db80_52ae_4241_9c8a_5c9e1f92b096;
|
||||
import 'RangeSlider_RangeSlider_e5f958bc_52ae_4241_9c8a_5c9e1f92b096/index.dart'
|
||||
as StandardDemo_RangeSlider_e5f958bc_52ae_4241_9c8a_5c9e1f92b096;
|
||||
import 'demoName_yourName_1a29aa8e_32ae_4241_9c8a_5c9e1f92b096/index.dart'
|
||||
as StandardDemo_demoName_1a29aa8e_32ae_4241_9c8a_5c9e1f92b096;
|
||||
import 'local_ab_2c1d57d0_42ae_4241_9c8a_5c9e1f92b096/index.dart'
|
||||
as StandardDemo_local_2c1d57d0_42ae_4241_9c8a_5c9e1f92b096;
|
||||
|
||||
var demoObjects = {
|
||||
'5553db80_52ae_4241_9c8a_5c9e1f92b096': StandardDemo_PullToRefresh_5553db80_52ae_4241_9c8a_5c9e1f92b096.demoWidgets,
|
||||
'e5f958bc_52ae_4241_9c8a_5c9e1f92b096': StandardDemo_RangeSlider_e5f958bc_52ae_4241_9c8a_5c9e1f92b096.demoWidgets,
|
||||
'1a29aa8e_32ae_4241_9c8a_5c9e1f92b096': StandardDemo_demoName_1a29aa8e_32ae_4241_9c8a_5c9e1f92b096.demoWidgets,
|
||||
'2c1d57d0_42ae_4241_9c8a_5c9e1f92b096': StandardDemo_local_2c1d57d0_42ae_4241_9c8a_5c9e1f92b096.demoWidgets
|
||||
'5553db80_52ae_4241_9c8a_5c9e1f92b096':
|
||||
StandardDemo_PullToRefresh_5553db80_52ae_4241_9c8a_5c9e1f92b096
|
||||
.demoWidgets,
|
||||
'e5f958bc_52ae_4241_9c8a_5c9e1f92b096':
|
||||
StandardDemo_RangeSlider_e5f958bc_52ae_4241_9c8a_5c9e1f92b096.demoWidgets,
|
||||
'1a29aa8e_32ae_4241_9c8a_5c9e1f92b096':
|
||||
StandardDemo_demoName_1a29aa8e_32ae_4241_9c8a_5c9e1f92b096.demoWidgets,
|
||||
'2c1d57d0_42ae_4241_9c8a_5c9e1f92b096':
|
||||
StandardDemo_local_2c1d57d0_42ae_4241_9c8a_5c9e1f92b096.demoWidgets
|
||||
};
|
@ -8,8 +8,4 @@
|
||||
|
||||
import 'src/index.dart';
|
||||
|
||||
var demoWidgets = [
|
||||
new Demo()
|
||||
];
|
||||
|
||||
|
||||
var demoWidgets = [new Demo()];
|
||||
|
@ -13,4 +13,3 @@ class _State extends State<Demo> {
|
||||
);
|
||||
}
|
||||
}
|
||||
|
File diff suppressed because one or more lines are too long
@ -1,4 +1,3 @@
|
||||
|
||||
// Created with Android Studio.
|
||||
// User: 三帆
|
||||
// Date: 31/01/2019
|
||||
@ -7,7 +6,6 @@
|
||||
// target: xxx
|
||||
//
|
||||
|
||||
|
||||
//enum DateType {
|
||||
// Int,
|
||||
// Double,
|
||||
@ -27,6 +25,7 @@ class SharedPreferencesKeys {
|
||||
/// boolean
|
||||
/// 用于欢迎页面. 只有第一次访问才会显示. 或者手动将这个值设为false
|
||||
static String showWelcome = 'loginWelcone';
|
||||
|
||||
/// json
|
||||
/// 用于存放搜索页的搜索数据.
|
||||
/// [{
|
||||
@ -35,4 +34,3 @@ class SharedPreferencesKeys {
|
||||
/// }]
|
||||
static String searchHistory = 'searchHistory';
|
||||
}
|
||||
|
||||
|
@ -1,4 +1,5 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
class WidgetName2Icon {
|
||||
static Map<String, dynamic> icons = {
|
||||
"Developer": Icons.developer_mode,
|
||||
|
@ -3,10 +3,12 @@ import 'package:fluro/fluro.dart';
|
||||
import 'package:flutter_go/utils/shared_preferences.dart';
|
||||
|
||||
import '../model/widget.dart';
|
||||
|
||||
enum ENV {
|
||||
PRODUCTION,
|
||||
DEV,
|
||||
}
|
||||
|
||||
class Application {
|
||||
/// 通过Application设计环境变量
|
||||
static ENV env = ENV.DEV;
|
||||
@ -18,7 +20,8 @@ class Application {
|
||||
static bool pageIsOpen = false;
|
||||
|
||||
static Map<String, String> github = {
|
||||
'widgetsURL':'https://github.com/alibaba/flutter-go/blob/develop/lib/widgets/',
|
||||
'widgetsURL':
|
||||
'https://github.com/alibaba/flutter-go/blob/develop/lib/widgets/',
|
||||
//'develop':'https://github.com/alibaba-paimai-frontend/flutter-common-widgets-app/tree/develop/lib/widgets/',
|
||||
//'master':'https://github.com/alibaba-paimai-frontend/flutter-common-widgets-app/tree/master/lib/widgets/'
|
||||
};
|
||||
@ -33,5 +36,4 @@ class Application {
|
||||
}
|
||||
return {};
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -24,15 +24,13 @@ var collectionFullHandler = new Handler(
|
||||
handlerFunc: (BuildContext context, Map<String, List<String>> params) {
|
||||
bool hasLogined = params['hasLogin']?.first == 'true';
|
||||
return CollectionFullPage(hasLogined: hasLogined);
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
var collectionHandler = new Handler(
|
||||
handlerFunc: (BuildContext context, Map<String, List<String>> params) {
|
||||
bool hasLogined = params['hasLogin']?.first == 'true';
|
||||
return CollectionPage(hasLogined: hasLogined);
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
var categoryHandler = new Handler(
|
||||
handlerFunc: (BuildContext context, Map<String, List<String>> params) {
|
||||
@ -59,7 +57,6 @@ var fullScreenCodeDialog = new Handler(
|
||||
);
|
||||
});
|
||||
|
||||
|
||||
var githubCodeDialog = new Handler(
|
||||
handlerFunc: (BuildContext context, Map<String, List<String>> params) {
|
||||
String path = params['remotePath']?.first;
|
||||
@ -75,14 +72,11 @@ var webViewPageHand = new Handler(
|
||||
return new WebViewPage(url, title);
|
||||
});
|
||||
|
||||
|
||||
var standardPageHandler = new Handler(
|
||||
handlerFunc: (BuildContext context, Map<String, List<String>> params) {
|
||||
String id = params['id']?.first;
|
||||
return StandardView(id: id);
|
||||
}
|
||||
);
|
||||
|
||||
});
|
||||
|
||||
var issuesMessageHandler = new Handler(
|
||||
handlerFunc: (BuildContext context, Map<String, List<String>> params) {
|
||||
|
@ -1,9 +1,9 @@
|
||||
|
||||
import 'package:fluro/fluro.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_go/utils/analytics.dart' show analytics;
|
||||
import '../widgets/index.dart';
|
||||
import './router_handler.dart';
|
||||
|
||||
/// import '../standard_pages/index.dart';
|
||||
class Routes {
|
||||
static String root = "/";
|
||||
@ -36,11 +36,11 @@ class Routes {
|
||||
router.define(issuesMessage, handler: issuesMessageHandler);
|
||||
router.define(standardPage, handler: standardPageHandler);
|
||||
widgetDemosList.forEach((demo) {
|
||||
Handler handler = new Handler(
|
||||
handlerFunc: (BuildContext context, Map<String, List<String>> params) {
|
||||
Handler handler = new Handler(handlerFunc:
|
||||
(BuildContext context, Map<String, List<String>> params) {
|
||||
print('组件路由params=$params widgetsItem=${demo.routerName}');
|
||||
analytics.logEvent(
|
||||
name: 'component', parameters: {'name': demo.routerName });
|
||||
analytics
|
||||
.logEvent(name: 'component', parameters: {'name': demo.routerName});
|
||||
return demo.buildRouter(context);
|
||||
});
|
||||
String path = demo.routerName;
|
||||
|
@ -83,5 +83,4 @@ PullToRefresh 是一个刷新列表组件,借助于pull_to_refresh库实现,
|
||||
|
||||
|
||||
""";
|
||||
|
||||
}
|
||||
|
@ -30,7 +30,4 @@ slider 用来选择连续性的或者非连续性的数据. 默认是在一段
|
||||
### 实例展示
|
||||
|
||||
[demo:e5f958bc_52ae_4241_9c8a_5c9e1f92b096]""";
|
||||
|
||||
|
||||
}
|
||||
|
@ -1,45 +1,77 @@
|
||||
import 'PullToRefresh_chenfeihu_cd9b8b80_52ae_4241_9c8a_5c9e1f92b096/index.dart'
|
||||
as StandardPage_PullToRefresh_cd9b8b80_52ae_4241_9c8a_5c9e1f92b096;
|
||||
import 'local_hnaxu_5d7178d0_42ae_4241_9c8a_5c9e1f92b096/index.dart'
|
||||
as StandardPage_local_5d7178d0_42ae_4241_9c8a_5c9e1f92b096;
|
||||
import 'test_abc_84f38e00_42ae_4241_9c8a_5c9e1f92b096/index.dart'
|
||||
as StandardPage_test_84f38e00_42ae_4241_9c8a_5c9e1f92b096;
|
||||
import 'standard_sanfan_ee4feb8e_32ae_4241_9c8a_5c9e1f92b096/index.dart'
|
||||
as StandardPage_standard_ee4feb8e_32ae_4241_9c8a_5c9e1f92b096;
|
||||
import 'standard_for_slider_sanfan_8ab2b5c2_42ae_4241_9c8a_5c9e1f92b096/index.dart'
|
||||
as StandardPage_standard_for_slider_8ab2b5c2_42ae_4241_9c8a_5c9e1f92b096;
|
||||
import 'RangeSlider_hanxu_cbffbf7c_52ae_4241_9c8a_5c9e1f92b096/index.dart'
|
||||
as StandardPage_RangeSlider_cbffbf7c_52ae_4241_9c8a_5c9e1f92b096;
|
||||
|
||||
import 'PullToRefresh_chenfeihu_cd9b8b80_52ae_4241_9c8a_5c9e1f92b096/index.dart' as StandardPage_PullToRefresh_cd9b8b80_52ae_4241_9c8a_5c9e1f92b096;
|
||||
import 'local_hnaxu_5d7178d0_42ae_4241_9c8a_5c9e1f92b096/index.dart' as StandardPage_local_5d7178d0_42ae_4241_9c8a_5c9e1f92b096;
|
||||
import 'test_abc_84f38e00_42ae_4241_9c8a_5c9e1f92b096/index.dart' as StandardPage_test_84f38e00_42ae_4241_9c8a_5c9e1f92b096;
|
||||
import 'standard_sanfan_ee4feb8e_32ae_4241_9c8a_5c9e1f92b096/index.dart' as StandardPage_standard_ee4feb8e_32ae_4241_9c8a_5c9e1f92b096;
|
||||
import 'standard_for_slider_sanfan_8ab2b5c2_42ae_4241_9c8a_5c9e1f92b096/index.dart' as StandardPage_standard_for_slider_8ab2b5c2_42ae_4241_9c8a_5c9e1f92b096;
|
||||
import 'RangeSlider_hanxu_cbffbf7c_52ae_4241_9c8a_5c9e1f92b096/index.dart' as StandardPage_RangeSlider_cbffbf7c_52ae_4241_9c8a_5c9e1f92b096;
|
||||
class StandardPages {
|
||||
Map<String, String> standardPages;
|
||||
Map<String, String> getPages() {
|
||||
return {
|
||||
"0": "0",
|
||||
"cd9b8b80_52ae_4241_9c8a_5c9e1f92b096" : StandardPage_PullToRefresh_cd9b8b80_52ae_4241_9c8a_5c9e1f92b096.getMd()
|
||||
,
|
||||
"5d7178d0_42ae_4241_9c8a_5c9e1f92b096" : StandardPage_local_5d7178d0_42ae_4241_9c8a_5c9e1f92b096.getMd()
|
||||
,
|
||||
"84f38e00_42ae_4241_9c8a_5c9e1f92b096" : StandardPage_test_84f38e00_42ae_4241_9c8a_5c9e1f92b096.getMd()
|
||||
,
|
||||
"ee4feb8e_32ae_4241_9c8a_5c9e1f92b096" : StandardPage_standard_ee4feb8e_32ae_4241_9c8a_5c9e1f92b096.getMd()
|
||||
,
|
||||
"8ab2b5c2_42ae_4241_9c8a_5c9e1f92b096" : StandardPage_standard_for_slider_8ab2b5c2_42ae_4241_9c8a_5c9e1f92b096.getMd()
|
||||
,
|
||||
"cbffbf7c_52ae_4241_9c8a_5c9e1f92b096" : StandardPage_RangeSlider_cbffbf7c_52ae_4241_9c8a_5c9e1f92b096.getMd()
|
||||
"cd9b8b80_52ae_4241_9c8a_5c9e1f92b096":
|
||||
StandardPage_PullToRefresh_cd9b8b80_52ae_4241_9c8a_5c9e1f92b096
|
||||
.getMd(),
|
||||
"5d7178d0_42ae_4241_9c8a_5c9e1f92b096":
|
||||
StandardPage_local_5d7178d0_42ae_4241_9c8a_5c9e1f92b096.getMd(),
|
||||
"84f38e00_42ae_4241_9c8a_5c9e1f92b096":
|
||||
StandardPage_test_84f38e00_42ae_4241_9c8a_5c9e1f92b096.getMd(),
|
||||
"ee4feb8e_32ae_4241_9c8a_5c9e1f92b096":
|
||||
StandardPage_standard_ee4feb8e_32ae_4241_9c8a_5c9e1f92b096.getMd(),
|
||||
"8ab2b5c2_42ae_4241_9c8a_5c9e1f92b096":
|
||||
StandardPage_standard_for_slider_8ab2b5c2_42ae_4241_9c8a_5c9e1f92b096
|
||||
.getMd(),
|
||||
"cbffbf7c_52ae_4241_9c8a_5c9e1f92b096":
|
||||
StandardPage_RangeSlider_cbffbf7c_52ae_4241_9c8a_5c9e1f92b096.getMd()
|
||||
};
|
||||
}
|
||||
|
||||
List<Map<String, String>> getLocalList() {
|
||||
return [
|
||||
{},
|
||||
{ "id": "cd9b8b80_52ae_4241_9c8a_5c9e1f92b096", "name": "PullToRefresh", "email": "763551832@qq.com", "author": "chenfeihu"}
|
||||
,
|
||||
{ "id": "5d7178d0_42ae_4241_9c8a_5c9e1f92b096", "name": "local", "email": "hanxu@qq.com", "author": "hnaxu"}
|
||||
,
|
||||
{ "id": "84f38e00_42ae_4241_9c8a_5c9e1f92b096", "name": "test", "email": "adsf.com", "author": "abc"}
|
||||
,
|
||||
{ "id": "ee4feb8e_32ae_4241_9c8a_5c9e1f92b096", "name": "standard", "email": "hanxu317@qq.com", "author": "sanfan"}
|
||||
,
|
||||
{ "id": "8ab2b5c2_42ae_4241_9c8a_5c9e1f92b096", "name": "standard_for_slider", "email": "hanxu@qq.com", "author": "sanfan"}
|
||||
,
|
||||
{ "id": "cbffbf7c_52ae_4241_9c8a_5c9e1f92b096", "name": "RangeSlider", "email": "hanxu317@qq.com", "author": "hanxu"}
|
||||
{
|
||||
"id": "cd9b8b80_52ae_4241_9c8a_5c9e1f92b096",
|
||||
"name": "PullToRefresh",
|
||||
"email": "763551832@qq.com",
|
||||
"author": "chenfeihu"
|
||||
},
|
||||
{
|
||||
"id": "5d7178d0_42ae_4241_9c8a_5c9e1f92b096",
|
||||
"name": "local",
|
||||
"email": "hanxu@qq.com",
|
||||
"author": "hnaxu"
|
||||
},
|
||||
{
|
||||
"id": "84f38e00_42ae_4241_9c8a_5c9e1f92b096",
|
||||
"name": "test",
|
||||
"email": "adsf.com",
|
||||
"author": "abc"
|
||||
},
|
||||
{
|
||||
"id": "ee4feb8e_32ae_4241_9c8a_5c9e1f92b096",
|
||||
"name": "standard",
|
||||
"email": "hanxu317@qq.com",
|
||||
"author": "sanfan"
|
||||
},
|
||||
{
|
||||
"id": "8ab2b5c2_42ae_4241_9c8a_5c9e1f92b096",
|
||||
"name": "standard_for_slider",
|
||||
"email": "hanxu@qq.com",
|
||||
"author": "sanfan"
|
||||
},
|
||||
{
|
||||
"id": "cbffbf7c_52ae_4241_9c8a_5c9e1f92b096",
|
||||
"name": "RangeSlider",
|
||||
"email": "hanxu317@qq.com",
|
||||
"author": "hanxu"
|
||||
}
|
||||
];
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
@ -48,5 +48,4 @@ goCLi createDemo
|
||||
```
|
||||
[demo: 1a29aa8e_32ae_4241_9c8a_5c9e1f92b096]
|
||||
```""";
|
||||
|
||||
}
|
||||
|
@ -55,7 +55,4 @@ goCLi createDemo
|
||||
调用效果:
|
||||
|
||||
[demo:1a29aa8e_32ae_4241_9c8a_5c9e1f92b096]""";
|
||||
|
||||
|
||||
}
|
||||
|
@ -50,7 +50,4 @@ goCLi createDemo
|
||||
```
|
||||
[demo: 1a29aa8e_32ae_4241_9c8a_5c9e1f92b096]
|
||||
```""";
|
||||
|
||||
|
||||
}
|
||||
|
@ -48,5 +48,4 @@ goCLi createDemo
|
||||
```
|
||||
[demo: 1a29aa8e_32ae_4241_9c8a_5c9e1f92b096]
|
||||
```""";
|
||||
|
||||
}
|
||||
|
@ -5,6 +5,7 @@ import 'package:flutter_go/model/collection.dart';
|
||||
import 'package:flutter_go/model/version.dart';
|
||||
import 'package:flutter_go/model/widget.dart';
|
||||
import 'package:package_info/package_info.dart';
|
||||
|
||||
/// import 'package:flutter_go/model/responseData.dart';
|
||||
|
||||
import './net_utils.dart';
|
||||
@ -190,7 +191,9 @@ class DataUtils {
|
||||
"name": json['name'],
|
||||
"cnName": json['name'],
|
||||
"routerName": routerName,
|
||||
"catId": json['parentId'].runtimeType == String ? int.parse(json['parentId']) : json['parentId']
|
||||
"catId": json['parentId'].runtimeType == String
|
||||
? int.parse(json['parentId'])
|
||||
: json['parentId']
|
||||
};
|
||||
list.add(WidgetPoint.fromJSON(tempMap));
|
||||
}
|
||||
|
@ -11,7 +11,6 @@ import 'package:flutter/material.dart';
|
||||
|
||||
import 'package:flutter_go/routers/application.dart';
|
||||
|
||||
|
||||
Map<String, String> _exampleCode;
|
||||
String _code;
|
||||
|
||||
@ -23,12 +22,14 @@ void _launchURL(String url) async {
|
||||
}
|
||||
}
|
||||
|
||||
Future<String> getExampleCode(context,String filePath, AssetBundle bundle) async {
|
||||
Future<String> getExampleCode(
|
||||
context, String filePath, AssetBundle bundle) async {
|
||||
if (_exampleCode == null) await _parseExampleCode(context, filePath, bundle);
|
||||
return _code;
|
||||
}
|
||||
|
||||
Future<void> _parseExampleCode(context,String filePath, AssetBundle bundle) async {
|
||||
Future<void> _parseExampleCode(
|
||||
context, String filePath, AssetBundle bundle) async {
|
||||
String code;
|
||||
try {
|
||||
code = await bundle.loadString('lib/widgets/$filePath');
|
||||
|
@ -9,16 +9,15 @@ import 'package:string_scanner/string_scanner.dart';
|
||||
/// DartSyntaxHighlighter(style).format(source)
|
||||
|
||||
class SyntaxHighlighterStyle {
|
||||
SyntaxHighlighterStyle({
|
||||
this.baseStyle,
|
||||
SyntaxHighlighterStyle(
|
||||
{this.baseStyle,
|
||||
this.numberStyle,
|
||||
this.commentStyle,
|
||||
this.keywordStyle,
|
||||
this.stringStyle,
|
||||
this.punctuationStyle,
|
||||
this.classStyle,
|
||||
this.constantStyle
|
||||
});
|
||||
this.constantStyle});
|
||||
|
||||
static SyntaxHighlighterStyle lightThemeStyle() {
|
||||
return SyntaxHighlighterStyle(
|
||||
@ -29,8 +28,7 @@ class SyntaxHighlighterStyle {
|
||||
stringStyle: const TextStyle(color: Color(0xFF43A047)),
|
||||
punctuationStyle: const TextStyle(color: Color(0xFF000000)),
|
||||
classStyle: const TextStyle(color: Color(0xFF512DA8)),
|
||||
constantStyle: const TextStyle(color: Color(0xFF795548))
|
||||
);
|
||||
constantStyle: const TextStyle(color: Color(0xFF795548)));
|
||||
}
|
||||
|
||||
static SyntaxHighlighterStyle darkThemeStyle() {
|
||||
@ -42,8 +40,7 @@ class SyntaxHighlighterStyle {
|
||||
stringStyle: const TextStyle(color: Color(0xFF009688)),
|
||||
punctuationStyle: const TextStyle(color: Color(0xFFFFFFFF)),
|
||||
classStyle: const TextStyle(color: Color(0xFF009688)),
|
||||
constantStyle: const TextStyle(color: Color(0xFF795548))
|
||||
);
|
||||
constantStyle: const TextStyle(color: Color(0xFF795548)));
|
||||
}
|
||||
|
||||
final TextStyle baseStyle;
|
||||
@ -56,7 +53,8 @@ class SyntaxHighlighterStyle {
|
||||
final TextStyle constantStyle;
|
||||
}
|
||||
|
||||
abstract class Highlighter { // ignore: one_member_abstracts
|
||||
abstract class Highlighter {
|
||||
// ignore: one_member_abstracts
|
||||
TextSpan format(String src);
|
||||
}
|
||||
|
||||
@ -69,17 +67,66 @@ class DartSyntaxHighlighter extends Highlighter {
|
||||
SyntaxHighlighterStyle _style;
|
||||
|
||||
static const List<String> _keywords = <String>[
|
||||
'abstract', 'as', 'assert', 'async', 'await', 'break', 'case', 'catch',
|
||||
'class', 'const', 'continue', 'default', 'deferred', 'do', 'dynamic', 'else',
|
||||
'enum', 'export', 'external', 'extends', 'factory', 'false', 'final',
|
||||
'finally', 'for', 'get', 'if', 'implements', 'import', 'in', 'is', 'library',
|
||||
'new', 'null', 'operator', 'part', 'rethrow', 'return', 'set', 'static',
|
||||
'super', 'switch', 'sync', 'this', 'throw', 'true', 'try', 'typedef', 'var',
|
||||
'void', 'while', 'with', 'yield'
|
||||
'abstract',
|
||||
'as',
|
||||
'assert',
|
||||
'async',
|
||||
'await',
|
||||
'break',
|
||||
'case',
|
||||
'catch',
|
||||
'class',
|
||||
'const',
|
||||
'continue',
|
||||
'default',
|
||||
'deferred',
|
||||
'do',
|
||||
'dynamic',
|
||||
'else',
|
||||
'enum',
|
||||
'export',
|
||||
'external',
|
||||
'extends',
|
||||
'factory',
|
||||
'false',
|
||||
'final',
|
||||
'finally',
|
||||
'for',
|
||||
'get',
|
||||
'if',
|
||||
'implements',
|
||||
'import',
|
||||
'in',
|
||||
'is',
|
||||
'library',
|
||||
'new',
|
||||
'null',
|
||||
'operator',
|
||||
'part',
|
||||
'rethrow',
|
||||
'return',
|
||||
'set',
|
||||
'static',
|
||||
'super',
|
||||
'switch',
|
||||
'sync',
|
||||
'this',
|
||||
'throw',
|
||||
'true',
|
||||
'try',
|
||||
'typedef',
|
||||
'var',
|
||||
'void',
|
||||
'while',
|
||||
'with',
|
||||
'yield'
|
||||
];
|
||||
|
||||
static const List<String> _builtInTypes = <String>[
|
||||
'int', 'double', 'num', 'bool'
|
||||
'int',
|
||||
'double',
|
||||
'num',
|
||||
'bool'
|
||||
];
|
||||
|
||||
String _src;
|
||||
@ -99,15 +146,18 @@ class DartSyntaxHighlighter extends Highlighter {
|
||||
|
||||
for (_HighlightSpan span in _spans) {
|
||||
if (currentPosition != span.start)
|
||||
formattedText.add(TextSpan(text: _src.substring(currentPosition, span.start)));
|
||||
formattedText
|
||||
.add(TextSpan(text: _src.substring(currentPosition, span.start)));
|
||||
|
||||
formattedText.add(TextSpan(style: span.textStyle(_style), text: span.textForSpan(_src)));
|
||||
formattedText.add(TextSpan(
|
||||
style: span.textStyle(_style), text: span.textForSpan(_src)));
|
||||
|
||||
currentPosition = span.end;
|
||||
}
|
||||
|
||||
if (currentPosition != _src.length)
|
||||
formattedText.add(TextSpan(text: _src.substring(currentPosition, _src.length)));
|
||||
formattedText
|
||||
.add(TextSpan(text: _src.substring(currentPosition, _src.length)));
|
||||
|
||||
return TextSpan(style: _style.baseStyle, children: formattedText);
|
||||
} else {
|
||||
@ -125,11 +175,8 @@ class DartSyntaxHighlighter extends Highlighter {
|
||||
|
||||
// Block comments
|
||||
if (_scanner.scan(RegExp(r'/\*(.|\n)*\*/'))) {
|
||||
_spans.add(_HighlightSpan(
|
||||
_HighlightType.comment,
|
||||
_scanner.lastMatch.start,
|
||||
_scanner.lastMatch.end
|
||||
));
|
||||
_spans.add(_HighlightSpan(_HighlightType.comment,
|
||||
_scanner.lastMatch.start, _scanner.lastMatch.end));
|
||||
continue;
|
||||
}
|
||||
|
||||
@ -146,115 +193,81 @@ class DartSyntaxHighlighter extends Highlighter {
|
||||
endComment = _src.length;
|
||||
}
|
||||
|
||||
_spans.add(_HighlightSpan(
|
||||
_HighlightType.comment,
|
||||
startComment,
|
||||
endComment
|
||||
));
|
||||
_spans.add(
|
||||
_HighlightSpan(_HighlightType.comment, startComment, endComment));
|
||||
|
||||
if (eof)
|
||||
break;
|
||||
if (eof) break;
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
// Raw r"String"
|
||||
if (_scanner.scan(RegExp(r'r".*"'))) {
|
||||
_spans.add(_HighlightSpan(
|
||||
_HighlightType.string,
|
||||
_scanner.lastMatch.start,
|
||||
_scanner.lastMatch.end
|
||||
));
|
||||
_spans.add(_HighlightSpan(_HighlightType.string,
|
||||
_scanner.lastMatch.start, _scanner.lastMatch.end));
|
||||
continue;
|
||||
}
|
||||
|
||||
// Raw r'String'
|
||||
if (_scanner.scan(RegExp(r"r'.*'"))) {
|
||||
_spans.add(_HighlightSpan(
|
||||
_HighlightType.string,
|
||||
_scanner.lastMatch.start,
|
||||
_scanner.lastMatch.end
|
||||
));
|
||||
_spans.add(_HighlightSpan(_HighlightType.string,
|
||||
_scanner.lastMatch.start, _scanner.lastMatch.end));
|
||||
continue;
|
||||
}
|
||||
|
||||
// Multiline """String"""
|
||||
if (_scanner.scan(RegExp(r'"""(?:[^"\\]|\\(.|\n))*"""'))) {
|
||||
_spans.add(_HighlightSpan(
|
||||
_HighlightType.string,
|
||||
_scanner.lastMatch.start,
|
||||
_scanner.lastMatch.end
|
||||
));
|
||||
_spans.add(_HighlightSpan(_HighlightType.string,
|
||||
_scanner.lastMatch.start, _scanner.lastMatch.end));
|
||||
continue;
|
||||
}
|
||||
|
||||
// Multiline '''String'''
|
||||
if (_scanner.scan(RegExp(r"'''(?:[^'\\]|\\(.|\n))*'''"))) {
|
||||
_spans.add(_HighlightSpan(
|
||||
_HighlightType.string,
|
||||
_scanner.lastMatch.start,
|
||||
_scanner.lastMatch.end
|
||||
));
|
||||
_spans.add(_HighlightSpan(_HighlightType.string,
|
||||
_scanner.lastMatch.start, _scanner.lastMatch.end));
|
||||
continue;
|
||||
}
|
||||
|
||||
// "String"
|
||||
if (_scanner.scan(RegExp(r'"(?:[^"\\]|\\.)*"'))) {
|
||||
_spans.add(_HighlightSpan(
|
||||
_HighlightType.string,
|
||||
_scanner.lastMatch.start,
|
||||
_scanner.lastMatch.end
|
||||
));
|
||||
_spans.add(_HighlightSpan(_HighlightType.string,
|
||||
_scanner.lastMatch.start, _scanner.lastMatch.end));
|
||||
continue;
|
||||
}
|
||||
|
||||
// 'String'
|
||||
if (_scanner.scan(RegExp(r"'(?:[^'\\]|\\.)*'"))) {
|
||||
_spans.add(_HighlightSpan(
|
||||
_HighlightType.string,
|
||||
_scanner.lastMatch.start,
|
||||
_scanner.lastMatch.end
|
||||
));
|
||||
_spans.add(_HighlightSpan(_HighlightType.string,
|
||||
_scanner.lastMatch.start, _scanner.lastMatch.end));
|
||||
continue;
|
||||
}
|
||||
|
||||
// Double
|
||||
if (_scanner.scan(RegExp(r'\d+\.\d+'))) {
|
||||
_spans.add(_HighlightSpan(
|
||||
_HighlightType.number,
|
||||
_scanner.lastMatch.start,
|
||||
_scanner.lastMatch.end
|
||||
));
|
||||
_spans.add(_HighlightSpan(_HighlightType.number,
|
||||
_scanner.lastMatch.start, _scanner.lastMatch.end));
|
||||
continue;
|
||||
}
|
||||
|
||||
// Integer
|
||||
if (_scanner.scan(RegExp(r'\d+'))) {
|
||||
_spans.add(_HighlightSpan(
|
||||
_HighlightType.number,
|
||||
_scanner.lastMatch.start,
|
||||
_scanner.lastMatch.end)
|
||||
);
|
||||
_spans.add(_HighlightSpan(_HighlightType.number,
|
||||
_scanner.lastMatch.start, _scanner.lastMatch.end));
|
||||
continue;
|
||||
}
|
||||
|
||||
// Punctuation
|
||||
if (_scanner.scan(RegExp(r'[\[\]{}().!=<>&\|\?\+\-\*/%\^~;:,]'))) {
|
||||
_spans.add(_HighlightSpan(
|
||||
_HighlightType.punctuation,
|
||||
_scanner.lastMatch.start,
|
||||
_scanner.lastMatch.end
|
||||
));
|
||||
_spans.add(_HighlightSpan(_HighlightType.punctuation,
|
||||
_scanner.lastMatch.start, _scanner.lastMatch.end));
|
||||
continue;
|
||||
}
|
||||
|
||||
// Meta data
|
||||
if (_scanner.scan(RegExp(r'@\w+'))) {
|
||||
_spans.add(_HighlightSpan(
|
||||
_HighlightType.keyword,
|
||||
_scanner.lastMatch.start,
|
||||
_scanner.lastMatch.end
|
||||
));
|
||||
_spans.add(_HighlightSpan(_HighlightType.keyword,
|
||||
_scanner.lastMatch.start, _scanner.lastMatch.end));
|
||||
continue;
|
||||
}
|
||||
|
||||
@ -263,8 +276,7 @@ class DartSyntaxHighlighter extends Highlighter {
|
||||
_HighlightType type;
|
||||
|
||||
String word = _scanner.lastMatch[0];
|
||||
if (word.startsWith('_'))
|
||||
word = word.substring(1);
|
||||
if (word.startsWith('_')) word = word.substring(1);
|
||||
|
||||
if (_keywords.contains(word))
|
||||
type = _HighlightType.keyword;
|
||||
@ -272,15 +284,14 @@ class DartSyntaxHighlighter extends Highlighter {
|
||||
type = _HighlightType.keyword;
|
||||
else if (_firstLetterIsUpperCase(word))
|
||||
type = _HighlightType.klass;
|
||||
else if (word.length >= 2 && word.startsWith('k') && _firstLetterIsUpperCase(word.substring(1)))
|
||||
else if (word.length >= 2 &&
|
||||
word.startsWith('k') &&
|
||||
_firstLetterIsUpperCase(word.substring(1)))
|
||||
type = _HighlightType.constant;
|
||||
|
||||
if (type != null) {
|
||||
_spans.add(_HighlightSpan(
|
||||
type,
|
||||
_scanner.lastMatch.start,
|
||||
_scanner.lastMatch.end
|
||||
));
|
||||
type, _scanner.lastMatch.start, _scanner.lastMatch.end));
|
||||
}
|
||||
}
|
||||
|
||||
@ -298,12 +309,10 @@ class DartSyntaxHighlighter extends Highlighter {
|
||||
|
||||
void _simplify() {
|
||||
for (int i = _spans.length - 2; i >= 0; i -= 1) {
|
||||
if (_spans[i].type == _spans[i + 1].type && _spans[i].end == _spans[i + 1].start) {
|
||||
_spans[i] = _HighlightSpan(
|
||||
_spans[i].type,
|
||||
_spans[i].start,
|
||||
_spans[i + 1].end
|
||||
);
|
||||
if (_spans[i].type == _spans[i + 1].type &&
|
||||
_spans[i].end == _spans[i + 1].start) {
|
||||
_spans[i] =
|
||||
_HighlightSpan(_spans[i].type, _spans[i].start, _spans[i + 1].end);
|
||||
_spans.removeAt(i + 1);
|
||||
}
|
||||
}
|
||||
|
@ -32,7 +32,8 @@ class Provider {
|
||||
if (db == null) {
|
||||
return Future.value([]);
|
||||
}
|
||||
List tables = await db.rawQuery('SELECT name FROM sqlite_master WHERE type = "table"');
|
||||
List tables = await db
|
||||
.rawQuery('SELECT name FROM sqlite_master WHERE type = "table"');
|
||||
List<String> targetList = [];
|
||||
tables.forEach((item) {
|
||||
targetList.add(item['name']);
|
||||
@ -52,7 +53,6 @@ class Provider {
|
||||
}
|
||||
}
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
//初始化数据库
|
||||
@ -89,5 +89,4 @@ class Provider {
|
||||
print("Opening existing database");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,4 +1,3 @@
|
||||
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:shared_preferences/shared_preferences.dart';
|
||||
@ -14,7 +13,6 @@ class SpUtil {
|
||||
|
||||
static SharedPreferences _spf;
|
||||
|
||||
|
||||
SpUtil._();
|
||||
|
||||
Future _init() async {
|
||||
@ -37,6 +35,7 @@ class SpUtil {
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
// 判断是否存在数据
|
||||
bool hasKey(String key) {
|
||||
Set keys = getKeys();
|
||||
@ -107,8 +106,6 @@ class SpUtil {
|
||||
return _spf.get(key);
|
||||
}
|
||||
|
||||
|
||||
|
||||
Future<bool> remove(String key) {
|
||||
if (_beforeCheck()) return null;
|
||||
return _spf.remove(key);
|
||||
|
@ -1,5 +1,3 @@
|
||||
|
||||
|
||||
import 'package:sqflite/sqflite.dart';
|
||||
|
||||
import './provider.dart';
|
||||
@ -23,12 +21,15 @@ class Sql extends BaseModel {
|
||||
Future<List> get() async {
|
||||
return await this.query(tableName);
|
||||
}
|
||||
|
||||
String getTableName() {
|
||||
return tableName;
|
||||
}
|
||||
|
||||
Future<int> delete(String value, String key) async {
|
||||
return await this.db.delete(tableName,where:'$key = ?',whereArgs:[value]);
|
||||
return await this
|
||||
.db
|
||||
.delete(tableName, where: '$key = ?', whereArgs: [value]);
|
||||
}
|
||||
|
||||
Future<int> deleteAll() async {
|
||||
@ -61,18 +62,21 @@ class Sql extends BaseModel {
|
||||
// print("this is string condition for sql > $stringConditions");
|
||||
return await this.query(tableName, where: stringConditions);
|
||||
}
|
||||
|
||||
Future<Map<String, dynamic>> insert(Map<String, dynamic> json) async {
|
||||
var id = await this.db.insert(tableName, json);
|
||||
json['id'] = id;
|
||||
return json;
|
||||
}
|
||||
|
||||
///
|
||||
/// 搜索
|
||||
/// @param Object condition
|
||||
/// @mods [And, Or] default is Or
|
||||
/// search({'name': "hanxu', 'id': 1};
|
||||
///
|
||||
Future<List> search({Map<String, dynamic> conditions, String mods = 'Or'}) async {
|
||||
Future<List> search(
|
||||
{Map<String, dynamic> conditions, String mods = 'Or'}) async {
|
||||
if (conditions == null || conditions.isEmpty) {
|
||||
return this.get();
|
||||
}
|
||||
|
@ -21,9 +21,9 @@ class AppText{
|
||||
fontSize: middleSize,
|
||||
);
|
||||
}
|
||||
|
||||
class WidgetDemoColor {
|
||||
static const int fontColor = 0xFF607173;
|
||||
static const int iconColor = 0xFF607173;
|
||||
static const int borderColor = 0xFFEFEFEF;
|
||||
|
||||
}
|
||||
|
@ -7,16 +7,15 @@ import 'package:flutter/material.dart';
|
||||
import 'package:string_scanner/string_scanner.dart';
|
||||
|
||||
class SyntaxHighlighterStyle {
|
||||
SyntaxHighlighterStyle({
|
||||
this.baseStyle,
|
||||
SyntaxHighlighterStyle(
|
||||
{this.baseStyle,
|
||||
this.numberStyle,
|
||||
this.commentStyle,
|
||||
this.keywordStyle,
|
||||
this.stringStyle,
|
||||
this.punctuationStyle,
|
||||
this.classStyle,
|
||||
this.constantStyle
|
||||
});
|
||||
this.constantStyle});
|
||||
|
||||
static SyntaxHighlighterStyle lightThemeStyle() {
|
||||
return SyntaxHighlighterStyle(
|
||||
@ -27,8 +26,7 @@ class SyntaxHighlighterStyle {
|
||||
stringStyle: const TextStyle(color: Color(0xFF43A047)),
|
||||
punctuationStyle: const TextStyle(color: Color(0xFF000000)),
|
||||
classStyle: const TextStyle(color: Color(0xFF512DA8)),
|
||||
constantStyle: const TextStyle(color: Color(0xFF795548))
|
||||
);
|
||||
constantStyle: const TextStyle(color: Color(0xFF795548)));
|
||||
}
|
||||
|
||||
static SyntaxHighlighterStyle darkThemeStyle() {
|
||||
@ -40,8 +38,7 @@ class SyntaxHighlighterStyle {
|
||||
stringStyle: const TextStyle(color: Color(0xFF009688)),
|
||||
punctuationStyle: const TextStyle(color: Color(0xFFFFFFFF)),
|
||||
classStyle: const TextStyle(color: Color(0xFF009688)),
|
||||
constantStyle: const TextStyle(color: Color(0xFF795548))
|
||||
);
|
||||
constantStyle: const TextStyle(color: Color(0xFF795548)));
|
||||
}
|
||||
|
||||
final TextStyle baseStyle;
|
||||
@ -54,7 +51,8 @@ class SyntaxHighlighterStyle {
|
||||
final TextStyle constantStyle;
|
||||
}
|
||||
|
||||
abstract class SyntaxHighlighter { // ignore: one_member_abstracts
|
||||
abstract class SyntaxHighlighter {
|
||||
// ignore: one_member_abstracts
|
||||
TextSpan format(String src);
|
||||
}
|
||||
|
||||
@ -67,17 +65,66 @@ class DartSyntaxHighlighter extends SyntaxHighlighter {
|
||||
SyntaxHighlighterStyle _style;
|
||||
|
||||
static const List<String> _keywords = <String>[
|
||||
'abstract', 'as', 'assert', 'async', 'await', 'break', 'case', 'catch',
|
||||
'class', 'const', 'continue', 'default', 'deferred', 'do', 'dynamic', 'else',
|
||||
'enum', 'export', 'external', 'extends', 'factory', 'false', 'final',
|
||||
'finally', 'for', 'get', 'if', 'implements', 'import', 'in', 'is', 'library',
|
||||
'new', 'null', 'operator', 'part', 'rethrow', 'return', 'set', 'static',
|
||||
'super', 'switch', 'sync', 'this', 'throw', 'true', 'try', 'typedef', 'var',
|
||||
'void', 'while', 'with', 'yield'
|
||||
'abstract',
|
||||
'as',
|
||||
'assert',
|
||||
'async',
|
||||
'await',
|
||||
'break',
|
||||
'case',
|
||||
'catch',
|
||||
'class',
|
||||
'const',
|
||||
'continue',
|
||||
'default',
|
||||
'deferred',
|
||||
'do',
|
||||
'dynamic',
|
||||
'else',
|
||||
'enum',
|
||||
'export',
|
||||
'external',
|
||||
'extends',
|
||||
'factory',
|
||||
'false',
|
||||
'final',
|
||||
'finally',
|
||||
'for',
|
||||
'get',
|
||||
'if',
|
||||
'implements',
|
||||
'import',
|
||||
'in',
|
||||
'is',
|
||||
'library',
|
||||
'new',
|
||||
'null',
|
||||
'operator',
|
||||
'part',
|
||||
'rethrow',
|
||||
'return',
|
||||
'set',
|
||||
'static',
|
||||
'super',
|
||||
'switch',
|
||||
'sync',
|
||||
'this',
|
||||
'throw',
|
||||
'true',
|
||||
'try',
|
||||
'typedef',
|
||||
'var',
|
||||
'void',
|
||||
'while',
|
||||
'with',
|
||||
'yield'
|
||||
];
|
||||
|
||||
static const List<String> _builtInTypes = <String>[
|
||||
'int', 'double', 'num', 'bool'
|
||||
'int',
|
||||
'double',
|
||||
'num',
|
||||
'bool'
|
||||
];
|
||||
|
||||
String _src;
|
||||
@ -97,15 +144,18 @@ class DartSyntaxHighlighter extends SyntaxHighlighter {
|
||||
|
||||
for (_HighlightSpan span in _spans) {
|
||||
if (currentPosition != span.start)
|
||||
formattedText.add(TextSpan(text: _src.substring(currentPosition, span.start)));
|
||||
formattedText
|
||||
.add(TextSpan(text: _src.substring(currentPosition, span.start)));
|
||||
|
||||
formattedText.add(TextSpan(style: span.textStyle(_style), text: span.textForSpan(_src)));
|
||||
formattedText.add(TextSpan(
|
||||
style: span.textStyle(_style), text: span.textForSpan(_src)));
|
||||
|
||||
currentPosition = span.end;
|
||||
}
|
||||
|
||||
if (currentPosition != _src.length)
|
||||
formattedText.add(TextSpan(text: _src.substring(currentPosition, _src.length)));
|
||||
formattedText
|
||||
.add(TextSpan(text: _src.substring(currentPosition, _src.length)));
|
||||
|
||||
return TextSpan(style: _style.baseStyle, children: formattedText);
|
||||
} else {
|
||||
@ -123,11 +173,8 @@ class DartSyntaxHighlighter extends SyntaxHighlighter {
|
||||
|
||||
// Block comments
|
||||
if (_scanner.scan(RegExp(r'/\*(.|\n)*\*/'))) {
|
||||
_spans.add(_HighlightSpan(
|
||||
_HighlightType.comment,
|
||||
_scanner.lastMatch.start,
|
||||
_scanner.lastMatch.end
|
||||
));
|
||||
_spans.add(_HighlightSpan(_HighlightType.comment,
|
||||
_scanner.lastMatch.start, _scanner.lastMatch.end));
|
||||
continue;
|
||||
}
|
||||
|
||||
@ -144,115 +191,81 @@ class DartSyntaxHighlighter extends SyntaxHighlighter {
|
||||
endComment = _src.length;
|
||||
}
|
||||
|
||||
_spans.add(_HighlightSpan(
|
||||
_HighlightType.comment,
|
||||
startComment,
|
||||
endComment
|
||||
));
|
||||
_spans.add(
|
||||
_HighlightSpan(_HighlightType.comment, startComment, endComment));
|
||||
|
||||
if (eof)
|
||||
break;
|
||||
if (eof) break;
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
// Raw r"String"
|
||||
if (_scanner.scan(RegExp(r'r".*"'))) {
|
||||
_spans.add(_HighlightSpan(
|
||||
_HighlightType.string,
|
||||
_scanner.lastMatch.start,
|
||||
_scanner.lastMatch.end
|
||||
));
|
||||
_spans.add(_HighlightSpan(_HighlightType.string,
|
||||
_scanner.lastMatch.start, _scanner.lastMatch.end));
|
||||
continue;
|
||||
}
|
||||
|
||||
// Raw r'String'
|
||||
if (_scanner.scan(RegExp(r"r'.*'"))) {
|
||||
_spans.add(_HighlightSpan(
|
||||
_HighlightType.string,
|
||||
_scanner.lastMatch.start,
|
||||
_scanner.lastMatch.end
|
||||
));
|
||||
_spans.add(_HighlightSpan(_HighlightType.string,
|
||||
_scanner.lastMatch.start, _scanner.lastMatch.end));
|
||||
continue;
|
||||
}
|
||||
|
||||
// Multiline """String"""
|
||||
if (_scanner.scan(RegExp(r'"""(?:[^"\\]|\\(.|\n))*"""'))) {
|
||||
_spans.add(_HighlightSpan(
|
||||
_HighlightType.string,
|
||||
_scanner.lastMatch.start,
|
||||
_scanner.lastMatch.end
|
||||
));
|
||||
_spans.add(_HighlightSpan(_HighlightType.string,
|
||||
_scanner.lastMatch.start, _scanner.lastMatch.end));
|
||||
continue;
|
||||
}
|
||||
|
||||
// Multiline '''String'''
|
||||
if (_scanner.scan(RegExp(r"'''(?:[^'\\]|\\(.|\n))*'''"))) {
|
||||
_spans.add(_HighlightSpan(
|
||||
_HighlightType.string,
|
||||
_scanner.lastMatch.start,
|
||||
_scanner.lastMatch.end
|
||||
));
|
||||
_spans.add(_HighlightSpan(_HighlightType.string,
|
||||
_scanner.lastMatch.start, _scanner.lastMatch.end));
|
||||
continue;
|
||||
}
|
||||
|
||||
// "String"
|
||||
if (_scanner.scan(RegExp(r'"(?:[^"\\]|\\.)*"'))) {
|
||||
_spans.add(_HighlightSpan(
|
||||
_HighlightType.string,
|
||||
_scanner.lastMatch.start,
|
||||
_scanner.lastMatch.end
|
||||
));
|
||||
_spans.add(_HighlightSpan(_HighlightType.string,
|
||||
_scanner.lastMatch.start, _scanner.lastMatch.end));
|
||||
continue;
|
||||
}
|
||||
|
||||
// 'String'
|
||||
if (_scanner.scan(RegExp(r"'(?:[^'\\]|\\.)*'"))) {
|
||||
_spans.add(_HighlightSpan(
|
||||
_HighlightType.string,
|
||||
_scanner.lastMatch.start,
|
||||
_scanner.lastMatch.end
|
||||
));
|
||||
_spans.add(_HighlightSpan(_HighlightType.string,
|
||||
_scanner.lastMatch.start, _scanner.lastMatch.end));
|
||||
continue;
|
||||
}
|
||||
|
||||
// Double
|
||||
if (_scanner.scan(RegExp(r'\d+\.\d+'))) {
|
||||
_spans.add(_HighlightSpan(
|
||||
_HighlightType.number,
|
||||
_scanner.lastMatch.start,
|
||||
_scanner.lastMatch.end
|
||||
));
|
||||
_spans.add(_HighlightSpan(_HighlightType.number,
|
||||
_scanner.lastMatch.start, _scanner.lastMatch.end));
|
||||
continue;
|
||||
}
|
||||
|
||||
// Integer
|
||||
if (_scanner.scan(RegExp(r'\d+'))) {
|
||||
_spans.add(_HighlightSpan(
|
||||
_HighlightType.number,
|
||||
_scanner.lastMatch.start,
|
||||
_scanner.lastMatch.end)
|
||||
);
|
||||
_spans.add(_HighlightSpan(_HighlightType.number,
|
||||
_scanner.lastMatch.start, _scanner.lastMatch.end));
|
||||
continue;
|
||||
}
|
||||
|
||||
// Punctuation
|
||||
if (_scanner.scan(RegExp(r'[\[\]{}().!=<>&\|\?\+\-\*/%\^~;:,]'))) {
|
||||
_spans.add(_HighlightSpan(
|
||||
_HighlightType.punctuation,
|
||||
_scanner.lastMatch.start,
|
||||
_scanner.lastMatch.end
|
||||
));
|
||||
_spans.add(_HighlightSpan(_HighlightType.punctuation,
|
||||
_scanner.lastMatch.start, _scanner.lastMatch.end));
|
||||
continue;
|
||||
}
|
||||
|
||||
// Meta data
|
||||
if (_scanner.scan(RegExp(r'@\w+'))) {
|
||||
_spans.add(_HighlightSpan(
|
||||
_HighlightType.keyword,
|
||||
_scanner.lastMatch.start,
|
||||
_scanner.lastMatch.end
|
||||
));
|
||||
_spans.add(_HighlightSpan(_HighlightType.keyword,
|
||||
_scanner.lastMatch.start, _scanner.lastMatch.end));
|
||||
continue;
|
||||
}
|
||||
|
||||
@ -261,8 +274,7 @@ class DartSyntaxHighlighter extends SyntaxHighlighter {
|
||||
_HighlightType type;
|
||||
|
||||
String word = _scanner.lastMatch[0];
|
||||
if (word.startsWith('_'))
|
||||
word = word.substring(1);
|
||||
if (word.startsWith('_')) word = word.substring(1);
|
||||
|
||||
if (_keywords.contains(word))
|
||||
type = _HighlightType.keyword;
|
||||
@ -270,15 +282,14 @@ class DartSyntaxHighlighter extends SyntaxHighlighter {
|
||||
type = _HighlightType.keyword;
|
||||
else if (_firstLetterIsUpperCase(word))
|
||||
type = _HighlightType.klass;
|
||||
else if (word.length >= 2 && word.startsWith('k') && _firstLetterIsUpperCase(word.substring(1)))
|
||||
else if (word.length >= 2 &&
|
||||
word.startsWith('k') &&
|
||||
_firstLetterIsUpperCase(word.substring(1)))
|
||||
type = _HighlightType.constant;
|
||||
|
||||
if (type != null) {
|
||||
_spans.add(_HighlightSpan(
|
||||
type,
|
||||
_scanner.lastMatch.start,
|
||||
_scanner.lastMatch.end
|
||||
));
|
||||
type, _scanner.lastMatch.start, _scanner.lastMatch.end));
|
||||
}
|
||||
}
|
||||
|
||||
@ -296,12 +307,10 @@ class DartSyntaxHighlighter extends SyntaxHighlighter {
|
||||
|
||||
void _simplify() {
|
||||
for (int i = _spans.length - 2; i >= 0; i -= 1) {
|
||||
if (_spans[i].type == _spans[i + 1].type && _spans[i].end == _spans[i + 1].start) {
|
||||
_spans[i] = _HighlightSpan(
|
||||
_spans[i].type,
|
||||
_spans[i].start,
|
||||
_spans[i + 1].end
|
||||
);
|
||||
if (_spans[i].type == _spans[i + 1].type &&
|
||||
_spans[i].end == _spans[i + 1].start) {
|
||||
_spans[i] =
|
||||
_HighlightSpan(_spans[i].type, _spans[i].start, _spans[i + 1].end);
|
||||
_spans.removeAt(i + 1);
|
||||
}
|
||||
}
|
||||
|
@ -58,7 +58,6 @@ class _CollectionFullPageState extends State<CollectionFullPage> {
|
||||
}
|
||||
|
||||
Widget _renderList(context, index) {
|
||||
|
||||
if (index == 0) {
|
||||
return Container(
|
||||
height: 40.0,
|
||||
@ -115,8 +114,7 @@ class _CollectionFullPageState extends State<CollectionFullPage> {
|
||||
trailing:
|
||||
Icon(Icons.keyboard_arrow_right, color: Colors.grey, size: 30.0),
|
||||
onTap: () {
|
||||
Application.router.navigateTo(
|
||||
context, targetRouter.toLowerCase(),
|
||||
Application.router.navigateTo(context, targetRouter.toLowerCase(),
|
||||
transition: TransitionType.inFromRight);
|
||||
},
|
||||
),
|
||||
|
@ -11,6 +11,7 @@ import 'package:flutter_go/routers/application.dart';
|
||||
import 'package:flutter_go/routers/routers.dart';
|
||||
import 'package:flutter_go/event/event_bus.dart';
|
||||
import 'package:flutter_go/event/event_model.dart';
|
||||
|
||||
/// import 'package:flutter_go/utils/data_utils.dart';
|
||||
|
||||
class CollectionPage extends StatefulWidget {
|
||||
@ -26,6 +27,7 @@ class _CollectionPageState extends State<CollectionPage> {
|
||||
final eventBus = new EventBus();
|
||||
ApplicationEvent.event = eventBus;
|
||||
}
|
||||
|
||||
/// CollectionControlModel _collectionControl = new CollectionControlModel();
|
||||
List<Collection> _collectionList = [];
|
||||
ScrollController _scrollController = new ScrollController();
|
||||
|
@ -209,7 +209,6 @@ class _DrawerPageState extends State<DrawerPage> {
|
||||
} else {
|
||||
//No description provided.
|
||||
Application.router.navigateTo(context, '${Routes.loginPage}');
|
||||
|
||||
}
|
||||
},
|
||||
),
|
||||
|
@ -17,7 +17,8 @@ class FirstPage extends StatefulWidget {
|
||||
FirstPageState createState() => new FirstPageState();
|
||||
}
|
||||
|
||||
class FirstPageState extends State<FirstPage> with AutomaticKeepAliveClientMixin{
|
||||
class FirstPageState extends State<FirstPage>
|
||||
with AutomaticKeepAliveClientMixin {
|
||||
Future<SharedPreferences> _prefs = SharedPreferences.getInstance();
|
||||
Future<bool> _unKnow;
|
||||
GlobalKey<DisclaimerMsgState> key;
|
||||
@ -25,7 +26,6 @@ class FirstPageState extends State<FirstPage> with AutomaticKeepAliveClientMixin
|
||||
@override
|
||||
bool get wantKeepAlive => true;
|
||||
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
@ -40,7 +40,9 @@ class FirstPageState extends State<FirstPage> with AutomaticKeepAliveClientMixin
|
||||
/// 判断是否需要弹出免责声明,已经勾选过不在显示,就不会主动弹
|
||||
_unKnow.then((bool value) {
|
||||
new Future.delayed(const Duration(seconds: 1), () {
|
||||
if (!value && key.currentState is DisclaimerMsgState && key.currentState.showAlertDialog is Function) {
|
||||
if (!value &&
|
||||
key.currentState is DisclaimerMsgState &&
|
||||
key.currentState.showAlertDialog is Function) {
|
||||
key.currentState.showAlertDialog(context);
|
||||
}
|
||||
});
|
||||
@ -48,10 +50,10 @@ class FirstPageState extends State<FirstPage> with AutomaticKeepAliveClientMixin
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Future<Map> getIndexListData([Map<String, dynamic> params]) async {
|
||||
/// const juejin_flutter = 'https://timeline-merger-ms.juejin.im/v1/get_tag_entry?src=web&tagId=5a96291f6fb9a0535b535438';
|
||||
const juejin_flutter = 'https://fluttergo.pub:9527/juejin.im/v1/get_tag_entry?src=web&tagId=5a96291f6fb9a0535b535438';
|
||||
const juejin_flutter =
|
||||
'https://fluttergo.pub:9527/juejin.im/v1/get_tag_entry?src=web&tagId=5a96291f6fb9a0535b535438';
|
||||
|
||||
var pageIndex = (params is Map) ? params['pageIndex'] : 0;
|
||||
final _param = {'page': pageIndex, 'pageSize': 20, 'sort': 'rankIndex'};
|
||||
@ -65,9 +67,7 @@ class FirstPageState extends State<FirstPage> with AutomaticKeepAliveClientMixin
|
||||
if (!(pageTotal is int) || pageTotal <= 0) {
|
||||
pageTotal = 0;
|
||||
}
|
||||
}catch(e){
|
||||
|
||||
}
|
||||
} catch (e) {}
|
||||
pageIndex += 1;
|
||||
List resultList = new List();
|
||||
for (int i = 0; i < responseList.length; i++) {
|
||||
@ -78,7 +78,11 @@ class FirstPageState extends State<FirstPage> with AutomaticKeepAliveClientMixin
|
||||
// No specified type, handles all
|
||||
}
|
||||
}
|
||||
Map<String, dynamic> result = {"list":resultList, 'total':pageTotal, 'pageIndex':pageIndex};
|
||||
Map<String, dynamic> result = {
|
||||
"list": resultList,
|
||||
'total': pageTotal,
|
||||
'pageIndex': pageIndex
|
||||
};
|
||||
return result;
|
||||
}
|
||||
|
||||
@ -87,35 +91,37 @@ class FirstPageState extends State<FirstPage> with AutomaticKeepAliveClientMixin
|
||||
var myTitle = '${item.title}';
|
||||
var myUsername = '${'👲'}: ${item.username} ';
|
||||
var codeUrl = '${item.detailUrl}';
|
||||
return new ListViewItem(itemUrl:codeUrl,itemTitle: myTitle,data: myUsername,);
|
||||
return new ListViewItem(
|
||||
itemUrl: codeUrl,
|
||||
itemTitle: myTitle,
|
||||
data: myUsername,
|
||||
);
|
||||
}
|
||||
|
||||
headerView() {
|
||||
return
|
||||
Column(
|
||||
return Column(
|
||||
children: <Widget>[
|
||||
Stack(
|
||||
//alignment: const FractionalOffset(0.9, 0.1),//方法一
|
||||
children: <Widget>[
|
||||
Pagination(),
|
||||
Positioned(//方法二
|
||||
Positioned(
|
||||
//方法二
|
||||
top: 10.0,
|
||||
left: 0.0,
|
||||
child: DisclaimerMsg(key:key,pWidget:this)
|
||||
),
|
||||
child: DisclaimerMsg(key: key, pWidget: this)),
|
||||
]),
|
||||
SizedBox(height: 1, child:Container(color: Theme.of(context).primaryColor)),
|
||||
SizedBox(
|
||||
height: 1, child: Container(color: Theme.of(context).primaryColor)),
|
||||
SizedBox(height: 10),
|
||||
],
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
super.build(context);
|
||||
return new Column(
|
||||
children: <Widget>[
|
||||
return new Column(children: <Widget>[
|
||||
// new Stack(
|
||||
// //alignment: const FractionalOffset(0.9, 0.1),//方法一
|
||||
// children: <Widget>[
|
||||
@ -129,12 +135,7 @@ class FirstPageState extends State<FirstPage> with AutomaticKeepAliveClientMixin
|
||||
// SizedBox(height: 2, child:Container(color: Theme.of(context).primaryColor)),
|
||||
new Expanded(
|
||||
//child: new List(),
|
||||
child: listComp.ListRefresh(getIndexListData,makeCard,headerView)
|
||||
)
|
||||
]
|
||||
|
||||
);
|
||||
child: listComp.ListRefresh(getIndexListData, makeCard, headerView))
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -2,6 +2,7 @@ import 'package:flutter/material.dart';
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter_go/views/first_page/drawer_page.dart';
|
||||
import './first_page.dart';
|
||||
|
||||
/// import './sub_page.dart';
|
||||
import './main_app_bar.dart';
|
||||
import './search_page.dart';
|
||||
@ -23,6 +24,7 @@ final List<_Page> _allPages = <_Page>[
|
||||
_Page('热门资讯', 1),
|
||||
_Page('FG-官网', 2),
|
||||
_Page('FG-web版', 3),
|
||||
|
||||
///_Page('项目4'),
|
||||
];
|
||||
|
||||
@ -40,7 +42,9 @@ class MainPage extends StatelessWidget {
|
||||
leading: Container(
|
||||
child: ClipOval(
|
||||
child: Image.network(
|
||||
userInfo.id == 0?'https://hbimg.huabanimg.com/9bfa0fad3b1284d652d370fa0a8155e1222c62c0bf9d-YjG0Vt_fw658':userInfo.avatarPic,
|
||||
userInfo.id == 0
|
||||
? 'https://hbimg.huabanimg.com/9bfa0fad3b1284d652d370fa0a8155e1222c62c0bf9d-YjG0Vt_fw658'
|
||||
: userInfo.avatarPic,
|
||||
scale: 15.0,
|
||||
),
|
||||
)),
|
||||
@ -55,9 +59,7 @@ class MainPage extends StatelessWidget {
|
||||
],
|
||||
),
|
||||
drawer: Drawer(
|
||||
child: DrawerPage(
|
||||
userInfo: userInfo
|
||||
),
|
||||
child: DrawerPage(userInfo: userInfo),
|
||||
),
|
||||
body: TabBarViewLayout(),
|
||||
));
|
||||
@ -82,18 +84,18 @@ class TabLayout extends StatelessWidget {
|
||||
onTap: (index) {
|
||||
if (index == 1) {
|
||||
DefaultTabController.of(context).animateTo(0);
|
||||
Application.router.navigateTo(context, '${Routes.webViewPage}?title=${Uri.encodeComponent('Flutter Go 官方网站')}&url=${Uri.encodeComponent('https://flutter-go.pub')}');
|
||||
Application.router.navigateTo(context,
|
||||
'${Routes.webViewPage}?title=${Uri.encodeComponent('Flutter Go 官方网站')}&url=${Uri.encodeComponent('https://flutter-go.pub')}');
|
||||
} else if (index == 2) {
|
||||
|
||||
// new Future.delayed(const Duration(seconds: 1),(){
|
||||
// showAlertDialog(Application.globalContext);
|
||||
// });
|
||||
|
||||
DefaultTabController.of(context).animateTo(0);
|
||||
Application.router.navigateTo(context, '${Routes.webViewPage}?title=${Uri.encodeComponent('Flutter Go web版(H5)')}&url=${Uri.encodeComponent('https://flutter-go.pub/flutter_go_web')}');
|
||||
Application.router.navigateTo(context,
|
||||
'${Routes.webViewPage}?title=${Uri.encodeComponent('Flutter Go web版(H5)')}&url=${Uri.encodeComponent('https://flutter-go.pub/flutter_go_web')}');
|
||||
}
|
||||
}
|
||||
);
|
||||
});
|
||||
return _tabBar;
|
||||
}
|
||||
}
|
||||
|
@ -27,7 +27,8 @@ final _industryPage = Industry.IndustryPage(itemTitle: (state){
|
||||
print(state.res[index].source);
|
||||
final itemTitle = state.res[index].title;
|
||||
final itemUrl = state.res[index].source;
|
||||
Application.router.navigateTo(context, '${Routes.webViewPage}?title=${Uri.encodeComponent(itemTitle)}&url=${Uri.encodeComponent(itemUrl)}');
|
||||
Application.router.navigateTo(context,
|
||||
'${Routes.webViewPage}?title=${Uri.encodeComponent(itemTitle)}&url=${Uri.encodeComponent(itemUrl)}');
|
||||
},
|
||||
);
|
||||
},
|
||||
@ -45,8 +46,7 @@ class SearchPage extends StatelessWidget {
|
||||
return Scaffold(
|
||||
appBar: PreferredSize(
|
||||
preferredSize: Size(double.infinity, 52), // is the height
|
||||
child: AppBar(title: searchBarPage)
|
||||
),
|
||||
child: AppBar(title: searchBarPage)),
|
||||
//body: ProgressView(),
|
||||
body: _industryPage,
|
||||
floatingActionButton: FloatingActionButton(
|
||||
@ -54,7 +54,9 @@ class SearchPage extends StatelessWidget {
|
||||
onPressed: () {
|
||||
//print('searchBarPage=====>${controller.text}');
|
||||
//print('searchBarPage=====>${that.getResultsDebounced}');
|
||||
if(that is _SearchBarPageState && that.getResultsDebounced is Function && controller.text is String ) {
|
||||
if (that is _SearchBarPageState &&
|
||||
that.getResultsDebounced is Function &&
|
||||
controller.text is String) {
|
||||
that.getResultsDebounced(controller.text);
|
||||
}
|
||||
},
|
||||
@ -84,10 +86,10 @@ class SearchBarPage extends StatefulWidget{
|
||||
State<StatefulWidget> createState() => _SearchBarPageState();
|
||||
}
|
||||
|
||||
|
||||
final TextEditingController controller = TextEditingController();
|
||||
var that;
|
||||
var loading;
|
||||
|
||||
class _SearchBarPageState extends State<SearchBarPage> {
|
||||
@override
|
||||
void initState() {
|
||||
@ -99,6 +101,7 @@ class _SearchBarPageState extends State<SearchBarPage> {
|
||||
Timer _resultsTimer;
|
||||
|
||||
String oldKey;
|
||||
|
||||
/// 防抖函数
|
||||
Future getResultsDebounced(String text) async {
|
||||
if (oldKey == text) {
|
||||
@ -121,7 +124,6 @@ class _SearchBarPageState extends State<SearchBarPage> {
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
void onSearchTextChanged(String text) {
|
||||
print('onSearchTextChanged:$text');
|
||||
//suggestion.dispatch(SuggestionFetch(query: text));
|
||||
@ -136,7 +138,6 @@ class _SearchBarPageState extends State<SearchBarPage> {
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
|
||||
Widget build(BuildContext context) {
|
||||
return Container(
|
||||
color: Theme.of(context).primaryColor,
|
||||
@ -153,8 +154,14 @@ class _SearchBarPageState extends State<SearchBarPage> {
|
||||
child: Row(
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
children: <Widget>[
|
||||
SizedBox(width: 5.0,),
|
||||
Icon(Icons.search, color: Colors.grey,size: 18.0,),
|
||||
SizedBox(
|
||||
width: 5.0,
|
||||
),
|
||||
Icon(
|
||||
Icons.search,
|
||||
color: Colors.grey,
|
||||
size: 18.0,
|
||||
),
|
||||
Expanded(
|
||||
child: Container(
|
||||
alignment: Alignment.center,
|
||||
@ -164,8 +171,7 @@ class _SearchBarPageState extends State<SearchBarPage> {
|
||||
contentPadding: EdgeInsets.only(top: 0.0),
|
||||
hintText: '全网搜索 Flutter 相关知识库',
|
||||
hintStyle: TextStyle(fontSize: 12.0),
|
||||
border: InputBorder.none
|
||||
),
|
||||
border: InputBorder.none),
|
||||
onChanged: onSearchTextChanged,
|
||||
),
|
||||
),
|
||||
@ -181,9 +187,7 @@ class _SearchBarPageState extends State<SearchBarPage> {
|
||||
),
|
||||
],
|
||||
),
|
||||
)
|
||||
)
|
||||
),
|
||||
))),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
@ -25,7 +25,6 @@ class SubPageState extends State<SubPage> with AutomaticKeepAliveClientMixin{
|
||||
@override
|
||||
bool get wantKeepAlive => true;
|
||||
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
@ -40,7 +39,9 @@ class SubPageState extends State<SubPage> with AutomaticKeepAliveClientMixin{
|
||||
/// 判断是否需要弹出免责声明,已经勾选过不在显示,就不会主动弹
|
||||
_unKnow.then((bool value) {
|
||||
new Future.delayed(const Duration(seconds: 1), () {
|
||||
if (!value && key.currentState is DisclaimerMsgState && key.currentState.showAlertDialog is Function) {
|
||||
if (!value &&
|
||||
key.currentState is DisclaimerMsgState &&
|
||||
key.currentState.showAlertDialog is Function) {
|
||||
key.currentState.showAlertDialog(context);
|
||||
}
|
||||
});
|
||||
@ -48,9 +49,9 @@ class SubPageState extends State<SubPage> with AutomaticKeepAliveClientMixin{
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Future<Map> getIndexListData([Map<String, dynamic> params]) async {
|
||||
const juejin_flutter = 'https://timeline-merger-ms.juejin.im/v1/get_tag_entry?src=web&tagId=5a96291f6fb9a0535b535438';
|
||||
const juejin_flutter =
|
||||
'https://timeline-merger-ms.juejin.im/v1/get_tag_entry?src=web&tagId=5a96291f6fb9a0535b535438';
|
||||
var pageIndex = (params is Map) ? params['pageIndex'] : 0;
|
||||
final _param = {'page': pageIndex, 'pageSize': 20, 'sort': 'rankIndex'};
|
||||
var responseList = [];
|
||||
@ -63,9 +64,7 @@ class SubPageState extends State<SubPage> with AutomaticKeepAliveClientMixin{
|
||||
if (!(pageTotal is int) || pageTotal <= 0) {
|
||||
pageTotal = 0;
|
||||
}
|
||||
}catch(e){
|
||||
|
||||
}
|
||||
} catch (e) {}
|
||||
pageIndex += 1;
|
||||
List resultList = new List();
|
||||
for (int i = 0; i < responseList.length; i++) {
|
||||
@ -76,50 +75,50 @@ class SubPageState extends State<SubPage> with AutomaticKeepAliveClientMixin{
|
||||
// No specified type, handles all
|
||||
}
|
||||
}
|
||||
Map<String, dynamic> result = {"list":resultList, 'total':pageTotal, 'pageIndex':pageIndex};
|
||||
Map<String, dynamic> result = {
|
||||
"list": resultList,
|
||||
'total': pageTotal,
|
||||
'pageIndex': pageIndex
|
||||
};
|
||||
return result;
|
||||
}
|
||||
|
||||
Widget makeCard(index, item) {
|
||||
|
||||
var myTitle = '${item.title}';
|
||||
var myUsername = '${'👲'}: ${item.username} ';
|
||||
var codeUrl = '${item.detailUrl}';
|
||||
return new ListViewItem(itemUrl:codeUrl,itemTitle: myTitle,data: myUsername,);
|
||||
return new ListViewItem(
|
||||
itemUrl: codeUrl,
|
||||
itemTitle: myTitle,
|
||||
data: myUsername,
|
||||
);
|
||||
}
|
||||
|
||||
headerView() {
|
||||
return
|
||||
Column(
|
||||
return Column(
|
||||
children: <Widget>[
|
||||
Stack(
|
||||
//alignment: const FractionalOffset(0.9, 0.1),//方法一
|
||||
children: <Widget>[
|
||||
Pagination(),
|
||||
Positioned(//方法二
|
||||
Positioned(
|
||||
//方法二
|
||||
top: 10.0,
|
||||
left: 0.0,
|
||||
child: DisclaimerMsg(key:key,pWidget:this)
|
||||
),
|
||||
child: DisclaimerMsg(key: key, pWidget: this)),
|
||||
]),
|
||||
SizedBox(height: 1, child:Container(color: Theme.of(context).primaryColor)),
|
||||
SizedBox(
|
||||
height: 1, child: Container(color: Theme.of(context).primaryColor)),
|
||||
SizedBox(height: 10),
|
||||
],
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
super.build(context);
|
||||
return new Column(
|
||||
children: <Widget>[
|
||||
new Expanded(
|
||||
child: listComp.ListRefresh(getIndexListData,makeCard)
|
||||
)
|
||||
]
|
||||
);
|
||||
return new Column(children: <Widget>[
|
||||
new Expanded(child: listComp.ListRefresh(getIndexListData, makeCard))
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -1,4 +1,3 @@
|
||||
|
||||
import 'dart:async';
|
||||
import 'dart:ui';
|
||||
|
||||
@ -7,13 +6,11 @@ import 'package:flutter/material.dart';
|
||||
import 'package:flutter_go/views/fourth_page/pager_indicator.dart';
|
||||
|
||||
class PageDragger extends StatefulWidget {
|
||||
|
||||
final canDragLeftToRight;
|
||||
final canDragRightToLeft;
|
||||
|
||||
final StreamController<SlideUpdate> slideUpdateStream;
|
||||
|
||||
|
||||
PageDragger({
|
||||
this.canDragLeftToRight,
|
||||
this.canDragRightToLeft,
|
||||
@ -25,7 +22,6 @@ class PageDragger extends StatefulWidget {
|
||||
}
|
||||
|
||||
class _PageDraggerState extends State<PageDragger> {
|
||||
|
||||
static const FULL_TRANSTITION_PX = 300.0;
|
||||
|
||||
Offset dragStart;
|
||||
@ -55,22 +51,16 @@ class _PageDraggerState extends State<PageDragger> {
|
||||
slidePercent = 0.0;
|
||||
}
|
||||
widget.slideUpdateStream.add(
|
||||
new SlideUpdate(
|
||||
UpdateType.dragging,
|
||||
slideDirection,
|
||||
slidePercent
|
||||
));
|
||||
new SlideUpdate(UpdateType.dragging, slideDirection, slidePercent));
|
||||
}
|
||||
}
|
||||
|
||||
onDragEnd(DragEndDetails details) {
|
||||
widget.slideUpdateStream.add(
|
||||
new SlideUpdate(
|
||||
widget.slideUpdateStream.add(new SlideUpdate(
|
||||
UpdateType.doneDragging,
|
||||
SlideDirection.none,
|
||||
0.0,
|
||||
)
|
||||
);
|
||||
));
|
||||
|
||||
dragStart = null;
|
||||
}
|
||||
@ -86,7 +76,6 @@ class _PageDraggerState extends State<PageDragger> {
|
||||
}
|
||||
|
||||
class AnimatedPageDragger {
|
||||
|
||||
static const PERCENT_PER_MILLISECOND = 0.005;
|
||||
|
||||
final slideDirection;
|
||||
@ -111,51 +100,34 @@ class AnimatedPageDragger{
|
||||
final slideRemaining = 1.0 - slidePercent;
|
||||
|
||||
duration = new Duration(
|
||||
milliseconds: (slideRemaining / PERCENT_PER_MILLISECOND).round()
|
||||
);
|
||||
|
||||
milliseconds: (slideRemaining / PERCENT_PER_MILLISECOND).round());
|
||||
} else {
|
||||
endSlidePercent = 0.0;
|
||||
duration = new Duration(
|
||||
milliseconds: (slidePercent / PERCENT_PER_MILLISECOND).round()
|
||||
);
|
||||
milliseconds: (slidePercent / PERCENT_PER_MILLISECOND).round());
|
||||
}
|
||||
|
||||
completionAnimationController = new AnimationController(
|
||||
duration: duration,
|
||||
vsync: vsync
|
||||
)
|
||||
completionAnimationController =
|
||||
new AnimationController(duration: duration, vsync: vsync)
|
||||
..addListener(() {
|
||||
slidePercent = lerpDouble(
|
||||
startSlidePercent,
|
||||
endSlidePercent,
|
||||
completionAnimationController.value
|
||||
);
|
||||
slidePercent = lerpDouble(startSlidePercent, endSlidePercent,
|
||||
completionAnimationController.value);
|
||||
|
||||
slideUpdateStream.add(
|
||||
new SlideUpdate(
|
||||
slideUpdateStream.add(new SlideUpdate(
|
||||
UpdateType.animating,
|
||||
slideDirection,
|
||||
slidePercent,
|
||||
)
|
||||
);
|
||||
|
||||
));
|
||||
})
|
||||
|
||||
..addStatusListener((AnimationStatus status) {
|
||||
|
||||
if (status == AnimationStatus.completed) {
|
||||
slideUpdateStream.add(
|
||||
new SlideUpdate(
|
||||
slideUpdateStream.add(new SlideUpdate(
|
||||
UpdateType.doneAnimating,
|
||||
slideDirection,
|
||||
endSlidePercent,
|
||||
)
|
||||
);
|
||||
));
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
run() {
|
||||
@ -165,7 +137,6 @@ class AnimatedPageDragger{
|
||||
dispose() {
|
||||
completionAnimationController.dispose();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
enum TransitionGoal {
|
||||
@ -185,9 +156,5 @@ class SlideUpdate {
|
||||
final direction;
|
||||
final slidePercent;
|
||||
|
||||
SlideUpdate(
|
||||
this.updateType,
|
||||
this.direction,
|
||||
this.slidePercent
|
||||
);
|
||||
SlideUpdate(this.updateType, this.direction, this.slidePercent);
|
||||
}
|
||||
|
@ -3,14 +3,10 @@ import 'dart:math';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
class PageReveal extends StatelessWidget {
|
||||
|
||||
final double revealPercent;
|
||||
final Widget child;
|
||||
|
||||
PageReveal({
|
||||
this.revealPercent,
|
||||
this.child
|
||||
});
|
||||
PageReveal({this.revealPercent, this.child});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
@ -22,17 +18,12 @@ class PageReveal extends StatelessWidget {
|
||||
}
|
||||
|
||||
class CircleRevealClipper extends CustomClipper<Rect> {
|
||||
|
||||
final double revealPercent;
|
||||
|
||||
|
||||
CircleRevealClipper(
|
||||
this.revealPercent
|
||||
);
|
||||
CircleRevealClipper(this.revealPercent);
|
||||
|
||||
@override
|
||||
Rect getClip(Size size) {
|
||||
|
||||
final epicenter = new Offset(size.width / 2, size.height * 0.9);
|
||||
|
||||
double theta = atan(epicenter.dy / epicenter.dx);
|
||||
@ -41,12 +32,12 @@ class CircleRevealClipper extends CustomClipper<Rect>{
|
||||
final radius = distanceToCorner * revealPercent;
|
||||
final diameter = 2 * radius;
|
||||
|
||||
return new Rect.fromLTWH(epicenter.dx - radius, epicenter.dy - radius, diameter, diameter);
|
||||
return new Rect.fromLTWH(
|
||||
epicenter.dx - radius, epicenter.dy - radius, diameter, diameter);
|
||||
}
|
||||
|
||||
@override
|
||||
bool shouldReclip(CustomClipper<Rect> oldClipper) {
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
@ -5,7 +5,6 @@ import 'package:flutter/material.dart';
|
||||
import 'package:flutter_go/views/fourth_page/pages.dart';
|
||||
|
||||
class PagerIndicator extends StatelessWidget {
|
||||
|
||||
final PagerIndicatorViewModel viewModel;
|
||||
|
||||
PagerIndicator({
|
||||
@ -14,7 +13,6 @@ class PagerIndicator extends StatelessWidget {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
|
||||
List<PageBubble> bubbles = [];
|
||||
for (var i = 0; i < viewModel.pages.length; ++i) {
|
||||
final page = viewModel.pages[i];
|
||||
@ -23,17 +21,19 @@ class PagerIndicator extends StatelessWidget {
|
||||
|
||||
if (i == viewModel.activeIndex) {
|
||||
percentActive = 1.0 - viewModel.slidePercent;
|
||||
} else if (i == viewModel.activeIndex - 1 && viewModel.slideDirection == SlideDirection.leftToRight){
|
||||
} else if (i == viewModel.activeIndex - 1 &&
|
||||
viewModel.slideDirection == SlideDirection.leftToRight) {
|
||||
percentActive = viewModel.slidePercent;
|
||||
} else if (i == viewModel.activeIndex + 1 && viewModel.slideDirection == SlideDirection.rightToLeft){
|
||||
} else if (i == viewModel.activeIndex + 1 &&
|
||||
viewModel.slideDirection == SlideDirection.rightToLeft) {
|
||||
percentActive = viewModel.slidePercent;
|
||||
} else {
|
||||
percentActive = 0.0;
|
||||
}
|
||||
|
||||
bool isHollow = i > viewModel.activeIndex || (i == viewModel.activeIndex && viewModel.slideDirection == SlideDirection.leftToRight);
|
||||
|
||||
|
||||
bool isHollow = i > viewModel.activeIndex ||
|
||||
(i == viewModel.activeIndex &&
|
||||
viewModel.slideDirection == SlideDirection.leftToRight);
|
||||
|
||||
bubbles.add(
|
||||
new PageBubble(
|
||||
@ -48,7 +48,8 @@ class PagerIndicator extends StatelessWidget {
|
||||
}
|
||||
|
||||
final bubbleWidth = 55.0;
|
||||
final baseTranslation = ((viewModel.pages.length * bubbleWidth) / 2) - (bubbleWidth / 2) ;
|
||||
final baseTranslation =
|
||||
((viewModel.pages.length * bubbleWidth) / 2) - (bubbleWidth / 2);
|
||||
var translation = baseTranslation - (viewModel.activeIndex * bubbleWidth);
|
||||
|
||||
if (viewModel.slideDirection == SlideDirection.leftToRight) {
|
||||
@ -78,7 +79,6 @@ enum SlideDirection{
|
||||
none,
|
||||
}
|
||||
|
||||
|
||||
class PagerIndicatorViewModel {
|
||||
final List<PageViewModel> pages;
|
||||
final int activeIndex;
|
||||
@ -86,23 +86,13 @@ class PagerIndicatorViewModel{
|
||||
final double slidePercent;
|
||||
|
||||
PagerIndicatorViewModel(
|
||||
this.pages,
|
||||
this.activeIndex,
|
||||
this.slideDirection,
|
||||
this.slidePercent
|
||||
);
|
||||
|
||||
|
||||
this.pages, this.activeIndex, this.slideDirection, this.slidePercent);
|
||||
}
|
||||
|
||||
class PageBubble extends StatelessWidget {
|
||||
|
||||
final PageBubbleViewModel viewModel;
|
||||
|
||||
|
||||
PageBubble({
|
||||
this.viewModel
|
||||
});
|
||||
PageBubble({this.viewModel});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
@ -116,11 +106,13 @@ class PageBubble extends StatelessWidget {
|
||||
decoration: new BoxDecoration(
|
||||
shape: BoxShape.circle,
|
||||
color: viewModel.isHollow
|
||||
? const Color(0x88FFFFFF).withAlpha(0x88 * viewModel.activePercent.round())
|
||||
? const Color(0x88FFFFFF)
|
||||
.withAlpha(0x88 * viewModel.activePercent.round())
|
||||
: const Color(0x88FFFFFF),
|
||||
border: new Border.all(
|
||||
color: viewModel.isHollow
|
||||
? const Color(0x88FFFFFF).withAlpha((0x88 * (1.0 - viewModel.activePercent)).round())
|
||||
? const Color(0x88FFFFFF).withAlpha(
|
||||
(0x88 * (1.0 - viewModel.activePercent)).round())
|
||||
: Colors.transparent,
|
||||
width: 3.0,
|
||||
),
|
||||
@ -138,7 +130,6 @@ class PageBubble extends StatelessWidget {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
class PageBubbleViewModel {
|
||||
final String iconAssetPath;
|
||||
final Color color;
|
||||
@ -151,7 +142,4 @@ class PageBubbleViewModel {
|
||||
this.isHollow,
|
||||
this.activePercent,
|
||||
);
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
@ -58,7 +58,8 @@ class Page extends StatelessWidget {
|
||||
elevation: 10.0,
|
||||
color: Colors.black26,
|
||||
// shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(20)),
|
||||
shape: RoundedRectangleBorder(borderRadius: BorderRadius.horizontal(left: Radius.circular(20.0))),
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.horizontal(left: Radius.circular(20.0))),
|
||||
//如果不手动设置icon和text颜色,则默认使用foregroundColor颜色
|
||||
icon: Icon(iconName, color: Colors.white, size: 14.0),
|
||||
label: Text(
|
||||
@ -76,6 +77,7 @@ class Page extends StatelessWidget {
|
||||
children: [
|
||||
Container(
|
||||
width: double.infinity,
|
||||
|
||||
/// height:MediaQuery.of(context).size.height-200.0,
|
||||
color: viewModel.color,
|
||||
padding: const EdgeInsets.fromLTRB(0, 0, 0, 0),
|
||||
@ -86,15 +88,13 @@ class Page extends StatelessWidget {
|
||||
layout(context),
|
||||
],
|
||||
),
|
||||
)
|
||||
),
|
||||
)),
|
||||
Positioned(
|
||||
right: -5.0,
|
||||
top: 2.0,
|
||||
child: creatButton(context, 'GitHub', Icons.arrow_forward, 'goGithub')
|
||||
),
|
||||
]
|
||||
);
|
||||
child: creatButton(
|
||||
context, 'GitHub', Icons.arrow_forward, 'goGithub')),
|
||||
]);
|
||||
}
|
||||
|
||||
Column layout(BuildContext context) {
|
||||
|
@ -6,27 +6,30 @@
|
||||
/// target: app首页
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
/// import 'package:flutter/rendering.dart';
|
||||
import 'package:flutter_go/utils/data_utils.dart';
|
||||
import 'package:flutter_go/utils/shared_preferences.dart';
|
||||
|
||||
/// import 'package:flutter_go/views/first_page/first_page.dart';
|
||||
import 'package:flutter_go/views/first_page/main_page.dart';
|
||||
import 'package:fluro/fluro.dart';
|
||||
import 'package:flutter_go/views/user_page/user_page.dart';
|
||||
import 'package:flutter_go/views/widget_page/widget_page.dart';
|
||||
import 'package:flutter_go/views/welcome_page/fourth_page.dart';
|
||||
|
||||
/// import 'package:flutter_go/views/collection_page/collection_page.dart';
|
||||
import 'package:flutter_go/routers/application.dart';
|
||||
|
||||
/// import 'package:flutter_go/utils/provider.dart';
|
||||
import 'package:flutter_go/model/widget.dart';
|
||||
|
||||
/// import 'package:flutter_go/widgets/index.dart';
|
||||
import 'package:flutter_go/components/search_input.dart';
|
||||
import 'package:flutter_go/model/search_history.dart';
|
||||
import 'package:flutter_go/resources/widget_name_to_icon.dart';
|
||||
import 'package:flutter_go/model/user_info.dart';
|
||||
|
||||
|
||||
|
||||
class AppPage extends StatefulWidget {
|
||||
final UserInformation userInfo;
|
||||
|
||||
@ -62,7 +65,8 @@ class _MyHomePageState extends State<AppPage>
|
||||
print('widget.userInfo ${widget.userInfo}');
|
||||
initSearchHistory();
|
||||
|
||||
if(Application.pageIsOpen == true){// 是否展开业界动态
|
||||
if (Application.pageIsOpen == true) {
|
||||
// 是否展开业界动态
|
||||
tabData.insert(0, {'text': '业界动态', 'icon': Icon(Icons.language)});
|
||||
_list
|
||||
//..add(FirstPage())
|
||||
@ -99,8 +103,8 @@ class _MyHomePageState extends State<AppPage>
|
||||
void onWidgetTap(WidgetPoint widgetPoint, BuildContext context) {
|
||||
String targetName = widgetPoint.name;
|
||||
String targetRouter = widgetPoint.routerName;
|
||||
searchHistoryList.add(
|
||||
SearchHistory(name: targetName, targetRouter: targetRouter));
|
||||
searchHistoryList
|
||||
.add(SearchHistory(name: targetName, targetRouter: targetRouter));
|
||||
print("searchHistoryList1 ${searchHistoryList.toString()}");
|
||||
Application.router.navigateTo(context, targetRouter.toLowerCase(),
|
||||
transition: TransitionType.inFromRight);
|
||||
|
@ -6,8 +6,6 @@ import 'package:flutter_go/utils/data_utils.dart';
|
||||
import 'package:notus/convert.dart';
|
||||
import 'package:fluttertoast/fluttertoast.dart';
|
||||
|
||||
|
||||
|
||||
class IssuesMessagePage extends StatefulWidget {
|
||||
@override
|
||||
_IssuesMessagePageState createState() => _IssuesMessagePageState();
|
||||
@ -48,7 +46,9 @@ class _IssuesMessagePageState extends State<IssuesMessagePage> {
|
||||
if (_title.trim().isEmpty) {
|
||||
_show('标题不能为空');
|
||||
} else {
|
||||
String mk = (_delta==null)?'No description provided.':notusMarkdown.encode(_delta);
|
||||
String mk = (_delta == null)
|
||||
? 'No description provided.'
|
||||
: notusMarkdown.encode(_delta);
|
||||
DataUtils.feedback({'title': _title, "body": mk}, context).then((result) {
|
||||
_show('提交成功');
|
||||
Navigator.maybePop(context);
|
||||
@ -81,7 +81,6 @@ class _IssuesMessagePageState extends State<IssuesMessagePage> {
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
|
@ -388,7 +388,9 @@ class _LoginPageState extends State<LoginPage> {
|
||||
decoration: TextDecoration.underline),
|
||||
),
|
||||
onPressed: () {
|
||||
Application.router.navigateTo(context, Routes.home, clearStack: true);
|
||||
Application.router.navigateTo(
|
||||
context, Routes.home,
|
||||
clearStack: true);
|
||||
},
|
||||
)
|
||||
],
|
||||
|
@ -19,12 +19,12 @@ import 'package:flutter_go/routers/routers.dart';
|
||||
import 'package:flutter_go/utils/net_utils.dart';
|
||||
import 'package:flutter_go/components/loading.dart';
|
||||
|
||||
const githubHost = 'https://raw.githubusercontent.com/alibaba/flutter-go/master';
|
||||
const githubHost =
|
||||
'https://raw.githubusercontent.com/alibaba/flutter-go/master';
|
||||
const githubUrl = '$githubHost/lib/standard_pages/';
|
||||
const PagesUrl = '$githubHost/lib/standard_pages/.pages.json';
|
||||
const DemosUrl = '$githubHost/lib/page_demo_package/.demo.json';
|
||||
|
||||
|
||||
// ONLINE || LOCAL
|
||||
ENV env = Application.env;
|
||||
|
||||
@ -54,9 +54,11 @@ class _StandardView extends State<StandardView> {
|
||||
// }
|
||||
/// 本地调用的获取文章属性的基本信息
|
||||
Future<void> localGetPagesAttrsInfo() async {
|
||||
String jsonString = await DefaultAssetBundle.of(context).loadString('lib/standard_pages/.pages.json');
|
||||
String jsonString = await DefaultAssetBundle.of(context)
|
||||
.loadString('lib/standard_pages/.pages.json');
|
||||
List jsonList = json.decode(jsonString);
|
||||
Map<String, dynamic> pageDetail = jsonList.firstWhere((item) => item['id'] == widget.id, orElse: null);
|
||||
Map<String, dynamic> pageDetail =
|
||||
jsonList.firstWhere((item) => item['id'] == widget.id, orElse: null);
|
||||
|
||||
if (pageDetail != null) {
|
||||
setState(() {
|
||||
@ -69,12 +71,12 @@ class _StandardView extends State<StandardView> {
|
||||
|
||||
/// 从本地获取基本文章信息
|
||||
String localGetPagesMarkdown() {
|
||||
|
||||
String pageId = widget.id;
|
||||
Map<String, String> pagesList = standardPage.getPages();
|
||||
// print('pagesList[pageId]>>> ${pagesList[pageId]}');
|
||||
return pagesList[pageId];
|
||||
}
|
||||
|
||||
Future<String> getContentOnline() async {
|
||||
this.setState(() {
|
||||
isLoading = true;
|
||||
@ -82,8 +84,6 @@ class _StandardView extends State<StandardView> {
|
||||
|
||||
List response = jsonDecode(await NetUtils.get(PagesUrl));
|
||||
|
||||
|
||||
|
||||
Map targetPage = response.firstWhere((page) => page['id'] == widget.id);
|
||||
if (targetPage == null) {
|
||||
setState(() {
|
||||
@ -97,13 +97,18 @@ class _StandardView extends State<StandardView> {
|
||||
email = targetPage['email'];
|
||||
});
|
||||
|
||||
String pageName = targetPage['name'] + "_" +targetPage['author']+ "_" +targetPage['id'];
|
||||
String pageName = targetPage['name'] +
|
||||
"_" +
|
||||
targetPage['author'] +
|
||||
"_" +
|
||||
targetPage['id'];
|
||||
String pageContent = await NetUtils.get(githubUrl + pageName + "/index.md");
|
||||
setState(() {
|
||||
isLoading = false;
|
||||
});
|
||||
return Future(() => pageContent);
|
||||
}
|
||||
|
||||
/// 获取当面界面的相关信息. 需要区分环境
|
||||
/// 本地环境下, 从本地获取 standard_pages的目录中互殴
|
||||
/// 线上环境. 从github的api中获取
|
||||
@ -124,6 +129,7 @@ class _StandardView extends State<StandardView> {
|
||||
}
|
||||
return Future(() => conent);
|
||||
}
|
||||
|
||||
void seeSourceCode(id) async {
|
||||
List response;
|
||||
try {
|
||||
@ -132,16 +138,18 @@ class _StandardView extends State<StandardView> {
|
||||
return alertDialog(msg: '请检查网络链接', title: '提示');
|
||||
}
|
||||
|
||||
Map<String, dynamic> demoDetail = response.firstWhere((item) => item['id'] == id, orElse: null);
|
||||
Map<String, dynamic> demoDetail =
|
||||
response.firstWhere((item) => item['id'] == id, orElse: null);
|
||||
if (demoDetail == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
String remoteSouceCode = '$githubHost/lib/page_demo_package/${demoDetail['name']}_${demoDetail['author']}_${demoDetail['id']}/src/index.dart';
|
||||
String remoteSouceCode =
|
||||
'$githubHost/lib/page_demo_package/${demoDetail['name']}_${demoDetail['author']}_${demoDetail['id']}/src/index.dart';
|
||||
Application.router.navigateTo(context,
|
||||
'${Routes.githubCodeView}?remotePath=${Uri.encodeComponent(remoteSouceCode)}');
|
||||
|
||||
}
|
||||
|
||||
Widget buildFootInfo() {
|
||||
if (!isLoading) {
|
||||
return Container(
|
||||
@ -159,8 +167,6 @@ class _StandardView extends State<StandardView> {
|
||||
}
|
||||
|
||||
Widget buildMarkdown() {
|
||||
|
||||
|
||||
if (markdownDesc == null) {
|
||||
return null;
|
||||
} else {
|
||||
@ -193,13 +199,15 @@ class _StandardView extends State<StandardView> {
|
||||
onTap: () {
|
||||
seeSourceCode(attrs['id']);
|
||||
},
|
||||
child: Text("查看源码", style: TextStyle(color: Theme.of(context).primaryColor)),
|
||||
child: Text("查看源码",
|
||||
style: TextStyle(color: Theme.of(context).primaryColor)),
|
||||
)
|
||||
],
|
||||
);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
alertDialog({String msg, String title}) {
|
||||
showDialog<Null>(
|
||||
context: context,
|
||||
@ -213,8 +221,7 @@ class _StandardView extends State<StandardView> {
|
||||
new Text(msg),
|
||||
],
|
||||
),
|
||||
)
|
||||
);
|
||||
));
|
||||
},
|
||||
);
|
||||
}
|
||||
|
@ -20,12 +20,8 @@ class WelcomePage extends StatefulWidget {
|
||||
}
|
||||
|
||||
class _WelcomePageState extends State<WelcomePage> {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return new Container(
|
||||
color: Colors.white,
|
||||
child: FourthPage()
|
||||
);
|
||||
return new Container(color: Colors.white, child: FourthPage());
|
||||
}
|
||||
}
|
||||
|
@ -9,26 +9,19 @@ import 'package:flutter_go/components/cate_card.dart';
|
||||
|
||||
import 'package:flutter_go/routers/application.dart';
|
||||
|
||||
|
||||
class WidgetPage extends StatefulWidget {
|
||||
|
||||
|
||||
|
||||
|
||||
@override
|
||||
SecondPageState createState() => new SecondPageState();
|
||||
}
|
||||
|
||||
class SecondPageState extends State<WidgetPage> with AutomaticKeepAliveClientMixin{
|
||||
|
||||
class SecondPageState extends State<WidgetPage>
|
||||
with AutomaticKeepAliveClientMixin {
|
||||
SecondPageState() : super();
|
||||
|
||||
TextEditingController controller;
|
||||
String active = 'test';
|
||||
String data = '无';
|
||||
|
||||
|
||||
|
||||
@override
|
||||
bool get wantKeepAlive => true;
|
||||
|
||||
@ -37,8 +30,6 @@ class SecondPageState extends State<WidgetPage> with AutomaticKeepAliveClientMix
|
||||
super.initState();
|
||||
}
|
||||
|
||||
|
||||
|
||||
Widget buildGrid() {
|
||||
// 存放最后的widget
|
||||
List<Widget> tiles = [];
|
||||
@ -58,5 +49,4 @@ class SecondPageState extends State<WidgetPage> with AutomaticKeepAliveClientMix
|
||||
child: this.buildGrid(),
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -7,9 +7,6 @@ class WidgetNotFound extends StatelessWidget {
|
||||
appBar: AppBar(
|
||||
title: Text("widget not found"),
|
||||
),
|
||||
body: Container(
|
||||
child: Text("widget not found")
|
||||
)
|
||||
);
|
||||
body: Container(child: Text("widget not found")));
|
||||
}
|
||||
}
|
||||
|
@ -18,7 +18,8 @@ class AppBarLessDefaultComplex extends StatefulWidget {
|
||||
}
|
||||
|
||||
// AppBar 默认的实例,有状态
|
||||
class _AppBarLessDefaultComplex extends State with SingleTickerProviderStateMixin {
|
||||
class _AppBarLessDefaultComplex extends State
|
||||
with SingleTickerProviderStateMixin {
|
||||
ScrollController _scrollViewController;
|
||||
TabController _tabController;
|
||||
|
||||
@ -26,7 +27,8 @@ class _AppBarLessDefaultComplex extends State with SingleTickerProviderStateMixi
|
||||
void initState() {
|
||||
super.initState();
|
||||
_scrollViewController = ScrollController();
|
||||
_tabController = TabController(vsync: this, length: 6);// 和下面的 TabBar.tabs 数量对应
|
||||
_tabController =
|
||||
TabController(vsync: this, length: 6); // 和下面的 TabBar.tabs 数量对应
|
||||
}
|
||||
|
||||
@override
|
||||
@ -43,7 +45,8 @@ class _AppBarLessDefaultComplex extends State with SingleTickerProviderStateMixi
|
||||
// 这种行为可以通过设置来关闭automaticallyImplyLeading 为false。在这种情况下,空的 leading widget 将导致 middle/title widget 拉伸开始。
|
||||
return SizedBox(
|
||||
height: 500,
|
||||
child: AppBar( // 大量配置属性参考 SliverAppBar 示例
|
||||
child: AppBar(
|
||||
// 大量配置属性参考 SliverAppBar 示例
|
||||
title: Text('title'),
|
||||
leading: Icon(Icons.home),
|
||||
backgroundColor: Colors.amber[500],
|
||||
@ -90,15 +93,13 @@ class _AppBarLessDefaultComplex extends State with SingleTickerProviderStateMixi
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// AppBar 默认的实例,无状态
|
||||
|
||||
class AppBarLessDefaultSimple extends StatelessWidget {
|
||||
final widget;
|
||||
final parent;
|
||||
|
||||
const AppBarLessDefaultSimple([this.widget, this.parent])
|
||||
: super();
|
||||
const AppBarLessDefaultSimple([this.widget, this.parent]) : super();
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
@ -123,7 +124,6 @@ class AppBarLessDefaultSimple extends StatelessWidget {
|
||||
onPressed: () => {},
|
||||
),
|
||||
],
|
||||
)
|
||||
);
|
||||
));
|
||||
}
|
||||
}
|
@ -10,23 +10,19 @@ import 'package:flutter/material.dart';
|
||||
import './demo.dart' as AppBarDemo;
|
||||
import 'package:flutter_go/components/widget_demo.dart';
|
||||
|
||||
const String _Text0 =
|
||||
"""### **简介**
|
||||
const String _Text0 = """### **简介**
|
||||
> AppBar “应用栏”
|
||||
- 应用栏由工具栏组成,或者是工具栏和其他 widget 组合形成,例如 TabBar和FlexibleSpaceBar;
|
||||
- 应用栏通常用于 Scaffold.appBar 属性,该属性将应用栏放置在屏幕顶部的固定高度小部件中;
|
||||
- 对于可滚动的应用栏,请参阅SliverAppBar,它将AppBar嵌入 sliver 中以便在CustomScrollView中使用;
|
||||
""";
|
||||
|
||||
|
||||
const String _Text1 =
|
||||
"""### **基本用法**
|
||||
const String _Text1 = """### **基本用法**
|
||||
> AppBar
|
||||
- AppBar 在底部上方显示工具栏 widget,前导 leading ,标题 title 和操作 actions;
|
||||
""";
|
||||
|
||||
const String _Text2 =
|
||||
"""### **进阶用法**
|
||||
const String _Text2 = """### **进阶用法**
|
||||
> AppBar
|
||||
- 一个完整的 AppBar 的例子, 增加 PopupMenuButton,TabBar 的示例子;
|
||||
- 所述底部通常用于一个的 TabBar;
|
||||
|
@ -12,8 +12,7 @@ class AppBarLessDefaultSimple extends StatelessWidget {
|
||||
final widget;
|
||||
final parent;
|
||||
|
||||
const AppBarLessDefaultSimple([this.widget, this.parent])
|
||||
: super();
|
||||
const AppBarLessDefaultSimple([this.widget, this.parent]) : super();
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
@ -21,9 +20,12 @@ class AppBarLessDefaultSimple extends StatelessWidget {
|
||||
height: 100,
|
||||
child: Scaffold(
|
||||
//appBar: AppBar(title: const Text('Bottom App Bar')),
|
||||
floatingActionButtonLocation: FloatingActionButtonLocation.centerDocked,
|
||||
floatingActionButtonLocation:
|
||||
FloatingActionButtonLocation.centerDocked,
|
||||
floatingActionButton: FloatingActionButton(
|
||||
child: const Icon(Icons.add), onPressed: () {},),
|
||||
child: const Icon(Icons.add),
|
||||
onPressed: () {},
|
||||
),
|
||||
bottomNavigationBar: BottomAppBar(
|
||||
shape: CircularNotchedRectangle(),
|
||||
notchMargin: 10.0, // FloatingActionButton和BottomAppBar 之间的差距
|
||||
@ -32,11 +34,17 @@ class AppBarLessDefaultSimple extends StatelessWidget {
|
||||
mainAxisSize: MainAxisSize.max,
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: <Widget>[
|
||||
IconButton(icon: Icon(Icons.menu), onPressed: () {},),
|
||||
IconButton(icon: Icon(Icons.search), onPressed: () {},),
|
||||
IconButton(
|
||||
icon: Icon(Icons.menu),
|
||||
onPressed: () {},
|
||||
),
|
||||
IconButton(
|
||||
icon: Icon(Icons.search),
|
||||
onPressed: () {},
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
)
|
||||
);
|
||||
}}
|
||||
));
|
||||
}
|
||||
}
|
||||
|
@ -11,19 +11,15 @@ import 'package:flutter/material.dart';
|
||||
|
||||
import './demo.dart' as BottomAppBarDemo;
|
||||
|
||||
const String _Text0 =
|
||||
"""### **简介**
|
||||
const String _Text0 = """### **简介**
|
||||
> BottomAppBar “底部应用栏”
|
||||
- 一个通常与 Scaffold.bottomNavigationBar 一起使用的容器,可以在顶部有一个凹口,为重叠的FloatingActionButton腾出空间;
|
||||
""";
|
||||
|
||||
|
||||
const String _Text1 =
|
||||
"""### **基本用法**
|
||||
const String _Text1 = """### **基本用法**
|
||||
> 通常与 Scaffold 和 FloatingActionButton 一起使用;
|
||||
""";
|
||||
|
||||
|
||||
class Demo extends StatefulWidget {
|
||||
static const String routeName = '/components//Bar/BottomAppBar';
|
||||
|
||||
@ -38,7 +34,8 @@ class _DemoState extends State<Demo> {
|
||||
title: 'BottomAppBar',
|
||||
codeUrl: 'components/Bar/BottomAppBar/demo.dart',
|
||||
contentList: allDomes(context, this),
|
||||
docUrl: 'https://docs.flutter.io/flutter/material/BottomAppBar-class.html',
|
||||
docUrl:
|
||||
'https://docs.flutter.io/flutter/material/BottomAppBar-class.html',
|
||||
);
|
||||
}
|
||||
}
|
||||
@ -56,6 +53,3 @@ List allDomes(BuildContext context, _DemoState that) {
|
||||
SizedBox(height: 20.0), // 间距
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
@ -30,37 +30,61 @@ class ButtonBarLessDefault extends StatelessWidget {
|
||||
final widget;
|
||||
final parent;
|
||||
|
||||
const ButtonBarLessDefault([this.widget, this.parent])
|
||||
: super();
|
||||
const ButtonBarLessDefault([this.widget, this.parent]) : super();
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Container(
|
||||
margin: EdgeInsets.symmetric(vertical: 0.0),
|
||||
height: 100.0,
|
||||
child: Scrollbar(child:ListView(
|
||||
scrollDirection: Axis.horizontal, // 水平listView
|
||||
child: Scrollbar(
|
||||
child: ListView(scrollDirection: Axis.horizontal, // 水平listView
|
||||
children: <Widget>[
|
||||
ButtonBar(
|
||||
alignment: MainAxisAlignment.spaceAround, //布局方向,默认MainAxisAlignment.end
|
||||
alignment: MainAxisAlignment
|
||||
.spaceAround, //布局方向,默认MainAxisAlignment.end
|
||||
mainAxisSize: MainAxisSize.max, //主轴大小,默认MainAxisSize.max
|
||||
children: <Widget>[ // Button集合
|
||||
RaisedButton(child: Text('ButtonBar1'),color: Colors.red,onPressed: ()=>{},),
|
||||
RaisedButton(child: Text('ButtonBar2'),color: Colors.red,onPressed: ()=>{},),
|
||||
RaisedButton(child: Text('ButtonBar3'),color: Colors.red,onPressed: ()=>{},),
|
||||
children: <Widget>[
|
||||
// Button集合
|
||||
RaisedButton(
|
||||
child: Text('ButtonBar1'),
|
||||
color: Colors.red,
|
||||
onPressed: () => {},
|
||||
),
|
||||
RaisedButton(
|
||||
child: Text('ButtonBar2'),
|
||||
color: Colors.red,
|
||||
onPressed: () => {},
|
||||
),
|
||||
RaisedButton(
|
||||
child: Text('ButtonBar3'),
|
||||
color: Colors.red,
|
||||
onPressed: () => {},
|
||||
),
|
||||
],
|
||||
),
|
||||
ButtonBar(
|
||||
alignment: MainAxisAlignment.end, //布局方向,默认MainAxisAlignment.end
|
||||
mainAxisSize: MainAxisSize.min, //主轴大小,默认MainAxisSize.max
|
||||
children: <Widget>[ // Button集合
|
||||
RaisedButton(child: Text('ButtonBar1'),color: Colors.yellow,onPressed: ()=>{},),
|
||||
RaisedButton(child: Text('ButtonBar2'),color: Colors.yellow,onPressed: ()=>{},),
|
||||
RaisedButton(child: Text('ButtonBar3'),color: Colors.yellow,onPressed: ()=>{},),
|
||||
children: <Widget>[
|
||||
// Button集合
|
||||
RaisedButton(
|
||||
child: Text('ButtonBar1'),
|
||||
color: Colors.yellow,
|
||||
onPressed: () => {},
|
||||
),
|
||||
RaisedButton(
|
||||
child: Text('ButtonBar2'),
|
||||
color: Colors.yellow,
|
||||
onPressed: () => {},
|
||||
),
|
||||
RaisedButton(
|
||||
child: Text('ButtonBar3'),
|
||||
color: Colors.yellow,
|
||||
onPressed: () => {},
|
||||
),
|
||||
],
|
||||
)
|
||||
]
|
||||
)
|
||||
));
|
||||
])));
|
||||
}
|
||||
}
|
@ -11,22 +11,18 @@ import 'package:flutter/material.dart';
|
||||
|
||||
import './demo.dart' as ButtonBarDemo;
|
||||
|
||||
const String _Text0 =
|
||||
"""### **简介**
|
||||
const String _Text0 = """### **简介**
|
||||
> ButtonBar “末端对齐的按钮容器”
|
||||
- 横排的Button布局
|
||||
""";
|
||||
|
||||
|
||||
const String _Text1 =
|
||||
"""### **基本用法**
|
||||
const String _Text1 = """### **基本用法**
|
||||
> 根据当前 ButtonTheme 中的填充水平放置 button
|
||||
- 子 button 在布置行与 MainAxisAlignment.end;
|
||||
- 当 Directionality为TextDirection.ltr 时,按钮栏的子项右对齐,最后一个子项成为最右边的子项;
|
||||
- 当 Directionality TextDirection.rtl 时,子项被左对齐,最后一个子项成为最左边的子项;
|
||||
""";
|
||||
|
||||
|
||||
class Demo extends StatefulWidget {
|
||||
static const String routeName = '/components/Bar/ButtonBar';
|
||||
|
||||
@ -58,4 +54,3 @@ List allDomes(BuildContext context, _DemoState that) {
|
||||
ButtonBarDemo.ButtonBarLessDefault()
|
||||
];
|
||||
}
|
||||
|
||||
|
@ -11,21 +11,17 @@ import 'package:flutter/material.dart';
|
||||
|
||||
import './demo.dart' as FlexibleSpaceBarDemo;
|
||||
|
||||
const String _Text0 =
|
||||
"""### **简介**
|
||||
const String _Text0 = """### **简介**
|
||||
> FlexibleSpaceBar “扩展和折叠的应用栏”
|
||||
- AppBar 的一部分,可以扩展和折叠;
|
||||
""";
|
||||
|
||||
|
||||
const String _Text1 =
|
||||
"""### **基本用法**
|
||||
const String _Text1 = """### **基本用法**
|
||||
> 最常用于 SliverAppBar.flexibleSpace 字段
|
||||
- 灵活的空格键随着应用滚动而扩展和收缩,以便 AppBar 从应用程序的顶部到达应用程序滚动内容的顶部;
|
||||
- 要调整 AppBar 大小,必须将其包装在 FlexibleSpaceBar.createSettings 返回的 widget 中 ,以将大小调整信息传递给 FlexibleSpaceBar;
|
||||
""";
|
||||
|
||||
|
||||
class Demo extends StatefulWidget {
|
||||
static const String routeName = '/components/Bar/FlexibleSpaceBar';
|
||||
|
||||
@ -40,7 +36,8 @@ class _DemoState extends State<Demo> {
|
||||
title: 'FlexibleSpaceBar',
|
||||
codeUrl: 'components/Bar/FlexibleSpaceBar/demo.dart',
|
||||
contentList: allDomes(context, this),
|
||||
docUrl: 'https://docs.flutter.io/flutter/material/FlexibleSpaceBar-class.html',
|
||||
docUrl:
|
||||
'https://docs.flutter.io/flutter/material/FlexibleSpaceBar-class.html',
|
||||
);
|
||||
}
|
||||
}
|
||||
@ -58,4 +55,3 @@ List allDomes(BuildContext context, _DemoState that) {
|
||||
SizedBox(height: 20.0), // 间距
|
||||
];
|
||||
}
|
||||
|
||||
|
@ -64,7 +64,8 @@ class SliverAppBarLessDefault extends StatelessWidget {
|
||||
expandedHeight: 200.0, //展开高度
|
||||
floating: false, //是否随着滑动隐藏标题
|
||||
pinned: true, //是否固定在顶部
|
||||
flexibleSpace: FlexibleSpaceBar( //可以展开区域,通常是一个FlexibleSpaceBar
|
||||
flexibleSpace: FlexibleSpaceBar(
|
||||
//可以展开区域,通常是一个FlexibleSpaceBar
|
||||
centerTitle: true,
|
||||
title: Text("我是一个帅气的标题",
|
||||
style: TextStyle(
|
||||
@ -128,4 +129,3 @@ class ListItemWidget extends StatelessWidget {
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -11,15 +11,12 @@ import 'package:flutter/material.dart';
|
||||
|
||||
import './demo.dart' as SliverAppBarDemo;
|
||||
|
||||
const String _Text0 =
|
||||
"""### **简介**
|
||||
const String _Text0 = """### **简介**
|
||||
> SliverAppBar “应用栏”
|
||||
- 它类似于Android中的toolbar;
|
||||
""";
|
||||
|
||||
|
||||
const String _Text1 =
|
||||
"""### **基本用法**
|
||||
const String _Text1 = """### **基本用法**
|
||||
> 虽然基本相同,构造方法也是非常的简单,但是却不能直接使用它,由官方文档可以看到通常结合 ScrollView 来使用它;
|
||||
- AppBar 和 SliverAppBar 都是继承StatefulWidget 类,都代表 Toobar;
|
||||
- 二者的区别在于 AppBar 位置的固定的应用最上面的;而 SliverAppBar 是可以跟随内容滚动的;
|
||||
@ -57,4 +54,3 @@ List allDomes(BuildContext context, _DemoState that) {
|
||||
SliverAppBarDemo.SliverAppBarLessDefault()
|
||||
];
|
||||
}
|
||||
|
||||
|
@ -12,8 +12,7 @@ class SnackBarLessDefault extends StatelessWidget {
|
||||
final widget;
|
||||
final parent;
|
||||
|
||||
const SnackBarLessDefault([this.widget, this.parent])
|
||||
: super();
|
||||
const SnackBarLessDefault([this.widget, this.parent]) : super();
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
@ -26,7 +25,8 @@ class SnackBarLessDefault extends StatelessWidget {
|
||||
final snackBar = SnackBar(
|
||||
content: Text('这是一个SnackBar, 右侧有SnackBarAction'),
|
||||
backgroundColor: Colors.red,
|
||||
action: SnackBarAction( // 提示信息上添加一个撤消的按钮
|
||||
action: SnackBarAction(
|
||||
// 提示信息上添加一个撤消的按钮
|
||||
textColor: Colors.black,
|
||||
label: '撤消',
|
||||
onPressed: () {
|
||||
@ -53,7 +53,6 @@ class SnackBarLessDefault extends StatelessWidget {
|
||||
child: Text('显示无SnackBarAction的SnackBar'),
|
||||
),
|
||||
],
|
||||
)
|
||||
);
|
||||
));
|
||||
}
|
||||
}
|
@ -9,21 +9,17 @@ import 'package:flutter/material.dart';
|
||||
import 'package:flutter_go/components/widget_demo.dart';
|
||||
import './demo.dart' as SnackBarDemo;
|
||||
|
||||
const String _Text0 =
|
||||
"""### **简介**
|
||||
const String _Text0 = """### **简介**
|
||||
> SnackBar “屏幕底部消息”
|
||||
- 带有可选操作的轻量级消息,短暂显示在屏幕底部
|
||||
- SnackBar是用户操作后,显示提示信息的一个控件,类似Toast,会自动隐藏;
|
||||
""";
|
||||
|
||||
|
||||
const String _Text1 =
|
||||
"""### **基本用法**
|
||||
const String _Text1 = """### **基本用法**
|
||||
> Scaffold.of(context).showSnackBar(),传递描述消息的 SnackBar 实例;
|
||||
- 要控制SnackBar保持可见的时间,请指定持续时间。
|
||||
""";
|
||||
|
||||
|
||||
class Demo extends StatefulWidget {
|
||||
static const String routeName = '/components//Bar/SnackBar';
|
||||
|
||||
|
@ -21,7 +21,8 @@ class _Demo extends State<SnackBarActionDemo> {
|
||||
final snackBar = new SnackBar(
|
||||
content: new Text('这是一个SnackBar, 右侧有SnackBarAction, 3秒后消失'),
|
||||
backgroundColor: Color(0xffc91b3a),
|
||||
action: SnackBarAction( // 提示信息上添加一个撤消的按钮
|
||||
action: SnackBarAction(
|
||||
// 提示信息上添加一个撤消的按钮
|
||||
textColor: Colors.white,
|
||||
label: '撤消',
|
||||
onPressed: () {
|
||||
@ -33,7 +34,6 @@ class _Demo extends State<SnackBarActionDemo> {
|
||||
);
|
||||
Scaffold.of(context).showSnackBar(snackBar);
|
||||
},
|
||||
|
||||
child: Text('点我显示有action的SnackBar'),
|
||||
),
|
||||
new RaisedButton(
|
||||
@ -49,8 +49,6 @@ class _Demo extends State<SnackBarActionDemo> {
|
||||
child: Text('点我显示无SnackBarAction的SnackBar'),
|
||||
),
|
||||
],
|
||||
)
|
||||
);
|
||||
));
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -22,7 +22,6 @@ const String _Text0 = """
|
||||
|
||||
""";
|
||||
|
||||
|
||||
class Demo extends StatefulWidget {
|
||||
static const String routeName = '/components/Bar/SnackBarAction';
|
||||
|
||||
@ -40,7 +39,8 @@ class _DemoState extends State<Demo> {
|
||||
_Text0,
|
||||
SnackBarDemo.SnackBarActionDemo(),
|
||||
],
|
||||
docUrl: 'https://docs.flutter.io/flutter/material/SnackBarAction-class.html',
|
||||
docUrl:
|
||||
'https://docs.flutter.io/flutter/material/SnackBarAction-class.html',
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -23,7 +23,8 @@ class _TabBarDemo extends State with SingleTickerProviderStateMixin {
|
||||
void initState() {
|
||||
super.initState();
|
||||
_scrollViewController = ScrollController();
|
||||
_tabController = TabController(vsync: this, length: 6);// 和下面的 TabBar.tabs 数量对应
|
||||
_tabController =
|
||||
TabController(vsync: this, length: 6); // 和下面的 TabBar.tabs 数量对应
|
||||
}
|
||||
|
||||
@override
|
||||
@ -41,7 +42,8 @@ class _TabBarDemo extends State with SingleTickerProviderStateMixin {
|
||||
return SizedBox(
|
||||
height: 500,
|
||||
child: Scaffold(
|
||||
appBar: AppBar( // 大量配置属性参考 SliverAppBar 示例
|
||||
appBar: AppBar(
|
||||
// 大量配置属性参考 SliverAppBar 示例
|
||||
title: Text('TabBar'),
|
||||
leading: Icon(Icons.home),
|
||||
backgroundColor: Colors.amber[1000],
|
||||
@ -66,8 +68,6 @@ class _TabBarDemo extends State with SingleTickerProviderStateMixin {
|
||||
Text('TabsView 5'),
|
||||
Text('TabsView 6'),
|
||||
]),
|
||||
)
|
||||
|
||||
);
|
||||
));
|
||||
}
|
||||
}
|
@ -43,7 +43,6 @@ const String _Text0 = """
|
||||
- controller TabController对象
|
||||
""";
|
||||
|
||||
|
||||
class Demo extends StatefulWidget {
|
||||
static const String routeName = '/components/Bar/TabBar';
|
||||
|
||||
@ -57,11 +56,9 @@ class _DemoState extends State<Demo> {
|
||||
return WidgetDemo(
|
||||
title: 'TabBar',
|
||||
codeUrl: 'components/Bar/TabBar/demo.dart',
|
||||
contentList: [
|
||||
_Text0,
|
||||
TabBarDemo()
|
||||
],
|
||||
docUrl: 'https://docs.flutter.io/flutter/material/SnackBarAction-class.html',
|
||||
contentList: [_Text0, TabBarDemo()],
|
||||
docUrl:
|
||||
'https://docs.flutter.io/flutter/material/SnackBarAction-class.html',
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -17,8 +17,6 @@ import 'SnackBar/index.dart' as SnackBar;
|
||||
import 'SnackBarAction/index.dart' as SnackBarAction;
|
||||
import 'TabBar/index.dart' as TabBar;
|
||||
|
||||
|
||||
|
||||
List<WidgetPoint> widgetPoints = [
|
||||
WidgetPoint(
|
||||
name: 'AppBar',
|
||||
|
@ -7,7 +7,6 @@
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
|
||||
/// Checkbox 默认Card的实例
|
||||
class CardFullDefault extends StatefulWidget {
|
||||
const CardFullDefault() : super();
|
||||
@ -16,7 +15,6 @@ class CardFullDefault extends StatefulWidget {
|
||||
State<StatefulWidget> createState() => _CardFullDefault();
|
||||
}
|
||||
|
||||
|
||||
/// Card 默认的实例,有状态
|
||||
class _CardFullDefault extends State {
|
||||
@override
|
||||
@ -32,8 +30,7 @@ class CardLessDefault extends StatelessWidget {
|
||||
final widget;
|
||||
final parent;
|
||||
|
||||
const CardLessDefault([this.widget, this.parent])
|
||||
: super();
|
||||
const CardLessDefault([this.widget, this.parent]) : super();
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
@ -43,29 +40,37 @@ class CardLessDefault extends StatelessWidget {
|
||||
elevation: 20.0, // 卡片的z坐标,控制卡片下面的阴影大小
|
||||
margin: EdgeInsets.all(20.0),
|
||||
// margin: EdgeInsetsDirectional.only(bottom: 30.0, top: 30.0, start: 30.0),// 边距
|
||||
semanticContainer:true, // 表示单个语义容器,还是false表示单个语义节点的集合,接受单个child,但该child可以是Row,Column或其他包含子级列表的widget
|
||||
semanticContainer:
|
||||
true, // 表示单个语义容器,还是false表示单个语义节点的集合,接受单个child,但该child可以是Row,Column或其他包含子级列表的widget
|
||||
// shape: Border.all(
|
||||
// color: Colors.indigo, width: 1.0, style: BorderStyle.solid), // 卡片材质的形状,以及边框
|
||||
shape:RoundedRectangleBorder(borderRadius: BorderRadius.circular(20.0)), // 圆角
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(20.0)), // 圆角
|
||||
//borderRadius: BorderRadius.all(Radius.circular(8.0)),
|
||||
child: Column( //card里面的子控件
|
||||
child: Column(
|
||||
//card里面的子控件
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: <Widget>[
|
||||
const ListTile(
|
||||
leading: Icon(Icons.access_time),
|
||||
title: Text('The Enchanted Nightingale',style: TextStyle(color: Colors.white, fontSize: 40.0)),
|
||||
subtitle: Text('Music by Julie Gable. Lyrics by Sidney Stein.',style: TextStyle(color: Colors.yellow, fontSize: 16.0)),
|
||||
title: Text('The Enchanted Nightingale',
|
||||
style: TextStyle(color: Colors.white, fontSize: 40.0)),
|
||||
subtitle: Text('Music by Julie Gable. Lyrics by Sidney Stein.',
|
||||
style: TextStyle(color: Colors.yellow, fontSize: 16.0)),
|
||||
contentPadding: EdgeInsets.all(20.0), // item 内容内边距
|
||||
),
|
||||
ButtonTheme.bar( // make buttons use the appropriate styles for cards
|
||||
ButtonTheme.bar(
|
||||
// make buttons use the appropriate styles for cards
|
||||
child: ButtonBar(
|
||||
children: <Widget>[
|
||||
FlatButton(
|
||||
child: const Text('BUY TICKETS',style: TextStyle(color: Colors.black, fontSize: 14.0)),
|
||||
child: const Text('BUY TICKETS',
|
||||
style: TextStyle(color: Colors.black, fontSize: 14.0)),
|
||||
onPressed: () {},
|
||||
),
|
||||
FlatButton(
|
||||
child: const Text('LISTEN',style: TextStyle(color: Colors.black, fontSize: 14.0)),
|
||||
child: const Text('LISTEN',
|
||||
style: TextStyle(color: Colors.black, fontSize: 14.0)),
|
||||
onPressed: () {},
|
||||
),
|
||||
],
|
||||
|
@ -10,19 +10,15 @@ import 'package:flutter/material.dart';
|
||||
import 'package:flutter_go/components/widget_demo.dart';
|
||||
import './demo.dart' as CardDemo;
|
||||
|
||||
const String _Text0 =
|
||||
"""### **简介**
|
||||
const String _Text0 = """### **简介**
|
||||
> Card “卡片”
|
||||
- 卡片用于表示一些相关信息,例如相册,地理位置,用餐,联系方式等
|
||||
""";
|
||||
|
||||
|
||||
const String _Text1 =
|
||||
"""### **基本用法**
|
||||
const String _Text1 = """### **基本用法**
|
||||
> 此示例显示了创建卡片窗口组件,其中显示了相册信息和两个操作
|
||||
""";
|
||||
|
||||
|
||||
class Demo extends StatefulWidget {
|
||||
static const String routeName = '/components/Card/Card';
|
||||
|
||||
@ -42,7 +38,6 @@ class _DemoState extends State<Demo> {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// 所有的 Card widget
|
||||
/// context: 运行上下文
|
||||
/// that: 指向有状态的 StatefulWidget
|
||||
@ -55,4 +50,3 @@ List allDomes(BuildContext context, _DemoState that) {
|
||||
CardDemo.CardLessDefault()
|
||||
];
|
||||
}
|
||||
|
||||
|
@ -34,8 +34,7 @@ class _DemoState extends State<Demo> {
|
||||
ChipDemo(),
|
||||
],
|
||||
codeUrl: 'components/Chip/Chip/demo.dart',
|
||||
docUrl:
|
||||
'https://docs.flutter.io/flutter/material/Chip-class.html',
|
||||
docUrl: 'https://docs.flutter.io/flutter/material/Chip-class.html',
|
||||
title: 'Chip');
|
||||
}
|
||||
}
|
||||
|
@ -15,9 +15,11 @@ class _ChipThemeDemoState extends State<ChipThemeDemo> {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return ChipTheme(
|
||||
data: ChipTheme.of(context).copyWith(backgroundColor:Colors.red.shade800 ),
|
||||
data:
|
||||
ChipTheme.of(context).copyWith(backgroundColor: Colors.red.shade800),
|
||||
child: ChoiceChip(
|
||||
padding: EdgeInsets.only(left: 100.0,right: 100.0,top: 10.0,bottom: 10.0),
|
||||
padding:
|
||||
EdgeInsets.only(left: 100.0, right: 100.0, top: 10.0, bottom: 10.0),
|
||||
label: Text('down'),
|
||||
labelStyle: TextStyle(color: Colors.white),
|
||||
onSelected: (bool value) {
|
||||
@ -55,5 +57,4 @@ class _ChipThemeDemoState extends State<ChipThemeDemo> {
|
||||
// ),
|
||||
// );
|
||||
|
||||
|
||||
// }
|
||||
|
@ -35,8 +35,7 @@ class _DemoState extends State<Demo> {
|
||||
ChipThemeDemo(),
|
||||
],
|
||||
codeUrl: 'components/Chip/ChipTheme/demo.dart',
|
||||
docUrl:
|
||||
'https://docs.flutter.io/flutter/material/ChipTheme-class.html',
|
||||
docUrl: 'https://docs.flutter.io/flutter/material/ChipTheme-class.html',
|
||||
title: 'ChipTheme');
|
||||
}
|
||||
}
|
||||
|
@ -18,9 +18,11 @@ class _ChipThemeDemoState extends State<ChipThemeDemo> {
|
||||
data: ChipThemeData.fromDefaults(
|
||||
// brightness: Brightness.dark,
|
||||
labelStyle: TextStyle(fontSize: 15.0),
|
||||
primaryColor: Colors.red,secondaryColor: Colors.red.shade800),
|
||||
primaryColor: Colors.red,
|
||||
secondaryColor: Colors.red.shade800),
|
||||
child: ChoiceChip(
|
||||
padding: EdgeInsets.only(left: 100.0,right: 100.0,top: 10.0,bottom: 10.0),
|
||||
padding:
|
||||
EdgeInsets.only(left: 100.0, right: 100.0, top: 10.0, bottom: 10.0),
|
||||
label: Text('down'),
|
||||
onSelected: (bool value) {
|
||||
setState(() {
|
||||
@ -32,6 +34,3 @@ class _ChipThemeDemoState extends State<ChipThemeDemo> {
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
@ -12,9 +12,7 @@ class ChoiceChipDemo extends StatefulWidget {
|
||||
class _ChoiceChipDemoState extends State<ChoiceChipDemo> {
|
||||
String _selected = '';
|
||||
|
||||
List<String> _sub=<String>[
|
||||
'java','web','android'
|
||||
];
|
||||
List<String> _sub = <String>['java', 'web', 'android'];
|
||||
|
||||
Iterable<Widget> get actorWidgets sync* {
|
||||
for (String choiceSub in _sub) {
|
||||
@ -36,9 +34,8 @@ class _ChoiceChipDemoState extends State<ChoiceChipDemo> {
|
||||
_selected = value ? choiceSub : 'Colors.red';
|
||||
});
|
||||
},
|
||||
selected: _selected == choiceSub,)
|
||||
);
|
||||
|
||||
selected: _selected == choiceSub,
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
@ -52,9 +49,5 @@ class _ChoiceChipDemoState extends State<ChoiceChipDemo> {
|
||||
),
|
||||
],
|
||||
);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
@ -33,7 +33,8 @@ class _DemoState extends State<Demo> {
|
||||
ChoiceChipDemo(),
|
||||
],
|
||||
codeUrl: 'components/Chip/ChoiceChip/demo.dart',
|
||||
docUrl:'https://docs.flutter.io/flutter/material/ChoiceChip-class.html',
|
||||
docUrl:
|
||||
'https://docs.flutter.io/flutter/material/ChoiceChip-class.html',
|
||||
title: 'ChoiceChip');
|
||||
}
|
||||
}
|
||||
|
@ -15,7 +15,6 @@ class ActorFilerEntry{
|
||||
const ActorFilerEntry(this.name, this.initials);
|
||||
}
|
||||
|
||||
|
||||
class _FilterChipDemoState extends State<FilterChipDemo> {
|
||||
final List<ActorFilerEntry> _list = <ActorFilerEntry>[
|
||||
const ActorFilerEntry('android', 'ad'),
|
||||
@ -49,7 +48,6 @@ class _FilterChipDemoState extends State<FilterChipDemo> {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Column(
|
||||
@ -63,6 +61,3 @@ class _FilterChipDemoState extends State<FilterChipDemo> {
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
@ -13,11 +13,9 @@ class InputEntry{
|
||||
final String name;
|
||||
final String initials;
|
||||
const InputEntry(this.name, this.initials);
|
||||
|
||||
}
|
||||
|
||||
class _FilterChipDemoState extends State<FilterChipDemo> {
|
||||
|
||||
final List<InputEntry> _lists = <InputEntry>[
|
||||
const InputEntry('android', 'A'),
|
||||
const InputEntry('java', 'J'),
|
||||
@ -41,9 +39,7 @@ Iterable<Widget> get inputWidget sync*{
|
||||
setState(() {
|
||||
_lists.remove(value);
|
||||
});
|
||||
|
||||
},
|
||||
|
||||
),
|
||||
);
|
||||
}
|
||||
@ -63,12 +59,6 @@ Iterable<Widget> get inputWidget sync*{
|
||||
// },
|
||||
// )
|
||||
],
|
||||
|
||||
|
||||
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
@ -16,7 +16,6 @@ class InputEntry{
|
||||
}
|
||||
|
||||
class _FilterChipDemoState extends State<FilterChipDemo> {
|
||||
|
||||
final List<InputEntry> _lists = <InputEntry>[
|
||||
const InputEntry('android', 'A'),
|
||||
const InputEntry('java', 'J'),
|
||||
@ -38,10 +37,8 @@ Iterable<Widget> get _rawChipWidget sync*{
|
||||
// _inputs.add(value.name);
|
||||
setState(() {
|
||||
_lists.remove(value);
|
||||
|
||||
});
|
||||
},
|
||||
|
||||
),
|
||||
);
|
||||
}
|
||||
@ -54,11 +51,7 @@ Iterable<Widget> get _rawChipWidget sync*{
|
||||
Wrap(
|
||||
children: _rawChipWidget.toList(),
|
||||
),
|
||||
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
@ -12,7 +12,6 @@ class AboutDialogDemo extends StatefulWidget {
|
||||
}
|
||||
|
||||
class _Demo extends State<AboutDialogDemo> {
|
||||
|
||||
void showAlertDialog(BuildContext context) {
|
||||
showDialog(
|
||||
context: context,
|
||||
@ -20,11 +19,9 @@ class _Demo extends State<AboutDialogDemo> {
|
||||
applicationName: '名称',
|
||||
applicationIcon: Icon(Icons.ac_unit),
|
||||
applicationVersion: 'V1.0',
|
||||
children: <Widget>[
|
||||
Text('我是一个关于的dialog')
|
||||
]
|
||||
));
|
||||
children: <Widget>[Text('我是一个关于的dialog')]));
|
||||
}
|
||||
|
||||
Widget build(BuildContext context) {
|
||||
return RaisedButton(
|
||||
padding: EdgeInsets.fromLTRB(10.0, 10.0, 10.0, 10.0),
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user