diff --git a/assets/fonts/SourceHanSans.otf b/assets/fonts/SourceHanSans.otf new file mode 100644 index 0000000..091f56d Binary files /dev/null and b/assets/fonts/SourceHanSans.otf differ diff --git a/lib/app/convert.dart b/lib/app/convert.dart index fc45ebd..d52c8bf 100644 --- a/lib/app/convert.dart +++ b/lib/app/convert.dart @@ -1,4 +1,4 @@ -import 'package:flutter_unit_mac/app/enums.dart'; +import 'package:flutter_unit/app/enums.dart'; /// create by 张风捷特烈 on 2020-03-07 /// contact me by email 1981462002@qq.com diff --git a/lib/app/res/cons.dart b/lib/app/res/cons.dart index 2437aa9..3c0ab93 100644 --- a/lib/app/res/cons.dart +++ b/lib/app/res/cons.dart @@ -1,6 +1,6 @@ import 'package:flutter/material.dart'; -import 'package:flutter_unit_mac/app/style/TolyIcon.dart'; -import 'package:flutter_unit_mac/components/permanent/code/highlighter_style.dart'; +import 'package:flutter_unit/app/res/toly_icon.dart'; +import 'package:flutter_unit/views/components/permanent/code/highlighter_style.dart'; class Cons { static String version = 'V1.1.0'; diff --git a/lib/app/style/TolyIcon.dart b/lib/app/res/toly_icon.dart similarity index 100% rename from lib/app/style/TolyIcon.dart rename to lib/app/res/toly_icon.dart diff --git a/lib/app/router.dart b/lib/app/router.dart index adb7f3e..a226daf 100644 --- a/lib/app/router.dart +++ b/lib/app/router.dart @@ -1,26 +1,26 @@ import 'package:flutter/material.dart'; -import 'package:flutter_unit_mac/views/app/navigation/unit_navigation.dart'; -import 'package:flutter_unit_mac/views/pages/about/about_me_page.dart'; -import 'package:flutter_unit_mac/views/pages/about/about_app_page.dart'; -import 'package:flutter_unit_mac/views/pages/category/category_show.dart'; -import 'package:flutter_unit_mac/views/pages/category/collect_page.dart'; -import 'package:flutter_unit_mac/views/pages/search/serach_page.dart'; -import 'package:flutter_unit_mac/views/pages/setting/code_style_setting.dart'; -import 'package:flutter_unit_mac/views/pages/setting/font_setting.dart'; -import 'package:flutter_unit_mac/views/pages/setting/item_style_setting.dart'; -import 'package:flutter_unit_mac/views/pages/setting/theme_color_setting.dart'; -import 'package:flutter_unit_mac/views/pages/unit_todo/attr_unit_page.dart'; -import 'package:flutter_unit_mac/views/pages/unit_todo/bug_unit_page.dart'; +import 'package:flutter_unit/views/pages/about/about_me_page.dart'; +import 'package:flutter_unit/views/pages/about/about_app_page.dart'; +import 'package:flutter_unit/views/pages/app/navigation/unit_navigation.dart'; +import 'package:flutter_unit/views/pages/category/category_show.dart'; +import 'package:flutter_unit/views/pages/category/collect_page.dart'; +import 'package:flutter_unit/views/pages/search/serach_page.dart'; +import 'package:flutter_unit/views/pages/setting/code_style_setting.dart'; +import 'package:flutter_unit/views/pages/setting/font_setting.dart'; +import 'package:flutter_unit/views/pages/setting/item_style_setting.dart'; +import 'package:flutter_unit/views/pages/setting/theme_color_setting.dart'; +import 'package:flutter_unit/views/pages/unit_todo/attr_unit_page.dart'; +import 'package:flutter_unit/views/pages/unit_todo/bug_unit_page.dart'; -import 'package:flutter_unit_mac/views/pages/detail/widget_detail_page.dart'; -import 'package:flutter_unit_mac/views/pages/unit_todo/layout_unit_page.dart'; -import 'package:flutter_unit_mac/views/pages/unit_todo/paint_unit_page.dart'; -import 'package:flutter_unit_mac/views/pages/setting/setting_page.dart'; +import 'package:flutter_unit/views/pages/detail/widget_detail_page.dart'; +import 'package:flutter_unit/views/pages/unit_todo/layout_unit_page.dart'; +import 'package:flutter_unit/views/pages/unit_todo/paint_unit_page.dart'; +import 'package:flutter_unit/views/pages/setting/setting_page.dart'; import 'utils/router_utils.dart'; -class Router { +class UnitRouter { static const String detail = 'detail'; static const String home = '/'; static const String logo = 'logo'; diff --git a/lib/blocs/category/category_bloc.dart b/lib/blocs/category/category_bloc.dart index 3d860cf..bc20dd1 100644 --- a/lib/blocs/category/category_bloc.dart +++ b/lib/blocs/category/category_bloc.dart @@ -1,9 +1,9 @@ import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; -import 'package:flutter_unit_mac/app/style/unit_color.dart'; -import 'package:flutter_unit_mac/app/utils/color_utils.dart'; -import 'package:flutter_unit_mac/repositories/itf/category_repository.dart'; -import 'package:flutter_unit_mac/storage/po/category_po.dart'; +import 'package:flutter_unit/app/style/unit_color.dart'; +import 'package:flutter_unit/app/utils/color_utils.dart'; +import 'package:flutter_unit/repositories/itf/category_repository.dart'; +import 'package:flutter_unit/storage/po/category_po.dart'; import 'category_event.dart'; import 'category_state.dart'; diff --git a/lib/blocs/category/category_state.dart b/lib/blocs/category/category_state.dart index 5d38536..4f7ca4c 100644 --- a/lib/blocs/category/category_state.dart +++ b/lib/blocs/category/category_state.dart @@ -1,6 +1,6 @@ import 'package:equatable/equatable.dart'; -import 'package:flutter_unit_mac/model/category_model.dart'; -import 'package:flutter_unit_mac/model/widget_model.dart'; +import 'package:flutter_unit/model/category_model.dart'; +import 'package:flutter_unit/model/widget_model.dart'; /// create by 张风捷特烈 on 2020-04-21 /// contact me by email 1981462002@qq.com diff --git a/lib/blocs/category_widget/category_widget_bloc.dart b/lib/blocs/category_widget/category_widget_bloc.dart index dc53004..0757abc 100644 --- a/lib/blocs/category_widget/category_widget_bloc.dart +++ b/lib/blocs/category_widget/category_widget_bloc.dart @@ -1,8 +1,8 @@ import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; -import 'package:flutter_unit_mac/blocs/category/category_bloc.dart'; -import 'package:flutter_unit_mac/blocs/category/category_event.dart'; -import 'package:flutter_unit_mac/repositories/itf/category_repository.dart'; +import 'package:flutter_unit/blocs/category/category_bloc.dart'; +import 'package:flutter_unit/blocs/category/category_event.dart'; +import 'package:flutter_unit/repositories/itf/category_repository.dart'; import 'category_widget_event.dart'; import 'category_widget_state.dart'; diff --git a/lib/blocs/category_widget/category_widget_state.dart b/lib/blocs/category_widget/category_widget_state.dart index 29dc61c..6b2677b 100644 --- a/lib/blocs/category_widget/category_widget_state.dart +++ b/lib/blocs/category_widget/category_widget_state.dart @@ -1,6 +1,6 @@ import 'package:equatable/equatable.dart'; -import 'package:flutter_unit_mac/model/category_model.dart'; -import 'package:flutter_unit_mac/model/widget_model.dart'; +import 'package:flutter_unit/model/category_model.dart'; +import 'package:flutter_unit/model/widget_model.dart'; /// create by 张风捷特烈 on 2020-04-21 /// contact me by email 1981462002@qq.com diff --git a/lib/blocs/collect/collect_bloc.dart b/lib/blocs/collect/collect_bloc.dart index 73dcb50..0a32535 100644 --- a/lib/blocs/collect/collect_bloc.dart +++ b/lib/blocs/collect/collect_bloc.dart @@ -1,8 +1,8 @@ import 'package:equatable/equatable.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; -import 'package:flutter_unit_mac/storage/dao/widget_dao.dart'; -import 'package:flutter_unit_mac/repositories/itf/widget_repository.dart'; +import 'package:flutter_unit/storage/dao/widget_dao.dart'; +import 'package:flutter_unit/repositories/itf/widget_repository.dart'; import 'collect_event.dart'; import 'collect_state.dart'; diff --git a/lib/blocs/collect/collect_event.dart b/lib/blocs/collect/collect_event.dart index 0fda95a..f351d4d 100644 --- a/lib/blocs/collect/collect_event.dart +++ b/lib/blocs/collect/collect_event.dart @@ -1,5 +1,5 @@ import 'package:equatable/equatable.dart'; -import 'package:flutter_unit_mac/model/widget_model.dart'; +import 'package:flutter_unit/model/widget_model.dart'; /// create by 张风捷特烈 on 2020-04-09 /// contact me by email 1981462002@qq.com diff --git a/lib/blocs/collect/collect_state.dart b/lib/blocs/collect/collect_state.dart index 45e6194..4c699fd 100644 --- a/lib/blocs/collect/collect_state.dart +++ b/lib/blocs/collect/collect_state.dart @@ -1,5 +1,5 @@ import 'package:equatable/equatable.dart'; -import 'package:flutter_unit_mac/model/widget_model.dart'; +import 'package:flutter_unit/model/widget_model.dart'; /// create by 张风捷特烈 on 2020-04-09 /// contact me by email 1981462002@qq.com diff --git a/lib/blocs/detail/detail_bloc.dart b/lib/blocs/detail/detail_bloc.dart index c4a2184..e90f99a 100644 --- a/lib/blocs/detail/detail_bloc.dart +++ b/lib/blocs/detail/detail_bloc.dart @@ -1,7 +1,7 @@ import 'package:flutter/cupertino.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; -import 'package:flutter_unit_mac/model/widget_model.dart'; -import 'package:flutter_unit_mac/repositories/itf/widget_repository.dart'; +import 'package:flutter_unit/model/widget_model.dart'; +import 'package:flutter_unit/repositories/itf/widget_repository.dart'; import 'detail_event.dart'; import 'detail_state.dart'; diff --git a/lib/blocs/detail/detail_event.dart b/lib/blocs/detail/detail_event.dart index a5a75c9..9229b87 100644 --- a/lib/blocs/detail/detail_event.dart +++ b/lib/blocs/detail/detail_event.dart @@ -1,5 +1,5 @@ import 'package:equatable/equatable.dart'; -import 'package:flutter_unit_mac/model/widget_model.dart'; +import 'package:flutter_unit/model/widget_model.dart'; /// create by 张风捷特烈 on 2020-03-03 diff --git a/lib/blocs/detail/detail_state.dart b/lib/blocs/detail/detail_state.dart index f66c351..5681c31 100644 --- a/lib/blocs/detail/detail_state.dart +++ b/lib/blocs/detail/detail_state.dart @@ -1,7 +1,7 @@ import 'package:equatable/equatable.dart'; import 'package:flutter/material.dart'; -import 'package:flutter_unit_mac/model/node_model.dart'; -import 'package:flutter_unit_mac/model/widget_model.dart'; +import 'package:flutter_unit/model/node_model.dart'; +import 'package:flutter_unit/model/widget_model.dart'; /// create by 张风捷特烈 on 2020-03-03 diff --git a/lib/blocs/global/global_bloc.dart b/lib/blocs/global/global_bloc.dart index f4a3121..eca10a5 100644 --- a/lib/blocs/global/global_bloc.dart +++ b/lib/blocs/global/global_bloc.dart @@ -1,7 +1,7 @@ import 'package:flutter_bloc/flutter_bloc.dart'; -import 'package:flutter_unit_mac/storage/app_storage.dart'; -import 'package:flutter_unit_mac/app/res/cons.dart'; -import 'package:flutter_unit_mac/app/res/sp.dart'; +import 'package:flutter_unit/storage/app_storage.dart'; +import 'package:flutter_unit/app/res/cons.dart'; +import 'package:flutter_unit/app/res/sp.dart'; import 'package:shared_preferences/shared_preferences.dart'; import 'global_event.dart'; diff --git a/lib/blocs/global/global_state.dart b/lib/blocs/global/global_state.dart index 290c914..caf45db 100644 --- a/lib/blocs/global/global_state.dart +++ b/lib/blocs/global/global_state.dart @@ -1,6 +1,6 @@ import 'package:equatable/equatable.dart'; import 'package:flutter/material.dart'; -import 'package:flutter_unit_mac/storage/po/node_po.dart'; +import 'package:flutter_unit/storage/po/node_po.dart'; class GlobalState extends Equatable { final String fontFamily; @@ -10,7 +10,7 @@ class GlobalState extends Equatable { final int itemStyleIndex; const GlobalState({ - this.fontFamily = 'ComicNeue', + this.fontFamily = 'SourceHanSans', this.themeColor = Colors.blue, this.showBackGround = true, this.codeStyleIndex, diff --git a/lib/blocs/home/home_bloc.dart b/lib/blocs/home/home_bloc.dart index 053d457..c08d224 100644 --- a/lib/blocs/home/home_bloc.dart +++ b/lib/blocs/home/home_bloc.dart @@ -3,9 +3,9 @@ import 'dart:math'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; -import 'package:flutter_unit_mac/app/enums.dart'; -import 'package:flutter_unit_mac/app/res/cons.dart'; -import 'package:flutter_unit_mac/repositories/itf/widget_repository.dart'; +import 'package:flutter_unit/app/enums.dart'; +import 'package:flutter_unit/app/res/cons.dart'; +import 'package:flutter_unit/repositories/itf/widget_repository.dart'; import 'home_event.dart'; import 'home_state.dart'; diff --git a/lib/blocs/home/home_event.dart b/lib/blocs/home/home_event.dart index 3dbc1bb..690565b 100644 --- a/lib/blocs/home/home_event.dart +++ b/lib/blocs/home/home_event.dart @@ -1,8 +1,8 @@ import 'package:equatable/equatable.dart'; import 'package:flutter/material.dart'; -import 'package:flutter_unit_mac/app/enums.dart'; -import 'package:flutter_unit_mac/storage/po/widget_po.dart'; -import 'package:flutter_unit_mac/model/widget_model.dart'; +import 'package:flutter_unit/app/enums.dart'; +import 'package:flutter_unit/storage/po/widget_po.dart'; +import 'package:flutter_unit/model/widget_model.dart'; /// create by 张风捷特烈 on 2020-03-03 diff --git a/lib/blocs/home/home_state.dart b/lib/blocs/home/home_state.dart index c14007c..45edb67 100644 --- a/lib/blocs/home/home_state.dart +++ b/lib/blocs/home/home_state.dart @@ -1,6 +1,6 @@ import 'package:equatable/equatable.dart'; import 'package:flutter/material.dart'; -import 'package:flutter_unit_mac/model/widget_model.dart'; +import 'package:flutter_unit/model/widget_model.dart'; /// create by 张风捷特烈 on 2020-03-03 /// contact me by email 1981462002@qq.com diff --git a/lib/blocs/search/search_bloc.dart b/lib/blocs/search/search_bloc.dart index aa5ef6a..703cfcc 100644 --- a/lib/blocs/search/search_bloc.dart +++ b/lib/blocs/search/search_bloc.dart @@ -1,7 +1,7 @@ import 'package:flutter/material.dart'; -import 'package:flutter_unit_mac/repositories/itf/widget_repository.dart'; +import 'package:flutter_unit/repositories/itf/widget_repository.dart'; import 'search_event.dart'; import 'search_state.dart'; diff --git a/lib/blocs/search/search_event.dart b/lib/blocs/search/search_event.dart index 1dee7db..9738098 100644 --- a/lib/blocs/search/search_event.dart +++ b/lib/blocs/search/search_event.dart @@ -1,6 +1,6 @@ -import 'package:flutter_unit_mac/storage/dao/widget_dao.dart'; +import 'package:flutter_unit/storage/dao/widget_dao.dart'; abstract class SearchEvent{//事件基 const SearchEvent(); diff --git a/lib/blocs/search/search_state.dart b/lib/blocs/search/search_state.dart index 06c735b..60254a3 100644 --- a/lib/blocs/search/search_state.dart +++ b/lib/blocs/search/search_state.dart @@ -1,6 +1,6 @@ -import 'package:flutter_unit_mac/model/widget_model.dart'; +import 'package:flutter_unit/model/widget_model.dart'; abstract class SearchState {//基态 const SearchState(); diff --git a/lib/components/flutter/no_div_expansion_tile.dart b/lib/components/flutter/no_div_expansion_tile.dart deleted file mode 100644 index 4cb93ff..0000000 --- a/lib/components/flutter/no_div_expansion_tile.dart +++ /dev/null @@ -1,205 +0,0 @@ -// Copyright 2017 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -import 'package:flutter/material.dart'; -import 'package:flutter/widgets.dart'; - - -const Duration _kExpand = Duration(milliseconds: 200); - -/// A single-line [ListTile] with a trailing button that expands or collapses -/// the tile to reveal or hide the [children]. -/// -/// This widget is typically used with [ListView] to create an -/// "expand / collapse" list entry. When used with scrolling widgets like -/// [ListView], a unique [PageStorageKey] must be specified to enable the -/// [NoBorderExpansionTile] to save and restore its expanded state when it is scrolled -/// in and out of view. -/// -/// See also: -/// -/// * [ListTile], useful for creating expansion tile [children] when the -/// expansion tile represents a sublist. -/// * The "Expand/collapse" section of -/// . -class NoBorderExpansionTile extends StatefulWidget { - /// Creates a single-line [ListTile] with a trailing button that expands or collapses - /// the tile to reveal or hide the [children]. The [initiallyExpanded] property must - /// be non-null. - const NoBorderExpansionTile({ - Key key, - this.leading, - @required this.title, - this.subtitle, - this.backgroundColor, - this.onExpansionChanged, - this.children = const [], - this.trailing, - this.initiallyExpanded = false, - }) : assert(initiallyExpanded != null), - super(key: key); - - /// A widget to display before the title. - /// - /// Typically a [CircleAvatar] widget. - final Widget leading; - - /// The primary content of the list item. - /// - /// Typically a [Text] widget. - final Widget title; - - /// Additional content displayed below the title. - /// - /// Typically a [Text] widget. - final Widget subtitle; - - /// Called when the tile expands or collapses. - /// - /// When the tile starts expanding, this function is called with the value - /// true. When the tile starts collapsing, this function is called with - /// the value false. - final ValueChanged onExpansionChanged; - - /// The widgets that are displayed when the tile expands. - /// - /// Typically [ListTile] widgets. - final List children; - - /// The color to display behind the sublist when expanded. - final Color backgroundColor; - - /// A widget to display instead of a rotating arrow icon. - final Widget trailing; - - /// Specifies if the list tile is initially expanded (true) or collapsed (false, the default). - final bool initiallyExpanded; - - @override - _NoBorderExpansionTileState createState() => _NoBorderExpansionTileState(); -} - -class _NoBorderExpansionTileState extends State with SingleTickerProviderStateMixin { - static final Animatable _easeOutTween = CurveTween(curve: Curves.easeOut); - static final Animatable _easeInTween = CurveTween(curve: Curves.easeIn); - static final Animatable _halfTween = Tween(begin: 0.0, end: 0.5); - - final ColorTween _borderColorTween = ColorTween(); - final ColorTween _headerColorTween = ColorTween(); - final ColorTween _iconColorTween = ColorTween(); - final ColorTween _backgroundColorTween = ColorTween(); - - AnimationController _controller; - Animation _iconTurns; - Animation _heightFactor; - Animation _borderColor; - Animation _headerColor; - Animation _iconColor; - Animation _backgroundColor; - - bool _isExpanded = false; - - @override - void initState() { - super.initState(); - _controller = AnimationController(duration: _kExpand, vsync: this); - _heightFactor = _controller.drive(_easeInTween); - _iconTurns = _controller.drive(_halfTween.chain(_easeInTween)); - _borderColor = _controller.drive(_borderColorTween.chain(_easeOutTween)); - _headerColor = _controller.drive(_headerColorTween.chain(_easeInTween)); - _iconColor = _controller.drive(_iconColorTween.chain(_easeInTween)); - _backgroundColor = _controller.drive(_backgroundColorTween.chain(_easeOutTween)); - - _isExpanded = PageStorage.of(context)?.readState(context) ?? widget.initiallyExpanded; - if (_isExpanded) - _controller.value = 1.0; - } - - - @override - void dispose() { - _controller.dispose(); - super.dispose(); - } - - void _handleTap() { - setState(() { - _isExpanded = !_isExpanded; - if (_isExpanded) { - _controller.forward(); - } else { - _controller.reverse().then((void value) { - if (!mounted) - return; - setState(() { - // Rebuild without widget.children. - }); - }); - } - PageStorage.of(context)?.writeState(context, _isExpanded); - }); - if (widget.onExpansionChanged != null) - widget.onExpansionChanged(_isExpanded); - } - - Widget _buildChildren(BuildContext context, Widget child) { - - return Container( - color: _backgroundColor.value ?? Colors.transparent, - child: Column( - mainAxisSize: MainAxisSize.min, - children: [ - ListTileTheme.merge( - iconColor: _iconColor.value, - textColor: _headerColor.value, - child: ListTile( - onTap: _handleTap, - leading: widget.leading, - title: widget.title, - subtitle: widget.subtitle, - trailing: widget.trailing ?? RotationTransition( - turns: _iconTurns, - child: const Icon(Icons.expand_more), - ), - ), - ), - ClipRect( - child: Align( -// alignment: Alignment.topCenter, - heightFactor: _heightFactor.value, - child: child, - ), - ), - ], - ), - ); - } - - @override - void didChangeDependencies() { - final ThemeData theme = Theme.of(context); - _borderColorTween - ..end = theme.dividerColor; - _headerColorTween - ..begin = theme.textTheme.subhead.color - ..end = theme.accentColor; - _iconColorTween - ..begin = theme.unselectedWidgetColor - ..end = theme.accentColor; - _backgroundColorTween - ..end = widget.backgroundColor; - super.didChangeDependencies(); - } - - @override - Widget build(BuildContext context) { - final bool closed = !_isExpanded && _controller.isDismissed; - return AnimatedBuilder( - animation: _controller.view, - builder: _buildChildren, - child: closed ? null : Column(children: widget.children), - ); - - } -} diff --git a/lib/components/flutter/no_shadow_tab_bar.dart b/lib/components/flutter/no_shadow_tab_bar.dart deleted file mode 100644 index a1ae1ae..0000000 --- a/lib/components/flutter/no_shadow_tab_bar.dart +++ /dev/null @@ -1,1345 +0,0 @@ -/// create by 张风捷特烈 on 2020-03-16 -/// contact me by email 1981462002@qq.com -/// 说明: - -// Copyright 2015 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -import 'dart:async'; -import 'dart:ui' show lerpDouble; - -import 'package:flutter/material.dart'; -import 'package:flutter/rendering.dart'; -import 'package:flutter/widgets.dart'; -import 'package:flutter/gestures.dart' show DragStartBehavior; - - -const double _kTabHeight = 46.0; -const double _kTextAndIconTabHeight = 72.0; - -/// Defines how the bounds of the selected tab indicator are computed. -/// -/// See also: -/// -/// * [TabBar], which displays a row of tabs. -/// * [TabBarView], which displays a widget for the currently selected tab. -/// * [TabBar.indicator], which defines the appearance of the selected tab -/// indicator relative to the tab's bounds. -enum TabBarIndicatorSize { - /// The tab indicator's bounds are as wide as the space occupied by the tab - /// in the tab bar: from the right edge of the previous tab to the left edge - /// of the next tab. - tab, - - /// The tab's bounds are only as wide as the (centered) tab widget itself. - /// - /// This value is used to align the tab's label, typically a [Tab] - /// widget's text or icon, with the selected tab indicator. - label, -} - -class _TabStyle extends AnimatedWidget { - const _TabStyle({ - Key key, - Animation animation, - this.selected, - this.labelColor, - this.unselectedLabelColor, - this.labelStyle, - this.unselectedLabelStyle, - @required this.child, - }) : super(key: key, listenable: animation); - - final TextStyle labelStyle; - final TextStyle unselectedLabelStyle; - final bool selected; - final Color labelColor; - final Color unselectedLabelColor; - final Widget child; - - @override - Widget build(BuildContext context) { - final ThemeData themeData = Theme.of(context); - final TabBarTheme tabBarTheme = TabBarTheme.of(context); - final Animation animation = listenable; - - // To enable TextStyle.lerp(style1, style2, value), both styles must have - // the same value of inherit. Force that to be inherit=true here. - final TextStyle defaultStyle = (labelStyle - ?? tabBarTheme.labelStyle - ?? themeData.primaryTextTheme.body2 - ).copyWith(inherit: true); - final TextStyle defaultUnselectedStyle = (unselectedLabelStyle - ?? tabBarTheme.unselectedLabelStyle - ?? labelStyle - ?? themeData.primaryTextTheme.body2 - ).copyWith(inherit: true); - final TextStyle textStyle = selected - ? TextStyle.lerp(defaultStyle, defaultUnselectedStyle, animation.value) - : TextStyle.lerp(defaultUnselectedStyle, defaultStyle, animation.value); - - final Color selectedColor = labelColor - ?? tabBarTheme.labelColor - ?? themeData.primaryTextTheme.body2.color; - final Color unselectedColor = unselectedLabelColor - ?? tabBarTheme.unselectedLabelColor - ?? selectedColor.withAlpha(0xB2); // 70% alpha - final Color color = selected - ? Color.lerp(selectedColor, unselectedColor, animation.value) - : Color.lerp(unselectedColor, selectedColor, animation.value); - - return DefaultTextStyle( - style: textStyle.copyWith(color: color), - child: IconTheme.merge( - data: IconThemeData( - size: 24.0, - color: color, - ), - child: child, - ), - ); - } -} - -typedef _LayoutCallback = void Function(List xOffsets, TextDirection textDirection, double width); - -class _TabLabelBarRenderer extends RenderFlex { - _TabLabelBarRenderer({ - List children, - @required Axis direction, - @required MainAxisSize mainAxisSize, - @required MainAxisAlignment mainAxisAlignment, - @required CrossAxisAlignment crossAxisAlignment, - @required TextDirection textDirection, - @required VerticalDirection verticalDirection, - @required this.onPerformLayout, - }) : assert(onPerformLayout != null), - assert(textDirection != null), - super( - children: children, - direction: direction, - mainAxisSize: mainAxisSize, - mainAxisAlignment: mainAxisAlignment, - crossAxisAlignment: crossAxisAlignment, - textDirection: textDirection, - verticalDirection: verticalDirection, - ); - - _LayoutCallback onPerformLayout; - - @override - void performLayout() { - super.performLayout(); - // xOffsets will contain childCount+1 values, giving the offsets of the - // leading edge of the first tab as the first value, of the leading edge of - // the each subsequent tab as each subsequent value, and of the trailing - // edge of the last tab as the last value. - RenderBox child = firstChild; - final List xOffsets = []; - while (child != null) { - final FlexParentData childParentData = child.parentData; - xOffsets.add(childParentData.offset.dx); - assert(child.parentData == childParentData); - child = childParentData.nextSibling; - } - assert(textDirection != null); - switch (textDirection) { - case TextDirection.rtl: - xOffsets.insert(0, size.width); - break; - case TextDirection.ltr: - xOffsets.add(size.width); - break; - } - onPerformLayout(xOffsets, textDirection, size.width); - } -} - -// This class and its renderer class only exist to report the widths of the tabs -// upon layout. The tab widths are only used at paint time (see _IndicatorPainter) -// or in response to input. -class _TabLabelBar extends Flex { - _TabLabelBar({ - Key key, - List children = const [], - this.onPerformLayout, - }) : super( - key: key, - children: children, - direction: Axis.horizontal, - mainAxisSize: MainAxisSize.max, - mainAxisAlignment: MainAxisAlignment.start, - crossAxisAlignment: CrossAxisAlignment.center, - verticalDirection: VerticalDirection.down, - ); - - final _LayoutCallback onPerformLayout; - - @override - RenderFlex createRenderObject(BuildContext context) { - return _TabLabelBarRenderer( - direction: direction, - mainAxisAlignment: mainAxisAlignment, - mainAxisSize: mainAxisSize, - crossAxisAlignment: crossAxisAlignment, - textDirection: getEffectiveTextDirection(context), - verticalDirection: verticalDirection, - onPerformLayout: onPerformLayout, - ); - } - - @override - void updateRenderObject(BuildContext context, _TabLabelBarRenderer renderObject) { - super.updateRenderObject(context, renderObject); - renderObject.onPerformLayout = onPerformLayout; - } -} - -double _indexChangeProgress(TabController controller) { - final double controllerValue = controller.animation.value; - final double previousIndex = controller.previousIndex.toDouble(); - final double currentIndex = controller.index.toDouble(); - - // The controller's offset is changing because the user is dragging the - // TabBarView's PageView to the left or right. - if (!controller.indexIsChanging) - return (currentIndex - controllerValue).abs().clamp(0.0, 1.0); - - // The TabController animation's value is changing from previousIndex to currentIndex. - return (controllerValue - currentIndex).abs() / (currentIndex - previousIndex).abs(); -} - -class _IndicatorPainter extends CustomPainter { - _IndicatorPainter({ - @required this.controller, - @required this.indicator, - @required this.indicatorSize, - @required this.tabKeys, - _IndicatorPainter old, - }) : assert(controller != null), - assert(indicator != null), - super(repaint: controller.animation) { - if (old != null) - saveTabOffsets(old._currentTabOffsets, old._currentTextDirection); - } - - final TabController controller; - final Decoration indicator; - final TabBarIndicatorSize indicatorSize; - final List tabKeys; - - List _currentTabOffsets; - TextDirection _currentTextDirection; - Rect _currentRect; - BoxPainter _painter; - bool _needsPaint = false; - void markNeedsPaint() { - _needsPaint = true; - } - - void dispose() { - _painter?.dispose(); - } - - void saveTabOffsets(List tabOffsets, TextDirection textDirection) { - _currentTabOffsets = tabOffsets; - _currentTextDirection = textDirection; - } - - // _currentTabOffsets[index] is the offset of the start edge of the tab at index, and - // _currentTabOffsets[_currentTabOffsets.length] is the end edge of the last tab. - int get maxTabIndex => _currentTabOffsets.length - 2; - - double centerOf(int tabIndex) { - assert(_currentTabOffsets != null); - assert(_currentTabOffsets.isNotEmpty); - assert(tabIndex >= 0); - assert(tabIndex <= maxTabIndex); - return (_currentTabOffsets[tabIndex] + _currentTabOffsets[tabIndex + 1]) / 2.0; - } - - Rect indicatorRect(Size tabBarSize, int tabIndex) { - assert(_currentTabOffsets != null); - assert(_currentTextDirection != null); - assert(_currentTabOffsets.isNotEmpty); - assert(tabIndex >= 0); - assert(tabIndex <= maxTabIndex); - double tabLeft, tabRight; - switch (_currentTextDirection) { - case TextDirection.rtl: - tabLeft = _currentTabOffsets[tabIndex + 1]; - tabRight = _currentTabOffsets[tabIndex]; - break; - case TextDirection.ltr: - tabLeft = _currentTabOffsets[tabIndex]; - tabRight = _currentTabOffsets[tabIndex + 1]; - break; - } - - if (indicatorSize == TabBarIndicatorSize.label) { - final double tabWidth = tabKeys[tabIndex].currentContext.size.width; - final double delta = ((tabRight - tabLeft) - tabWidth) / 2.0; - tabLeft += delta; - tabRight -= delta; - } - - return Rect.fromLTWH(tabLeft, 0.0, tabRight - tabLeft, tabBarSize.height); - } - - @override - void paint(Canvas canvas, Size size) { - _needsPaint = false; - _painter ??= indicator.createBoxPainter(markNeedsPaint); - - if (controller.indexIsChanging) { - // The user tapped on a tab, the tab controller's animation is running. - final Rect targetRect = indicatorRect(size, controller.index); - _currentRect = Rect.lerp(targetRect, _currentRect ?? targetRect, _indexChangeProgress(controller)); - } else { - // The user is dragging the TabBarView's PageView left or right. - final int currentIndex = controller.index; - final Rect previous = currentIndex > 0 ? indicatorRect(size, currentIndex - 1) : null; - final Rect middle = indicatorRect(size, currentIndex); - final Rect next = currentIndex < maxTabIndex ? indicatorRect(size, currentIndex + 1) : null; - final double index = controller.index.toDouble(); - final double value = controller.animation.value; - if (value == index - 1.0) - _currentRect = previous ?? middle; - else if (value == index + 1.0) - _currentRect = next ?? middle; - else if (value == index) - _currentRect = middle; - else if (value < index) - _currentRect = previous == null ? middle : Rect.lerp(middle, previous, index - value); - else - _currentRect = next == null ? middle : Rect.lerp(middle, next, value - index); - } - assert(_currentRect != null); - - final ImageConfiguration configuration = ImageConfiguration( - size: _currentRect.size, - textDirection: _currentTextDirection, - ); - _painter.paint(canvas, _currentRect.topLeft, configuration); - } - - static bool _tabOffsetsEqual(List a, List b) { - // TODO(shihaohong): The following null check should be replaced when a fix - // for https://github.com/flutter/flutter/issues/40014 is available. - if (a == null || b == null || a.length != b.length) - return false; - for (int i = 0; i < a.length; i += 1) { - if (a[i] != b[i]) - return false; - } - return true; - } - - @override - bool shouldRepaint(_IndicatorPainter old) { - return _needsPaint - || controller != old.controller - || indicator != old.indicator - || tabKeys.length != old.tabKeys.length - || (!_tabOffsetsEqual(_currentTabOffsets, old._currentTabOffsets)) - || _currentTextDirection != old._currentTextDirection; - } -} - -class _ChangeAnimation extends Animation with AnimationWithParentMixin { - _ChangeAnimation(this.controller); - - final TabController controller; - - @override - Animation get parent => controller.animation; - - @override - void removeStatusListener(AnimationStatusListener listener) { - if (parent != null) - super.removeStatusListener(listener); - } - - @override - void removeListener(VoidCallback listener) { - if (parent != null) - super.removeListener(listener); - } - - @override - double get value => _indexChangeProgress(controller); -} - -class _DragAnimation extends Animation with AnimationWithParentMixin { - _DragAnimation(this.controller, this.index); - - final TabController controller; - final int index; - - @override - Animation get parent => controller.animation; - - @override - void removeStatusListener(AnimationStatusListener listener) { - if (parent != null) - super.removeStatusListener(listener); - } - - @override - void removeListener(VoidCallback listener) { - if (parent != null) - super.removeListener(listener); - } - - @override - double get value { - assert(!controller.indexIsChanging); - return (controller.animation.value - index.toDouble()).abs().clamp(0.0, 1.0); - } -} - -// This class, and TabBarScrollController, only exist to handle the case -// where a scrollable TabBar has a non-zero initialIndex. In that case we can -// only compute the scroll position's initial scroll offset (the "correct" -// pixels value) after the TabBar viewport width and scroll limits are known. -class _TabBarScrollPosition extends ScrollPositionWithSingleContext { - _TabBarScrollPosition({ - ScrollPhysics physics, - ScrollContext context, - ScrollPosition oldPosition, - this.tabBar, - }) : super( - physics: physics, - context: context, - initialPixels: null, - oldPosition: oldPosition, - ); - - final _TabBarState tabBar; - - bool _initialViewportDimensionWasZero; - - @override - bool applyContentDimensions(double minScrollExtent, double maxScrollExtent) { - bool result = true; - if (_initialViewportDimensionWasZero != true) { - // If the viewport never had a non-zero dimension, we just want to jump - // to the initial scroll position to avoid strange scrolling effects in - // release mode: In release mode, the viewport temporarily may have a - // dimension of zero before the actual dimension is calculated. In that - // scenario, setting the actual dimension would cause a strange scroll - // effect without this guard because the super call below would starts a - // ballistic scroll activity. - assert(viewportDimension != null); - _initialViewportDimensionWasZero = viewportDimension != 0.0; - correctPixels(tabBar._initialScrollOffset(viewportDimension, minScrollExtent, maxScrollExtent)); - result = false; - } - return super.applyContentDimensions(minScrollExtent, maxScrollExtent) && result; - } -} - -// This class, and TabBarScrollPosition, only exist to handle the case -// where a scrollable TabBar has a non-zero initialIndex. -class _TabBarScrollController extends ScrollController { - _TabBarScrollController(this.tabBar); - - final _TabBarState tabBar; - - @override - ScrollPosition createScrollPosition(ScrollPhysics physics, ScrollContext context, ScrollPosition oldPosition) { - return _TabBarScrollPosition( - physics: physics, - context: context, - oldPosition: oldPosition, - tabBar: tabBar, - ); - } -} - -/// A material design widget that displays a horizontal row of tabs. -/// -/// Typically created as the [AppBar.bottom] part of an [AppBar] and in -/// conjunction with a [TabBarView]. -/// -/// If a [TabController] is not provided, then a [DefaultTabController] ancestor -/// must be provided instead. The tab controller's [TabController.length] must -/// equal the length of the [tabs] list and the length of the -/// [TabBarView.children] list. -/// -/// Requires one of its ancestors to be a [Material] widget. -/// -/// Uses values from [TabBarTheme] if it is set in the current context. -/// -/// To see a sample implementation, visit the [TabController] documentation. -/// -/// See also: -/// -/// * [TabBarView], which displays page views that correspond to each tab. -class NoShadowTabBar extends StatefulWidget implements PreferredSizeWidget { - /// Creates a material design tab bar. - /// - /// The [tabs] argument must not be null and its length must match the [controller]'s - /// [TabController.length]. - /// - /// If a [TabController] is not provided, then there must be a - /// [DefaultTabController] ancestor. - /// - /// The [indicatorWeight] parameter defaults to 2, and must not be null. - /// - /// The [indicatorPadding] parameter defaults to [EdgeInsets.zero], and must not be null. - /// - /// If [indicator] is not null, then [indicatorWeight], [indicatorPadding], and - /// [indicatorColor] are ignored. - const NoShadowTabBar({ - Key key, - @required this.tabs, - this.controller, - this.isScrollable = false, - this.indicatorColor, - this.indicatorWeight = 2.0, - this.indicatorPadding = EdgeInsets.zero, - this.indicator, - this.indicatorSize, - this.labelColor, - this.labelStyle, - this.labelPadding, - this.unselectedLabelColor, - this.unselectedLabelStyle, - this.dragStartBehavior = DragStartBehavior.start, - this.onTap, - }) : assert(tabs != null), - assert(isScrollable != null), - assert(dragStartBehavior != null), - assert(indicator != null || (indicatorWeight != null && indicatorWeight > 0.0)), - assert(indicator != null || (indicatorPadding != null)), - super(key: key); - - /// Typically a list of two or more [Tab] widgets. - /// - /// The length of this list must match the [controller]'s [TabController.length] - /// and the length of the [TabBarView.children] list. - final List tabs; - - /// This widget's selection and animation state. - /// - /// If [TabController] is not provided, then the value of [DefaultTabController.of] - /// will be used. - final TabController controller; - - /// Whether this tab bar can be scrolled horizontally. - /// - /// If [isScrollable] is true, then each tab is as wide as needed for its label - /// and the entire [TabBar] is scrollable. Otherwise each tab gets an equal - /// share of the available space. - final bool isScrollable; - - /// The color of the line that appears below the selected tab. - /// - /// If this parameter is null, then the value of the Theme's indicatorColor - /// property is used. - /// - /// If [indicator] is specified, this property is ignored. - final Color indicatorColor; - - /// The thickness of the line that appears below the selected tab. - /// - /// The value of this parameter must be greater than zero and its default - /// value is 2.0. - /// - /// If [indicator] is specified, this property is ignored. - final double indicatorWeight; - - /// The horizontal padding for the line that appears below the selected tab. - /// - /// For [isScrollable] tab bars, specifying [kTabLabelPadding] will align - /// the indicator with the tab's text for [Tab] widgets and all but the - /// shortest [Tab.text] values. - /// - /// The [EdgeInsets.top] and [EdgeInsets.bottom] values of the - /// [indicatorPadding] are ignored. - /// - /// The default value of [indicatorPadding] is [EdgeInsets.zero]. - /// - /// If [indicator] is specified, this property is ignored. - final EdgeInsetsGeometry indicatorPadding; - - /// Defines the appearance of the selected tab indicator. - /// - /// If [indicator] is specified, the [indicatorColor], [indicatorWeight], - /// and [indicatorPadding] properties are ignored. - /// - /// The default, underline-style, selected tab indicator can be defined with - /// [UnderlineTabIndicator]. - /// - /// The indicator's size is based on the tab's bounds. If [indicatorSize] - /// is [TabBarIndicatorSize.tab] the tab's bounds are as wide as the space - /// occupied by the tab in the tab bar. If [indicatorSize] is - /// [TabBarIndicatorSize.label], then the tab's bounds are only as wide as - /// the tab widget itself. - final Decoration indicator; - - /// Defines how the selected tab indicator's size is computed. - /// - /// The size of the selected tab indicator is defined relative to the - /// tab's overall bounds if [indicatorSize] is [TabBarIndicatorSize.tab] - /// (the default) or relative to the bounds of the tab's widget if - /// [indicatorSize] is [TabBarIndicatorSize.label]. - /// - /// The selected tab's location appearance can be refined further with - /// the [indicatorColor], [indicatorWeight], [indicatorPadding], and - /// [indicator] properties. - final TabBarIndicatorSize indicatorSize; - - /// The color of selected tab labels. - /// - /// Unselected tab labels are rendered with the same color rendered at 70% - /// opacity unless [unselectedLabelColor] is non-null. - /// - /// If this parameter is null, then the color of the [ThemeData.primaryTextTheme]'s - /// body2 text color is used. - final Color labelColor; - - /// The color of unselected tab labels. - /// - /// If this property is null, unselected tab labels are rendered with the - /// [labelColor] with 70% opacity. - final Color unselectedLabelColor; - - /// The text style of the selected tab labels. - /// - /// If [unselectedLabelStyle] is null, then this text style will be used for - /// both selected and unselected label styles. - /// - /// If this property is null, then the text style of the - /// [ThemeData.primaryTextTheme]'s body2 definition is used. - final TextStyle labelStyle; - - /// The padding added to each of the tab labels. - /// - /// If this property is null, then kTabLabelPadding is used. - final EdgeInsetsGeometry labelPadding; - - /// The text style of the unselected tab labels - /// - /// If this property is null, then the [labelStyle] value is used. If [labelStyle] - /// is null, then the text style of the [ThemeData.primaryTextTheme]'s - /// body2 definition is used. - final TextStyle unselectedLabelStyle; - - /// {@macro flutter.widgets.scrollable.dragStartBehavior} - final DragStartBehavior dragStartBehavior; - - /// An optional callback that's called when the [TabBar] is tapped. - /// - /// The callback is applied to the index of the tab where the tap occurred. - /// - /// This callback has no effect on the default handling of taps. It's for - /// applications that want to do a little extra work when a tab is tapped, - /// even if the tap doesn't change the TabController's index. TabBar [onTap] - /// callbacks should not make changes to the TabController since that would - /// interfere with the default tap handler. - final ValueChanged onTap; - - /// A size whose height depends on if the tabs have both icons and text. - /// - /// [AppBar] uses this size to compute its own preferred size. - @override - Size get preferredSize { - for (Widget item in tabs) { - if (item is Tab) { - final Tab tab = item; - if (tab.text != null && tab.icon != null) - return Size.fromHeight(_kTextAndIconTabHeight + indicatorWeight); - } - } - return Size.fromHeight(_kTabHeight + indicatorWeight); - } - - @override - _TabBarState createState() => _TabBarState(); -} - -class _TabBarState extends State { - ScrollController _scrollController; - TabController _controller; - _IndicatorPainter _indicatorPainter; - int _currentIndex; - double _tabStripWidth; - List _tabKeys; - - @override - void initState() { - super.initState(); - // If indicatorSize is TabIndicatorSize.label, _tabKeys[i] is used to find - // the width of tab widget i. See _IndicatorPainter.indicatorRect(). - _tabKeys = widget.tabs.map((Widget tab) => GlobalKey()).toList(); - } - - Decoration get _indicator { - if (widget.indicator != null) - return widget.indicator; - final TabBarTheme tabBarTheme = TabBarTheme.of(context); - if (tabBarTheme.indicator != null) - return tabBarTheme.indicator; - - Color color = widget.indicatorColor ?? Theme.of(context).indicatorColor; - // ThemeData tries to avoid this by having indicatorColor avoid being the - // primaryColor. However, it's possible that the tab bar is on a - // Material that isn't the primaryColor. In that case, if the indicator - // color ends up matching the material's color, then this overrides it. - // When that happens, automatic transitions of the theme will likely look - // ugly as the indicator color suddenly snaps to white at one end, but it's - // not clear how to avoid that any further. - // - // The material's color might be null (if it's a transparency). In that case - // there's no good way for us to find out what the color is so we don't. - if (color.value == Material.of(context).color?.value) - color = Colors.white; - - return UnderlineTabIndicator( - insets: widget.indicatorPadding, - borderSide: BorderSide( - width: widget.indicatorWeight, - color: color, - ), - ); - } - - // If the TabBar is rebuilt with a new tab controller, the caller should - // dispose the old one. In that case the old controller's animation will be - // null and should not be accessed. - bool get _controllerIsValid => _controller?.animation != null; - - void _updateTabController() { - final TabController newController = widget.controller ?? DefaultTabController.of(context); - assert(() { - if (newController == null) { - throw FlutterError( - 'No TabController for ${widget.runtimeType}.\n' - 'When creating a ${widget.runtimeType}, you must either provide an explicit ' - 'TabController using the "controller" property, or you must ensure that there ' - 'is a DefaultTabController above the ${widget.runtimeType}.\n' - 'In this case, there was neither an explicit controller nor a default controller.' - ); - } - return true; - }()); - - if (newController == _controller) - return; - - if (_controllerIsValid) { - _controller.animation.removeListener(_handleTabControllerAnimationTick); - _controller.removeListener(_handleTabControllerTick); - } - _controller = newController; - if (_controller != null) { - _controller.animation.addListener(_handleTabControllerAnimationTick); - _controller.addListener(_handleTabControllerTick); - _currentIndex = _controller.index; - } - } - - void _initIndicatorPainter() { - _indicatorPainter = !_controllerIsValid ? null : _IndicatorPainter( - controller: _controller, - indicator: _indicator, - indicatorSize: widget.indicatorSize ?? TabBarTheme.of(context).indicatorSize, - tabKeys: _tabKeys, - old: _indicatorPainter, - ); - } - - @override - void didChangeDependencies() { - super.didChangeDependencies(); - assert(debugCheckHasMaterial(context)); - _updateTabController(); - _initIndicatorPainter(); - } - - @override - void didUpdateWidget(NoShadowTabBar oldWidget) { - super.didUpdateWidget(oldWidget); - if (widget.controller != oldWidget.controller) { - _updateTabController(); - _initIndicatorPainter(); - } else if (widget.indicatorColor != oldWidget.indicatorColor || - widget.indicatorWeight != oldWidget.indicatorWeight || - widget.indicatorSize != oldWidget.indicatorSize || - widget.indicator != oldWidget.indicator) { - _initIndicatorPainter(); - } - - if (widget.tabs.length > oldWidget.tabs.length) { - final int delta = widget.tabs.length - oldWidget.tabs.length; - _tabKeys.addAll(List.generate(delta, (int n) => GlobalKey())); - } else if (widget.tabs.length < oldWidget.tabs.length) { - _tabKeys.removeRange(widget.tabs.length, oldWidget.tabs.length); - } - } - - @override - void dispose() { - _indicatorPainter.dispose(); - if (_controllerIsValid) { - _controller.animation.removeListener(_handleTabControllerAnimationTick); - _controller.removeListener(_handleTabControllerTick); - } - _controller = null; - // We don't own the _controller Animation, so it's not disposed here. - super.dispose(); - } - - int get maxTabIndex => _indicatorPainter.maxTabIndex; - - double _tabScrollOffset(int index, double viewportWidth, double minExtent, double maxExtent) { - if (!widget.isScrollable) - return 0.0; - double tabCenter = _indicatorPainter.centerOf(index); - switch (Directionality.of(context)) { - case TextDirection.rtl: - tabCenter = _tabStripWidth - tabCenter; - break; - case TextDirection.ltr: - break; - } - return (tabCenter - viewportWidth / 2.0).clamp(minExtent, maxExtent); - } - - double _tabCenteredScrollOffset(int index) { - final ScrollPosition position = _scrollController.position; - return _tabScrollOffset(index, position.viewportDimension, position.minScrollExtent, position.maxScrollExtent); - } - - double _initialScrollOffset(double viewportWidth, double minExtent, double maxExtent) { - return _tabScrollOffset(_currentIndex, viewportWidth, minExtent, maxExtent); - } - - void _scrollToCurrentIndex() { - final double offset = _tabCenteredScrollOffset(_currentIndex); - _scrollController.animateTo(offset, duration: kTabScrollDuration, curve: Curves.ease); - } - - void _scrollToControllerValue() { - final double leadingPosition = _currentIndex > 0 ? _tabCenteredScrollOffset(_currentIndex - 1) : null; - final double middlePosition = _tabCenteredScrollOffset(_currentIndex); - final double trailingPosition = _currentIndex < maxTabIndex ? _tabCenteredScrollOffset(_currentIndex + 1) : null; - - final double index = _controller.index.toDouble(); - final double value = _controller.animation.value; - double offset; - if (value == index - 1.0) - offset = leadingPosition ?? middlePosition; - else if (value == index + 1.0) - offset = trailingPosition ?? middlePosition; - else if (value == index) - offset = middlePosition; - else if (value < index) - offset = leadingPosition == null ? middlePosition : lerpDouble(middlePosition, leadingPosition, index - value); - else - offset = trailingPosition == null ? middlePosition : lerpDouble(middlePosition, trailingPosition, value - index); - - _scrollController.jumpTo(offset); - } - - void _handleTabControllerAnimationTick() { - assert(mounted); - if (!_controller.indexIsChanging && widget.isScrollable) { - // Sync the TabBar's scroll position with the TabBarView's PageView. - _currentIndex = _controller.index; - _scrollToControllerValue(); - } - } - - void _handleTabControllerTick() { - if (_controller.index != _currentIndex) { - _currentIndex = _controller.index; - if (widget.isScrollable) - _scrollToCurrentIndex(); - } - setState(() { - // Rebuild the tabs after a (potentially animated) index change - // has completed. - }); - } - - // Called each time layout completes. - void _saveTabOffsets(List tabOffsets, TextDirection textDirection, double width) { - _tabStripWidth = width; - _indicatorPainter?.saveTabOffsets(tabOffsets, textDirection); - } - - void _handleTap(int index) { - assert(index >= 0 && index < widget.tabs.length); - _controller.animateTo(index); - if (widget.onTap != null) { - widget.onTap(index); - } - } - - Widget _buildStyledTab(Widget child, bool selected, Animation animation) { - return _TabStyle( - animation: animation, - selected: selected, - labelColor: widget.labelColor, - unselectedLabelColor: widget.unselectedLabelColor, - labelStyle: widget.labelStyle, - unselectedLabelStyle: widget.unselectedLabelStyle, - child: child, - ); - } - - @override - Widget build(BuildContext context) { - assert(debugCheckHasMaterialLocalizations(context)); - assert(() { - if (_controller.length != widget.tabs.length) { - throw FlutterError( - 'Controller\'s length property (${_controller.length}) does not match the \n' - 'number of tabs (${widget.tabs.length}) present in TabBar\'s tabs property.' - ); - } - return true; - }()); - final MaterialLocalizations localizations = MaterialLocalizations.of(context); - if (_controller.length == 0) { - return Container( - height: _kTabHeight + widget.indicatorWeight, - ); - } - - final TabBarTheme tabBarTheme = TabBarTheme.of(context); - - final List wrappedTabs = List(widget.tabs.length); - for (int i = 0; i < widget.tabs.length; i += 1) { - wrappedTabs[i] = Center( - heightFactor: 1.0, - child: Padding( - padding: widget.labelPadding ?? tabBarTheme.labelPadding ?? kTabLabelPadding, - child: KeyedSubtree( - key: _tabKeys[i], - child: widget.tabs[i], - ), - ), - ); - - } - - // If the controller was provided by DefaultTabController and we're part - // of a Hero (typically the AppBar), then we will not be able to find the - // controller during a Hero transition. See https://github.com/flutter/flutter/issues/213. - if (_controller != null) { - final int previousIndex = _controller.previousIndex; - - if (_controller.indexIsChanging) { - // The user tapped on a tab, the tab controller's animation is running. - assert(_currentIndex != previousIndex); - final Animation animation = _ChangeAnimation(_controller); - wrappedTabs[_currentIndex] = _buildStyledTab(wrappedTabs[_currentIndex], true, animation); - wrappedTabs[previousIndex] = _buildStyledTab(wrappedTabs[previousIndex], false, animation); - } else { - // The user is dragging the TabBarView's PageView left or right. - final int tabIndex = _currentIndex; - final Animation centerAnimation = _DragAnimation(_controller, tabIndex); - wrappedTabs[tabIndex] = _buildStyledTab(wrappedTabs[tabIndex], true, centerAnimation); - if (_currentIndex > 0) { - final int tabIndex = _currentIndex - 1; - final Animation previousAnimation = ReverseAnimation(_DragAnimation(_controller, tabIndex)); - wrappedTabs[tabIndex] = _buildStyledTab(wrappedTabs[tabIndex], false, previousAnimation); - } - if (_currentIndex < widget.tabs.length - 1) { - final int tabIndex = _currentIndex + 1; - final Animation nextAnimation = ReverseAnimation(_DragAnimation(_controller, tabIndex)); - wrappedTabs[tabIndex] = _buildStyledTab(wrappedTabs[tabIndex], false, nextAnimation); - } - } - } - - // Add the tap handler to each tab. If the tab bar is not scrollable, - // then give all of the tabs equal flexibility so that they each occupy - // the same share of the tab bar's overall width. - final int tabCount = widget.tabs.length; - for (int index = 0; index < tabCount; index += 1) { - wrappedTabs[index] = GestureDetector( - onTap: () { _handleTap(index); }, - child: Container( - color: Colors.transparent, - padding: EdgeInsets.only(bottom: widget.indicatorWeight), - child: Stack( - children: [ - wrappedTabs[index], - Semantics( - selected: index == _currentIndex, - label: localizations.tabLabel(tabIndex: index + 1, tabCount: tabCount), - ), - ], - ), - ), - ); - if (!widget.isScrollable) - wrappedTabs[index] = Expanded(child: wrappedTabs[index]); - } - - Widget tabBar = CustomPaint( - painter: _indicatorPainter, - child: _TabStyle( - animation: kAlwaysDismissedAnimation, - selected: false, - labelColor: widget.labelColor, - unselectedLabelColor: widget.unselectedLabelColor, - labelStyle: widget.labelStyle, - unselectedLabelStyle: widget.unselectedLabelStyle, - child: _TabLabelBar( - onPerformLayout: _saveTabOffsets, - children: wrappedTabs, - ), - ), - ); - - if (widget.isScrollable) { - _scrollController ??= _TabBarScrollController(this); - tabBar = SingleChildScrollView( - dragStartBehavior: widget.dragStartBehavior, - scrollDirection: Axis.horizontal, - controller: _scrollController, - child: tabBar, - ); - } - - return tabBar; - } -} - - -final PageScrollPhysics _kTabBarViewPhysics = const PageScrollPhysics().applyTo(const ClampingScrollPhysics()); - -class _TabBarViewState extends State { - TabController _controller; - PageController _pageController; - List _children; - List _childrenWithKey; - int _currentIndex; - int _warpUnderwayCount = 0; - - // If the TabBarView is rebuilt with a new tab controller, the caller should - // dispose the old one. In that case the old controller's animation will be - // null and should not be accessed. - bool get _controllerIsValid => _controller?.animation != null; - - void _updateTabController() { - final TabController newController = widget.controller ?? DefaultTabController.of(context); - assert(() { - if (newController == null) { - throw FlutterError( - 'No TabController for ${widget.runtimeType}.\n' - 'When creating a ${widget.runtimeType}, you must either provide an explicit ' - 'TabController using the "controller" property, or you must ensure that there ' - 'is a DefaultTabController above the ${widget.runtimeType}.\n' - 'In this case, there was neither an explicit controller nor a default controller.' - ); - } - return true; - }()); - - if (newController == _controller) - return; - - if (_controllerIsValid) - _controller.animation.removeListener(_handleTabControllerAnimationTick); - _controller = newController; - if (_controller != null) - _controller.animation.addListener(_handleTabControllerAnimationTick); - } - - @override - void initState() { - super.initState(); - _updateChildren(); - } - - @override - void didChangeDependencies() { - super.didChangeDependencies(); - _updateTabController(); - _currentIndex = _controller?.index; - _pageController = PageController(initialPage: _currentIndex ?? 0); - } - - @override - void didUpdateWidget(TabBarView oldWidget) { - super.didUpdateWidget(oldWidget); - if (widget.controller != oldWidget.controller) - _updateTabController(); - if (widget.children != oldWidget.children && _warpUnderwayCount == 0) - _updateChildren(); - } - - @override - void dispose() { - if (_controllerIsValid) - _controller.animation.removeListener(_handleTabControllerAnimationTick); - _controller = null; - // We don't own the _controller Animation, so it's not disposed here. - super.dispose(); - } - - void _updateChildren() { - _children = widget.children; - _childrenWithKey = KeyedSubtree.ensureUniqueKeysForList(widget.children); - } - - void _handleTabControllerAnimationTick() { - if (_warpUnderwayCount > 0 || !_controller.indexIsChanging) - return; // This widget is driving the controller's animation. - - if (_controller.index != _currentIndex) { - _currentIndex = _controller.index; - _warpToCurrentIndex(); - } - } - - Future _warpToCurrentIndex() async { - if (!mounted) - return Future.value(); - - if (_pageController.page == _currentIndex.toDouble()) - return Future.value(); - - final int previousIndex = _controller.previousIndex; - if ((_currentIndex - previousIndex).abs() == 1) - return _pageController.animateToPage(_currentIndex, duration: kTabScrollDuration, curve: Curves.ease); - - assert((_currentIndex - previousIndex).abs() > 1); - final int initialPage = _currentIndex > previousIndex - ? _currentIndex - 1 - : _currentIndex + 1; - final List originalChildren = _childrenWithKey; - setState(() { - _warpUnderwayCount += 1; - - _childrenWithKey = List.from(_childrenWithKey, growable: false); - final Widget temp = _childrenWithKey[initialPage]; - _childrenWithKey[initialPage] = _childrenWithKey[previousIndex]; - _childrenWithKey[previousIndex] = temp; - }); - _pageController.jumpToPage(initialPage); - - await _pageController.animateToPage(_currentIndex, duration: kTabScrollDuration, curve: Curves.ease); - if (!mounted) - return Future.value(); - setState(() { - _warpUnderwayCount -= 1; - if (widget.children != _children) { - _updateChildren(); - } else { - _childrenWithKey = originalChildren; - } - }); - } - - // Called when the PageView scrolls - bool _handleScrollNotification(ScrollNotification notification) { - if (_warpUnderwayCount > 0) - return false; - - if (notification.depth != 0) - return false; - - _warpUnderwayCount += 1; - if (notification is ScrollUpdateNotification && !_controller.indexIsChanging) { - if ((_pageController.page - _controller.index).abs() > 1.0) { - _controller.index = _pageController.page.floor(); - _currentIndex =_controller.index; - } - _controller.offset = (_pageController.page - _controller.index).clamp(-1.0, 1.0); - } else if (notification is ScrollEndNotification) { - _controller.index = _pageController.page.round(); - _currentIndex = _controller.index; - } - _warpUnderwayCount -= 1; - - return false; - } - - @override - Widget build(BuildContext context) { - assert(() { - if (_controller.length != widget.children.length) { - throw FlutterError( - 'Controller\'s length property (${_controller.length}) does not match the \n' - 'number of tabs (${widget.children.length}) present in TabBar\'s tabs property.' - ); - } - return true; - }()); - return NotificationListener( - onNotification: _handleScrollNotification, - child: PageView( - dragStartBehavior: widget.dragStartBehavior, - controller: _pageController, - physics: widget.physics == null ? _kTabBarViewPhysics : _kTabBarViewPhysics.applyTo(widget.physics), - children: _childrenWithKey, - ), - ); - } -} - -/// Displays a single circle with the specified border and background colors. -/// -/// Used by [TabPageSelector] to indicate the selected page. -class TabPageSelectorIndicator extends StatelessWidget { - /// Creates an indicator used by [TabPageSelector]. - /// - /// The [backgroundColor], [borderColor], and [size] parameters must not be null. - const TabPageSelectorIndicator({ - Key key, - @required this.backgroundColor, - @required this.borderColor, - @required this.size, - }) : assert(backgroundColor != null), - assert(borderColor != null), - assert(size != null), - super(key: key); - - /// The indicator circle's background color. - final Color backgroundColor; - - /// The indicator circle's border color. - final Color borderColor; - - /// The indicator circle's diameter. - final double size; - - @override - Widget build(BuildContext context) { - return Container( - width: size, - height: size, - margin: const EdgeInsets.all(4.0), - decoration: BoxDecoration( - color: backgroundColor, - border: Border.all(color: borderColor), - shape: BoxShape.circle, - ), - ); - } -} - -/// Displays a row of small circular indicators, one per tab. -/// -/// The selected tab's indicator is highlighted. Often used in conjunction with -/// a [TabBarView]. -/// -/// If a [TabController] is not provided, then there must be a -/// [DefaultTabController] ancestor. -class TabPageSelector extends StatelessWidget { - /// Creates a compact widget that indicates which tab has been selected. - const TabPageSelector({ - Key key, - this.controller, - this.indicatorSize = 12.0, - this.color, - this.selectedColor, - }) : assert(indicatorSize != null && indicatorSize > 0.0), - super(key: key); - - /// This widget's selection and animation state. - /// - /// If [TabController] is not provided, then the value of - /// [DefaultTabController.of] will be used. - final TabController controller; - - /// The indicator circle's diameter (the default value is 12.0). - final double indicatorSize; - - /// The indicator circle's fill color for unselected pages. - /// - /// If this parameter is null, then the indicator is filled with [Colors.transparent]. - final Color color; - - /// The indicator circle's fill color for selected pages and border color - /// for all indicator circles. - /// - /// If this parameter is null, then the indicator is filled with the theme's - /// accent color, [ThemeData.accentColor]. - final Color selectedColor; - - Widget _buildTabIndicator( - int tabIndex, - TabController tabController, - ColorTween selectedColorTween, - ColorTween previousColorTween, - ) { - Color background; - if (tabController.indexIsChanging) { - // The selection's animation is animating from previousValue to value. - final double t = 1.0 - _indexChangeProgress(tabController); - if (tabController.index == tabIndex) - background = selectedColorTween.lerp(t); - else if (tabController.previousIndex == tabIndex) - background = previousColorTween.lerp(t); - else - background = selectedColorTween.begin; - } else { - // The selection's offset reflects how far the TabBarView has / been dragged - // to the previous page (-1.0 to 0.0) or the next page (0.0 to 1.0). - final double offset = tabController.offset; - if (tabController.index == tabIndex) { - background = selectedColorTween.lerp(1.0 - offset.abs()); - } else if (tabController.index == tabIndex - 1 && offset > 0.0) { - background = selectedColorTween.lerp(offset); - } else if (tabController.index == tabIndex + 1 && offset < 0.0) { - background = selectedColorTween.lerp(-offset); - } else { - background = selectedColorTween.begin; - } - } - return TabPageSelectorIndicator( - backgroundColor: background, - borderColor: selectedColorTween.end, - size: indicatorSize, - ); - } - - @override - Widget build(BuildContext context) { - final Color fixColor = color ?? Colors.transparent; - final Color fixSelectedColor = selectedColor ?? Theme.of(context).accentColor; - final ColorTween selectedColorTween = ColorTween(begin: fixColor, end: fixSelectedColor); - final ColorTween previousColorTween = ColorTween(begin: fixSelectedColor, end: fixColor); - final TabController tabController = controller ?? DefaultTabController.of(context); - assert(() { - if (tabController == null) { - throw FlutterError( - 'No TabController for $runtimeType.\n' - 'When creating a $runtimeType, you must either provide an explicit TabController ' - 'using the "controller" property, or you must ensure that there is a ' - 'DefaultTabController above the $runtimeType.\n' - 'In this case, there was neither an explicit controller nor a default controller.' - ); - } - return true; - }()); - final Animation animation = CurvedAnimation( - parent: tabController.animation, - curve: Curves.fastOutSlowIn, - ); - return AnimatedBuilder( - animation: animation, - builder: (BuildContext context, Widget child) { - return Semantics( - label: 'Page ${tabController.index + 1} of ${tabController.length}', - child: Row( - mainAxisSize: MainAxisSize.min, - children: List.generate(tabController.length, (int tabIndex) { - return _buildTabIndicator(tabIndex, tabController, selectedColorTween, previousColorTween); - }).toList(), - ), - ); - }, - ); - } -} diff --git a/lib/components/permanent/animated_text.dart b/lib/components/permanent/animated_text.dart deleted file mode 100644 index c2edcba..0000000 --- a/lib/components/permanent/animated_text.dart +++ /dev/null @@ -1,67 +0,0 @@ -import 'dart:async'; - -import 'package:flutter/material.dart'; - -class AnimatedText extends StatefulWidget { - final String text; - final int delayInMilliseconds; - final int durationInMilliseconds; - final TextStyle textStyle; - - AnimatedText(this.text, this.delayInMilliseconds, - {this.durationInMilliseconds: 2500, this.textStyle}); - - @override createState() => AnimatedTextState(); -} - -class AnimatedTextState extends State - with SingleTickerProviderStateMixin { - - String currentText = ''; - - AnimationController _controller; - - List get textRunes=> widget.text.runes.toList(); - int get value => _controller.value.toInt(); - - int curIndex = 0; - - - @override - void initState() { - super.initState(); - currentText = String.fromCharCode(textRunes[0]); - - _controller = AnimationController( - vsync: this, - value: 0.0, - lowerBound: 0.0, - upperBound: textRunes.length.toDouble(), - duration: Duration(milliseconds: widget.durationInMilliseconds)); - - _controller..addListener(_updateText)..forward(); - - } - - _updateText(){ - if (value > curIndex && value < textRunes.length) { - setState(() { - curIndex = value; - currentText += String.fromCharCode(textRunes[curIndex]); - }); - } - } - - @override - void dispose() { - _controller.dispose(); - super.dispose(); - } - - @override - Widget build(BuildContext context) { - return Text(currentText, textAlign: TextAlign.left, - style: widget.textStyle ?? - TextStyle(fontWeight: FontWeight.w600, fontSize: 20.0),); - } -} \ No newline at end of file diff --git a/lib/components/permanent/circle.dart b/lib/components/permanent/circle.dart deleted file mode 100644 index e50a58f..0000000 --- a/lib/components/permanent/circle.dart +++ /dev/null @@ -1,31 +0,0 @@ -import 'package:flutter/material.dart'; - -class Circle extends StatelessWidget { - final Color color; - final double radius; - final bool showShadow; - final Widget child; - - const Circle({this.color=Colors.blue, this.radius=6,this.showShadow=true,this.child}); - - @override - Widget build(BuildContext context) { - return Container( - alignment: Alignment.center, - child: child==null?Container():child, - width: 2*radius, - height: 2*radius, - decoration: BoxDecoration( - color: color, - shape: BoxShape.circle, - boxShadow: [ - if (showShadow) - BoxShadow( - color: Colors.grey, - offset: Offset(.5,.5), - blurRadius: .5, - )] - ), - ); - } -} diff --git a/lib/components/permanent/circle_image.dart b/lib/components/permanent/circle_image.dart deleted file mode 100644 index 724bd11..0000000 --- a/lib/components/permanent/circle_image.dart +++ /dev/null @@ -1,43 +0,0 @@ -import 'package:flutter/material.dart'; - -class CircleImage extends StatelessWidget { - CircleImage( - {Key key, - this.borderSize =3, - @required this.image, - this.size = 70, - this.shadowColor, - this.roundColor}) - : super(key: key); - final ImageProvider image; //图片 - final double size; //大小 - final Color shadowColor; //阴影颜色 - final Color roundColor; //边框颜色 - final double borderSize; - @override - Widget build(BuildContext context) { - var headIcon = Container( - width: size, - height: size, - decoration: BoxDecoration( - shape: BoxShape.circle, //圆形装饰线 - color: roundColor ?? Colors.white, - boxShadow: [ - BoxShadow( - //阴影 - color: shadowColor ?? Colors.grey.withOpacity(0.3), - offset: Offset(0.0, 0.0), blurRadius: 3.0, spreadRadius: 0.0, - ), - ], - ), - child: Padding( - padding: EdgeInsets.all(borderSize), - child: - CircleAvatar( - backgroundImage: image, - ), - ), - ); - return headIcon; - } -} diff --git a/lib/components/permanent/circle_text.dart b/lib/components/permanent/circle_text.dart deleted file mode 100644 index 8918a9e..0000000 --- a/lib/components/permanent/circle_text.dart +++ /dev/null @@ -1,66 +0,0 @@ -import 'package:flutter/material.dart'; - -class CircleText extends StatelessWidget { - CircleText( - {Key key, - @required this.text, - this.size = 70, - this.fontSize = 24, - this.color = Colors.white, - this.shadowColor, - this.backgroundColor, - this.roundColor}) - : super(key: key); - final String text; //图片 - final double size; //大小 - final double fontSize; //大小 - final Color shadowColor; //阴影颜色 - final Color color; //阴影颜色 - final Color roundColor; //边框颜色 - final Color backgroundColor; //边框颜色 - @override - Widget build(BuildContext context) { - var headIcon = Container( - width: size, - height: size, - decoration: BoxDecoration( - shape: BoxShape.circle, //圆形装饰线 - color: roundColor ?? Colors.white, - boxShadow: [ - BoxShadow( - //阴影 - color: shadowColor ?? Colors.grey.withOpacity(0.3), - offset: Offset(0.0, 0.0), blurRadius: 3.0, spreadRadius: 0.0, - ), - ], - ), - child: Padding( - padding: EdgeInsets.all(3), - child: Container( - alignment: Alignment.center, - width: size, - height: size, - decoration: BoxDecoration( - shape: BoxShape.circle, //圆形装饰线 - color: backgroundColor??Color(0xffD8F5FF), - ), - child: Text( - text.length>2?text.substring(0, 2):text, - style: TextStyle( - fontSize: fontSize, - color: color, - fontWeight: FontWeight.bold, - shadows: [ - Shadow( - //阴影 - color: Colors.grey, - offset: Offset(1.0, 1.0), blurRadius: 1.0, - ) - ], - ), - )), - ), - ); - return headIcon; - } -} \ No newline at end of file diff --git a/lib/components/permanent/code/back/code_panel.dart b/lib/components/permanent/code/back/code_panel.dart deleted file mode 100755 index f56cd38..0000000 --- a/lib/components/permanent/code/back/code_panel.dart +++ /dev/null @@ -1,66 +0,0 @@ -import 'package:flutter/foundation.dart'; -import 'package:flutter/material.dart'; - -import '../high_light_code.dart'; -import '../highlighter_style.dart'; - - -class CodeWidget extends StatelessWidget { - CodeWidget({ - Key key, - @required this.code, - this.style, - this.fontSize = 13, - this.fontFamily, - }) : super(key: key); - - final String code; - final HighlighterStyle style; - final double fontSize; - final String fontFamily; - @override - Widget build(BuildContext context) { - if (code == null) { - return Container(); - } - - Widget _codeWidget = FutureBuilder( - future: compute(_hightlight, _HightlightArgs(style, code)), - builder: (context, snapshot) { - if (snapshot.hasError) { - return Text(code); - } - if (snapshot.hasData) - return RichText( - text: TextSpan( - children: [snapshot.data], - ), - ); - // computing - return SizedBox.shrink(); - }, - ); - - return SingleChildScrollView( - child: Container( - child: DefaultTextStyle( - child: _codeWidget, - style: TextStyle(fontSize: fontSize, fontFamily: fontFamily), - ), - padding: EdgeInsets.all(10), - decoration: BoxDecoration( - color: style.backgroundColor ?? Color(0xffF6F8FA), - borderRadius: BorderRadius.all(Radius.circular(5.0))), - ), - ); - } -} - -class _HightlightArgs { - final HighlighterStyle style; - final String code; - _HightlightArgs(this.style, this.code); -} - -TextSpan _hightlight(_HightlightArgs args) => - DartHighlighter(args.style).format(args.code); diff --git a/lib/components/permanent/code/code_widget.dart b/lib/components/permanent/code/code_widget.dart deleted file mode 100644 index be8d647..0000000 --- a/lib/components/permanent/code/code_widget.dart +++ /dev/null @@ -1,49 +0,0 @@ - -/// create by 张风捷特烈 on 2020-04-15 -/// contact me by email 1981462002@qq.com -/// 说明: - -import 'package:flutter/material.dart'; - -import 'high_light_code.dart'; -import 'highlighter_style.dart'; - -class CodeWidget extends StatelessWidget { - CodeWidget({Key key, @required this.code, this.style, this.fontSize = 13,this.fontFamily}) - : super(key: key); - - final String code; - final HighlighterStyle style; - final double fontSize; - final String fontFamily; - - @override - Widget build(BuildContext context) { - Widget body; - if (code == null) { - return Container(); - } else { - Widget _codeWidget; - try { - _codeWidget = RichText( - text: TextSpan( - style: TextStyle(fontSize: fontSize,fontFamily: fontFamily), - children: [DartHighlighter(style).format(code)], - ), - ); - } catch (err) { - _codeWidget = Text(code); - } - body = SingleChildScrollView( - child: Container( - child: _codeWidget, - padding: EdgeInsets.all(10), - decoration: BoxDecoration( - color: style.backgroundColor ?? Color(0xffF6F8FA), - borderRadius: BorderRadius.all(Radius.circular(5.0))), - ), - ); - } - return body; - } -} \ No newline at end of file diff --git a/lib/components/permanent/code/high_light_code.dart b/lib/components/permanent/code/high_light_code.dart deleted file mode 100644 index e3987e1..0000000 --- a/lib/components/permanent/code/high_light_code.dart +++ /dev/null @@ -1,319 +0,0 @@ -/// create by 张风捷特烈 on 2020-04-15 -/// contact me by email 1981462002@qq.com -/// 说明: - -// Copyright 2016 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -import 'package:flutter/material.dart'; -import 'package:string_scanner/string_scanner.dart'; - -import 'highlighter_style.dart'; - -/// final SyntaxHighlighterStyle style = SyntaxHighlighterStyle.lightThemeStyle(); -/// DartSyntaxHighlighter(style).format(source) - - -abstract class Highlighter { // ignore: one_member_abstracts - TextSpan format(String src); -} - -//暗黑模式下的高亮样式 -class DartHighlighter extends Highlighter { - DartHighlighter([this._style]) { - _spans = <_HighlightSpan>[]; - _style ??= HighlighterStyle.fromColors(HighlighterStyle.lightColor); - } - - HighlighterStyle _style; - - static const List _keywords = [ - '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 _builtInTypes = [ - 'int', 'double', 'num', 'bool' - ]; - - String _src; - StringScanner _scanner; - - List<_HighlightSpan> _spans; - - @override - TextSpan format(String src) { - _src = src; - _scanner = StringScanner(_src); - - if (_generateSpans()) { - // Successfully parsed the code - final List formattedText = []; - int currentPosition = 0; - - for (_HighlightSpan span in _spans) { - if (currentPosition != span.start) - formattedText.add(TextSpan(text: _src.substring(currentPosition, span.start))); - - 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))); - - return TextSpan(style: _style.baseStyle, children: formattedText); - } else { - // Parsing failed, return with only basic formatting - return TextSpan(style: _style.baseStyle, text: src); - } - } - - bool _generateSpans() { - int lastLoopPosition = _scanner.position; - - while (!_scanner.isDone) { - // Skip White space - _scanner.scan(RegExp(r'\s+')); - - // Block comments - if (_scanner.scan(RegExp(r'/\*(.|\n)*\*/'))) { - _spans.add(_HighlightSpan( - _HighlightType.comment, - _scanner.lastMatch.start, - _scanner.lastMatch.end - )); - continue; - } - - // Line comments - if (_scanner.scan('//')) { - final int startComment = _scanner.lastMatch.start; - - bool eof = false; - int endComment; - if (_scanner.scan(RegExp(r'.*\n'))) { - endComment = _scanner.lastMatch.end - 1; - } else { - eof = true; - endComment = _src.length; - } - - _spans.add(_HighlightSpan( - _HighlightType.comment, - startComment, - endComment - )); - - if (eof) - break; - - continue; - } - - // Raw r"String" - if (_scanner.scan(RegExp(r'r".*"'))) { - _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 - )); - continue; - } - - // Multiline """String""" - if (_scanner.scan(RegExp(r'"""(?:[^"\\]|\\(.|\n))*"""'))) { - _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 - )); - continue; - } - - // "String" - if (_scanner.scan(RegExp(r'"(?:[^"\\]|\\.)*"'))) { - _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 - )); - continue; - } - - // Double - if (_scanner.scan(RegExp(r'\d+\.\d+'))) { - _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) - ); - continue; - } - - // Punctuation - if (_scanner.scan(RegExp(r'[\[\]{}().!=<>&\|\?\+\-\*/%\^~;:,]'))) { - _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 - )); - continue; - } - - // Words - if (_scanner.scan(RegExp(r'\w+'))) { - _HighlightType type; - - String word = _scanner.lastMatch[0]; - if (word.startsWith('_')) - word = word.substring(1); - - if (_keywords.contains(word)) - type = _HighlightType.keyword; - else if (_builtInTypes.contains(word)) - type = _HighlightType.keyword; - else if (_firstLetterIsUpperCase(word)) - type = _HighlightType.klass; - 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 - )); - } - } - - // Check if this loop did anything - if (lastLoopPosition == _scanner.position) { - // Failed to parse this file, abort gracefully - return false; - } - lastLoopPosition = _scanner.position; - } - - _simplify(); - return true; - } - - 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 - ); - _spans.removeAt(i + 1); - } - } - } - - bool _firstLetterIsUpperCase(String str) { - if (str.isNotEmpty) { - final String first = str.substring(0, 1); - return first == first.toUpperCase(); - } - return false; - } -} - -enum _HighlightType { - number, - comment, - keyword, - string, - punctuation, - klass, - constant -} - -class _HighlightSpan { - _HighlightSpan(this.type, this.start, this.end); - final _HighlightType type; - final int start; - final int end; - - String textForSpan(String src) { - return src.substring(start, end); - } - - TextStyle textStyle(HighlighterStyle style) { - if (type == _HighlightType.number) - return style.numberStyle; - else if (type == _HighlightType.comment) - return style.commentStyle; - else if (type == _HighlightType.keyword) - return style.keywordStyle; - else if (type == _HighlightType.string) - return style.stringStyle; - else if (type == _HighlightType.punctuation) - return style.punctuationStyle; - else if (type == _HighlightType.klass) - return style.classStyle; - else if (type == _HighlightType.constant) - return style.constantStyle; - else - return style.baseStyle; - } -} \ No newline at end of file diff --git a/lib/components/permanent/code/highlighter_style.dart b/lib/components/permanent/code/highlighter_style.dart deleted file mode 100644 index 3980bfc..0000000 --- a/lib/components/permanent/code/highlighter_style.dart +++ /dev/null @@ -1,139 +0,0 @@ -/// create by 张风捷特烈 on 2020-04-15 -/// contact me by email 1981462002@qq.com -/// 说明: - -import 'package:flutter/material.dart'; - -/// create by 张风捷特烈 on 2020-04-11 -/// contact me by email 1981462002@qq.com -/// 说明: - -class HighlighterStyle { - //句法高亮样式 - const HighlighterStyle( - { //构造函数 - this.baseStyle, //基础样式 - this.numberStyle, //数字的样式 - this.commentStyle, //注释样式 - this.keywordStyle, //关键字样式 - this.stringStyle, //字符串样式 - this.punctuationStyle, //标点符号样式 - this.classStyle, //类名 - this.backgroundColor, - this.constantStyle}); - - static List get lightColor => [ - 0xFF000000, //基础 - 0xFF00b0e8, //数字 - 0xFF9E9E9E, //注释 - 0xFF9C27B0, //关键 - 0xFF43A047, //字符串 - 0xFF000000, //标点符号 - 0xFF3D62F5, //类名 - 0xFF795548, //常量 - 0xffF6F8FA, //背景 - ]; - - static List get darkColor => [ - 0xFFFFFFFF, //基础 - 0xFFDF935F, //数字 - 0xFF9E9E9E, //注释 - 0xFF80CBC4, //关键字 - 0xFFB9CA4A, //字符串 - 0xFFFFFFFF, //标点符号 - 0xFF7AA6DA, //类名 - 0xFF795548, //常量 - 0xFF1D1F21, //背景 - ]; - - static List get gitHub => - [ - 0xFF333333, //基础 - 0xFF008081, //数字 - 0xFF9D9D8D, //注释 - 0xFF009999, //关键字 - 0xFFDD1045, //字符串 - 0xFF333333, //标点符号 - 0xFF6F42C1, //类名 - 0xFF795548, //常量 - 0xFFF8F8F8, //背景 - ]; - - static List get zenburn => [ - 0xFFDCDCDC, //普通字 - 0xFF87C5C8, //数字 - 0xFF8F8F8F, //注释 - 0xFFE4CEAB, //关键字 - 0xFFCC9493, //字符串 - 0xFFDCDCDC, //标点符号 - 0xFFEFEF90, //类名 - 0xFFEF5350, //常量 - 0xFF3F3F3F, //背景 - ]; - - static List get mf =>[ - 0xFF707D95, //基础 - 0xFF6897BB, //数字 - 0xFF629755, //注释 - 0xFFCC7832, //关键 - 0xFFF14E9F, //字符串 - 0xFFFFBB33, //标点符号 - 0xFF66CCFF, //类名 - 0xFF9876AA, //常量 - 0xFF2B2B2B //背景 - ]; - - static List get solarized =>[ - 0xFF657B83, // 普通字 - 0xFFD33682, // 数字 - 0xFF93A1A1, // 注释 - 0xFF859900, // 关键字 - 0xFF2AA198, // 字符串 - 0xFF859900, // 标点符号 - 0xFF268BD2, // 类名 - 0xFF268BD2, //常量 - 0xFFDDD6C1, // 背景 - ]; - - factory HighlighterStyle.fromColors(List colors) => HighlighterStyle( - baseStyle: TextStyle( - color: Color(colors[0]), - ), - numberStyle: TextStyle( - color: Color(colors[1]), - ), - commentStyle: TextStyle( - color: Color( - colors[2], - ), - fontStyle: FontStyle.italic), - keywordStyle: TextStyle( - fontWeight: FontWeight.bold, - color: Color( - colors[3], - ), - ), - stringStyle: TextStyle( - color: Color(colors[4]), - ), - punctuationStyle: TextStyle( - color: Color(colors[5]), - ), - classStyle: TextStyle( - color: Color(colors[6]), - ), - constantStyle: TextStyle( - color: Color(colors[7]), - ), - backgroundColor: Color(colors[8]), - ); - final TextStyle baseStyle; - final TextStyle numberStyle; - final TextStyle commentStyle; - final TextStyle keywordStyle; - final TextStyle stringStyle; - final TextStyle punctuationStyle; - final TextStyle classStyle; - final TextStyle constantStyle; - final Color backgroundColor; -} \ No newline at end of file diff --git a/lib/components/permanent/edit_panel.dart b/lib/components/permanent/edit_panel.dart deleted file mode 100644 index 7a554d8..0000000 --- a/lib/components/permanent/edit_panel.dart +++ /dev/null @@ -1,109 +0,0 @@ -import 'package:flutter/material.dart'; - -typedef ChangeCallback = void Function(String str); - -///输入面板 -class EditPanel extends StatefulWidget { - EditPanel( - {Key key, - this.backgroundColor = Colors.white, - this.color = Colors.lightBlue, - this.minLines = 4, - this.maxLines = 15, - this.fontSize = 14, - this.submitClear = true, - this.defaultText = "", - this.onChange, - this.hint = "写点什么..."}) - : super(key: key); - - final Color color; //字颜色 - final Color backgroundColor; //背景色颜色 - final int minLines; //最小行数 - final int maxLines; //最大行数 - final double fontSize; //字号 - final String hint; //提示字 - final bool submitClear; //提交是否清空文字 - final ChangeCallback onChange; //提交监听 - final String defaultText; //提交监听 - - @override - _EditPanelState createState() => _EditPanelState(); -} - -class _EditPanelState extends State { - var _radius; //边角半径 - - TextEditingController _controller; - - @override - void initState() { - _radius = Radius.circular(widget.fontSize * 0.618); - _controller = TextEditingController(text: widget.defaultText??''); - super.initState(); - } - - @override - void dispose() { - _controller.dispose(); - super.dispose(); - } - - @override - Widget build(BuildContext context) { - var panel = TextField( - controller: _controller, - //输入控制器 - keyboardType: TextInputType.text, - //键盘类型 - textAlign: TextAlign.start, - //文字居左 - cursorColor: Colors.black, - //游标颜色 - minLines: widget.minLines, - //最小行数 - maxLines: widget.maxLines, - //最大行数 - style: TextStyle( - //文字样式 - fontSize: widget.fontSize, - color: widget.color, - backgroundColor: Colors.white), - decoration: InputDecoration( - //装饰线 - filled: true, - //是否填充 - fillColor: widget.backgroundColor, - //填充色 - hintText: widget.hint, - //提示文字 - hintStyle: TextStyle(color: Colors.black26, fontSize: widget.fontSize), - //提示文字样式 - focusedBorder: UnderlineInputBorder( - //聚焦时边线 - borderSide: BorderSide(color: widget.backgroundColor), - borderRadius: BorderRadius.all(_radius), - ), - enabledBorder: UnderlineInputBorder( - //非聚焦时边线 - borderSide: BorderSide(color: widget.backgroundColor), - borderRadius: BorderRadius.all(_radius), - ), - ), - onChanged: (str) { - //文字变化监听 - if (widget.onChange != null) widget.onChange(str); - }, - onSubmitted: (str) { - //提交监听 - FocusScope.of(context).requestFocus(FocusNode()); //收起键盘 - if (widget.submitClear) { - setState(() { - _controller.clear(); - }); - } - }, - ); - return panel; - } -} diff --git a/lib/components/permanent/feedback_widget.dart b/lib/components/permanent/feedback_widget.dart deleted file mode 100644 index 36a148e..0000000 --- a/lib/components/permanent/feedback_widget.dart +++ /dev/null @@ -1,82 +0,0 @@ -import 'dart:math'; - -import 'package:flutter/material.dart'; - -/// create by 张风捷特烈 on 2020-04-10 -/// contact me by email 1981462002@qq.com -/// 说明: - -enum FeedMode { - scale, - fade, - rotate, -} - -class FeedbackWidget extends StatefulWidget { - final Widget child; - final FeedMode mode; - final Duration duration; - final Function() onPressed; - final a; - - FeedbackWidget( - {@required this.child, - this.mode = FeedMode.scale, - this.a = 0.9, - this.duration = const Duration(milliseconds: 150), - @required this.onPressed}); - - @override - _FeedBackState createState() => _FeedBackState(); -} - -class _FeedBackState extends State - with SingleTickerProviderStateMixin { - AnimationController _controller; - var rate = 1.0; - - @override - void initState() { - super.initState(); - _controller = AnimationController(vsync: this, duration: widget.duration) - ..addListener(() { - setState(() => rate = (widget.a - 1) * _controller.value + 1); - }) - ..addStatusListener((s) { - if (s == AnimationStatus.completed) { - _controller.reverse(); - } - }); - } - - @override - void dispose() { - _controller.dispose(); - super.dispose(); - } - - @override - Widget build(BuildContext context) { - return GestureDetector( - onTap: () { - _controller.forward(); - if(widget.onPressed!=null){ - widget.onPressed(); - } - }, - child: _buildByMode(widget.child, widget.mode), - ); - } - - Widget _buildByMode(Widget child, FeedMode mode) { - switch (mode) { - case FeedMode.scale: - return Transform.scale(scale: rate, child: widget.child); - case FeedMode.fade: - return Opacity(opacity: rate, child: widget.child); - case FeedMode.rotate: - return Transform.rotate(angle: rate * pi * 2, child: widget.child); - } - return Container(); - } -} diff --git a/lib/components/permanent/input_button.dart b/lib/components/permanent/input_button.dart deleted file mode 100644 index 81f6b51..0000000 --- a/lib/components/permanent/input_button.dart +++ /dev/null @@ -1,138 +0,0 @@ -import 'package:flutter/material.dart'; - -typedef SubmitCallback = void Function(String str); - -class InputButtonConfig { - final double height; //高度 - final IconData iconData; //图标 - final String hint; //提示文字 - final double fontSize; //文字大小 - final Widget front; //前面图标 - final bool submitClear; //是否提交清空 - - - const InputButtonConfig( - {this.height = 36, - - this.iconData = Icons.add, - this.fontSize = 14, - this.submitClear = true, - this.front, - this.hint = "I want to say..."}); -} - -class InputButton extends StatefulWidget { - final SubmitCallback onSubmit; - final ValueChanged onChanged; - final VoidCallback onTap; - final InputButtonConfig config; - final String defaultText; - - InputButton( - {Key key, - this.onSubmit, - this.onChanged, - this.defaultText, - this.onTap, - this.config = const InputButtonConfig()}) - : super(key: key); - - @override - _InputButtonState createState() => _InputButtonState(); -} - -class _InputButtonState extends State { - var _height; - var _fontSize; - var _radius; - - TextEditingController _controller; - - @override - void initState() { - super.initState(); - _height = widget.config.height; - _fontSize = widget.config.fontSize; - _radius = Radius.circular(_height / 3.6); - _controller = TextEditingController(text: widget.defaultText??''); - } - - @override - void dispose() { - _controller.dispose(); - super.dispose(); - } - - @override - Widget build(BuildContext context) { - var textField = TextField( - controller: _controller, - maxLines: 1, - style: TextStyle( - fontSize: _fontSize, - color: Colors.lightBlue, - backgroundColor: Colors.white), - decoration: InputDecoration( - filled: true, - fillColor: Colors.white, - hintText: widget.config.hint, - hintStyle: TextStyle(color: Colors.black26, fontSize: _fontSize), - contentPadding: EdgeInsets.only(left: 14.0, top: -_fontSize), - focusedBorder: UnderlineInputBorder( - borderSide: BorderSide(color: Colors.white), - borderRadius: - BorderRadius.only(topLeft: _radius, bottomLeft: _radius), - ), - enabledBorder: UnderlineInputBorder( - borderSide: BorderSide(color: Colors.white), - borderRadius: - BorderRadius.only(topLeft: _radius, bottomLeft: _radius), - ), - ), - onChanged: (str) { - if (widget.onChanged != null) widget.onChanged(str); - }, - onTap: widget.onTap, - ); - var btn = RaisedButton( - - elevation: 0, - child: Icon(widget.config.iconData,color: Theme.of(context).primaryColor,), - color: Color(0x99E0E0E0), - padding: EdgeInsets.zero, - onPressed: () { - FocusScope.of(context).requestFocus(FocusNode()); //收起键盘 - if (widget.onSubmit != null) widget.onSubmit(_controller.text); - if (widget.config.submitClear) { - setState(() { - _controller.clear(); - }); - } - }, - ); - var inputBtn = Row( - mainAxisAlignment: MainAxisAlignment.center, - children: [ - Expanded( - child: Container( - child: textField, - height: _height, - ), - ), - ClipRRect( - borderRadius: BorderRadius.only( - topLeft: Radius.zero, - bottomLeft: Radius.zero, - topRight: _radius, - bottomRight: _radius), - child: Container( - child: btn, - width: _height, - height: _height, - ), - ), - ], - ); - return inputBtn; - } -} diff --git a/lib/components/permanent/panel.dart b/lib/components/permanent/panel.dart deleted file mode 100644 index a0481e0..0000000 --- a/lib/components/permanent/panel.dart +++ /dev/null @@ -1,24 +0,0 @@ -import 'package:flutter/cupertino.dart'; -import 'package:flutter/material.dart'; - - -class Panel extends StatelessWidget { - final double radius; - final Color color; - final Widget child; - - Panel({this.radius = 5.0, this.color, this.child}); - - @override - Widget build(BuildContext context) { - return Container( - child: child, - padding: EdgeInsets.all(10), - decoration: BoxDecoration( - color: color ?? Color(0xffF6F8FA), - borderRadius: BorderRadius.all(Radius.circular(radius))), - ); - } -} - - diff --git a/lib/components/permanent/tag.dart b/lib/components/permanent/tag.dart deleted file mode 100644 index 957d3c7..0000000 --- a/lib/components/permanent/tag.dart +++ /dev/null @@ -1,63 +0,0 @@ -import 'package:flutter/material.dart'; - -class Tag extends StatelessWidget { - final Size size; - final double shadowHeight; - final double tranRate; - final Color color; - - const Tag({this.size = const Size(100, 150),this.shadowHeight=9.0,this.tranRate=0.25,this.color=Colors.red}); - - @override - Widget build(BuildContext context) { - return Container( - width: size.width, - height: size.height, - child: CustomPaint( - painter: _TagPaint( - color: color, - shadowHeight: shadowHeight, - tranRate: tranRate, - ), - ), - ); - } -} - -class _TagPaint extends CustomPainter { - Path path = Path(); - Path shadowPath = Path(); - Paint _paint; - final tranRate; - final double shadowHeight; - final Color color; - - final rate = 0.5; - - _TagPaint({this.tranRate, this.color ,this.shadowHeight}) - : _paint = Paint()..color = color; - - @override - void paint(Canvas canvas, Size size) { - canvas.clipRect(Offset.zero & size); - - path.moveTo(0, 0); - path.relativeLineTo(size.width-shadowHeight*rate, 0); - path.relativeLineTo(0, size.height); - path.relativeLineTo(-(size.width-shadowHeight*rate) / 2, -tranRate * size.height); - path.relativeLineTo(-(size.width-shadowHeight*rate) / 2, tranRate * size.height); - path.close(); - canvas.drawPath(path, _paint..color = color); - - shadowPath.moveTo(size.width-shadowHeight*rate, 0); - shadowPath.relativeLineTo(0, shadowHeight); - shadowPath.relativeLineTo(shadowHeight*rate, 0); - shadowPath.close(); - canvas.drawPath(shadowPath, _paint..color=color.withAlpha(88)); - } - - @override - bool shouldRepaint(CustomPainter oldDelegate) { - return true; - } -} diff --git a/lib/components/project/color_chooser.dart b/lib/components/project/color_chooser.dart deleted file mode 100644 index 71fc877..0000000 --- a/lib/components/project/color_chooser.dart +++ /dev/null @@ -1,124 +0,0 @@ -import 'package:flutter/material.dart'; -import 'package:flutter_unit_mac/components/permanent/circle.dart'; -import 'package:flutter_unit_mac/components/permanent/feedback_widget.dart'; - -typedef CheckCallback = void Function(T color); - -class ColorChooser extends StatefulWidget { - ColorChooser( - {Key key, - this.defaultIndex=0, - this.radius = 10, - @required this.colors, - @required this.onChecked}) - : super(key: key); - final double radius; - final List colors; - final Function(Color) onChecked; - final int defaultIndex; - - @override - _ColorChooserState createState() => _ColorChooserState(); -} - -class _ColorChooserState extends State { - List _checkLi; - int _perPosition = 0; - - @override - void initState() { - _perPosition=widget.defaultIndex; - _checkLi = List.generate(widget.colors.length, (_) => false); - _checkLi[_perPosition] = true; - super.initState(); - } - - @override - Widget build(BuildContext context) { - var li = []; - for (var i = 0; i < widget.colors.length; i++) { - li.add(FeedbackWidget( - a: 0.8, - onPressed: () { - _checkLi[_perPosition] = false; - _perPosition = i; - _checkLi[i] = true; - if (widget.onChecked != null) widget.onChecked(widget.colors[i]); - setState(() {}); - }, - child: Circle( - color: widget.colors[i], - radius: widget.radius, - child: _checkLi[i] - ? Icon( - Icons.star, - size: 15, - color: Colors.white, - ) - : null, -// checked: _checkLi[i] - ))); - } - return Wrap(spacing: 10, runSpacing: 10, children: li); - } -} - -class IconChooser extends StatefulWidget { - IconChooser( - {Key key, - this.radius = 20, - @required this.icons, - @required this.onChecked, - this.initialIndex = 0}) - : super(key: key); - final double radius; - final List icons; - final int initialIndex; - final CheckCallback onChecked; - - @override - _IconChooserState createState() => _IconChooserState(); -} - -class _IconChooserState extends State { - List _checkLi; - int _perPosition = 0; - - @override - void initState() { - _checkLi = List.generate(widget.icons.length, (_) => false); - _checkLi[widget.initialIndex] = true; - super.initState(); - } - - @override - Widget build(BuildContext context) { - var li = []; - for (var i = 0; i < widget.icons.length; i++) { - li.add(GestureDetector( - onTap: () { - _checkLi[_perPosition] = false; - _perPosition = i; - _checkLi[i] = true; - if (widget.onChecked != null) widget.onChecked(i); - setState(() {}); - }, - child: buildIcon(checked: _checkLi[i], icon: widget.icons[i]))); - } - return Wrap( - alignment: WrapAlignment.center, - runSpacing: 10, - spacing: 25, - children: li); - } - - buildIcon({bool checked, IconData icon}) { - var defaultColor = Colors.black26; - var activeColor = Colors.blue; - return Icon( - icon, - color: checked ? activeColor : defaultColor, - size: 35, - ); - } -} diff --git a/lib/components/project/widget_node_panel.dart b/lib/components/project/widget_node_panel.dart deleted file mode 100644 index 147a124..0000000 --- a/lib/components/project/widget_node_panel.dart +++ /dev/null @@ -1,158 +0,0 @@ -import 'package:flutter/material.dart'; -import 'package:flutter/services.dart'; - -import 'package:flutter_unit_mac/app/style/TolyIcon.dart'; -import 'package:flutter_unit_mac/app/utils/Toast.dart'; - -import 'package:flutter_unit_mac/components/permanent/circle.dart'; -import 'package:flutter_unit_mac/components/permanent/code/code_widget.dart'; -import 'package:flutter_unit_mac/components/permanent/panel.dart'; -import 'package:share/share.dart'; -import 'package:toggle_rotate/toggle_rotate.dart'; - -import '../permanent/feedback_widget.dart'; -import '../permanent/code/highlighter_style.dart'; - -/// create by 张风捷特烈 on 2020-04-13 -/// contact me by email 1981462002@qq.com -/// 说明: 一个Widget的知识点对应的界面 - -class WidgetNodePanel extends StatefulWidget { - final String text; - final String subText; - final String code; - final Widget show; - final HighlighterStyle codeStyle; - final String codeFamily; - - WidgetNodePanel( - {this.text, - this.subText, - this.code, - this.show, - this.codeStyle, - this.codeFamily}); - - @override - _WidgetNodePanelState createState() => _WidgetNodePanelState(); -} - -class _WidgetNodePanelState extends State { - var _crossFadeState = CrossFadeState.showFirst; - - bool get isFirst => _crossFadeState == CrossFadeState.showFirst; - - Color get themeColor => Theme.of(context).primaryColor; - - @override - Widget build(BuildContext context) { - return Container( - margin: EdgeInsets.all(10), - child: Column( - crossAxisAlignment: CrossAxisAlignment.center, - children: [ - buildNodeTitle(), - SizedBox( - height: 20, - ), - _buildCode(context), - Padding( - padding: const EdgeInsets.only(top: 10, bottom: 20), - child: widget.show, - ), - _buildNodeInfo(), - Divider(), - ], - ), - ); - } - - Widget buildNodeTitle() => Row( - children: [ - Padding( - padding: const EdgeInsets.symmetric(horizontal: 8), - child: Circle( - color: themeColor, - radius: 5, - ), - ), - Expanded( - child: Text( - '${widget.text}', - style: TextStyle(fontWeight: FontWeight.bold, fontSize: 16), - ), - ), - _buildShareButton(), - _buildCodeButton() - ], - ); - - Widget _buildNodeInfo() => Container( - width: double.infinity, - child: Panel( - child: Text( - '${widget.subText}', - style: TextStyle(fontSize: 14), - )), - ); - - Widget _buildCodeButton() => Padding( - padding: const EdgeInsets.only(right: 10.0), - child: ToggleRotate( - durationMs: 300, - child: Icon( - TolyIcon.icon_code, - color: themeColor, - ), - onTap: _toggleCodePanel, - ), - ); - - Widget _buildShareButton() => FeedbackWidget( - mode: FeedMode.fade, - a: 0.4, - onPressed: _doCopy, - child: Padding( - padding: const EdgeInsets.only( - right: 10, - ), - child: Icon( - Icons.content_copy, - size: 20, - color: themeColor, - ), - ), - ); - - Widget _buildCode(BuildContext context) => AnimatedCrossFade( - firstCurve: Curves.easeInCirc, - secondCurve: Curves.easeInToLinear, - firstChild: Container(), - secondChild: Container( - width: MediaQuery.of(context).size.width, - child: CodeWidget( - fontFamily: widget.codeFamily, - code: isFirst?'':widget.code, - style: widget.codeStyle ?? - HighlighterStyle.fromColors(HighlighterStyle.lightColor), - ), - ), - duration: Duration(milliseconds: 200), - crossFadeState: _crossFadeState, - ); - - //执行分享 - _doCopy() async{ - await Clipboard.setData(ClipboardData(text: widget.code)); - Toast.toast(context, '复制成功!',duration: Duration(seconds: 1)); -// Share.share(widget.code); - } - - // 折叠代码面板 - _toggleCodePanel() { - setState(() { - _crossFadeState = - !isFirst ? CrossFadeState.showFirst : CrossFadeState.showSecond; - }); - } -} diff --git a/lib/main.dart b/lib/main.dart index eb1d4c1..688496b 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -1,8 +1,9 @@ -import 'dart:io'; + import 'package:flutter/material.dart'; -import 'package:flutter_unit_mac/views/app/bloc_wrapper.dart'; -import 'views/app/flutter_app.dart'; +import 'package:flutter_unit/views/pages/app/bloc_wrapper.dart'; +import 'package:flutter_unit/views/pages/app/flutter_app.dart'; + void main() { runApp(BlocWrapper(child: FlutterApp())); diff --git a/lib/model/category_model.dart b/lib/model/category_model.dart index 7634e9c..f0d79c9 100644 --- a/lib/model/category_model.dart +++ b/lib/model/category_model.dart @@ -1,7 +1,7 @@ import 'package:equatable/equatable.dart'; import 'package:flutter/material.dart'; -import 'package:flutter_unit_mac/app/utils/color_utils.dart'; -import 'package:flutter_unit_mac/storage/po/category_po.dart'; +import 'package:flutter_unit/app/utils/color_utils.dart'; +import 'package:flutter_unit/storage/po/category_po.dart'; import 'package:intl/intl.dart'; /// create by 张风捷特烈 on 2020-04-21 diff --git a/lib/model/node_model.dart b/lib/model/node_model.dart index 7d4a5b7..5958d3d 100644 --- a/lib/model/node_model.dart +++ b/lib/model/node_model.dart @@ -1,5 +1,5 @@ import 'package:equatable/equatable.dart'; -import 'package:flutter_unit_mac/storage/po/node_po.dart'; +import 'package:flutter_unit/storage/po/node_po.dart'; /// create by 张风捷特烈 on 2020-03-04 /// contact me by email 1981462002@qq.com diff --git a/lib/model/widget_model.dart b/lib/model/widget_model.dart index bcf5489..16c36a0 100644 --- a/lib/model/widget_model.dart +++ b/lib/model/widget_model.dart @@ -1,9 +1,9 @@ import 'package:equatable/equatable.dart'; import 'package:flutter/cupertino.dart'; -import 'package:flutter_unit_mac/app/convert.dart'; -import 'package:flutter_unit_mac/app/enums.dart'; -import 'package:flutter_unit_mac/app/res/cons.dart'; -import 'package:flutter_unit_mac/storage/po/widget_po.dart'; +import 'package:flutter_unit/app/convert.dart'; +import 'package:flutter_unit/app/enums.dart'; +import 'package:flutter_unit/app/res/cons.dart'; +import 'package:flutter_unit/storage/po/widget_po.dart'; /// create by 张风捷特烈 on 2020-03-04 /// contact me by email 1981462002@qq.com diff --git a/lib/repositories/impl/catagory_db_repository.dart b/lib/repositories/impl/catagory_db_repository.dart index 82ff1cf..14114f5 100644 --- a/lib/repositories/impl/catagory_db_repository.dart +++ b/lib/repositories/impl/catagory_db_repository.dart @@ -1,10 +1,10 @@ -import 'package:flutter_unit_mac/model/category_model.dart'; -import 'package:flutter_unit_mac/model/widget_model.dart'; -import 'package:flutter_unit_mac/repositories/itf/category_repository.dart'; -import 'package:flutter_unit_mac/storage/app_storage.dart'; -import 'package:flutter_unit_mac/storage/dao/category_dao.dart'; -import 'package:flutter_unit_mac/storage/po/category_po.dart'; -import 'package:flutter_unit_mac/storage/po/widget_po.dart'; +import 'package:flutter_unit/model/category_model.dart'; +import 'package:flutter_unit/model/widget_model.dart'; +import 'package:flutter_unit/repositories/itf/category_repository.dart'; +import 'package:flutter_unit/storage/app_storage.dart'; +import 'package:flutter_unit/storage/dao/category_dao.dart'; +import 'package:flutter_unit/storage/po/category_po.dart'; +import 'package:flutter_unit/storage/po/widget_po.dart'; /// create by 张风捷特烈 on 2020-04-21 /// contact me by email 1981462002@qq.com diff --git a/lib/repositories/impl/widget_db_repository.dart b/lib/repositories/impl/widget_db_repository.dart index 027cf59..2ea218b 100644 --- a/lib/repositories/impl/widget_db_repository.dart +++ b/lib/repositories/impl/widget_db_repository.dart @@ -1,13 +1,13 @@ -import 'package:flutter_unit_mac/storage/app_storage.dart'; -import 'package:flutter_unit_mac/app/enums.dart'; -import 'package:flutter_unit_mac/storage/dao/node_dao.dart'; +import 'package:flutter_unit/storage/app_storage.dart'; +import 'package:flutter_unit/app/enums.dart'; +import 'package:flutter_unit/storage/dao/node_dao.dart'; -import 'package:flutter_unit_mac/storage/po/widget_po.dart'; -import 'package:flutter_unit_mac/storage/dao/widget_dao.dart'; -import 'package:flutter_unit_mac/model/node_model.dart'; -import 'package:flutter_unit_mac/model/widget_model.dart'; -import 'package:flutter_unit_mac/repositories/itf/widget_repository.dart'; +import 'package:flutter_unit/storage/po/widget_po.dart'; +import 'package:flutter_unit/storage/dao/widget_dao.dart'; +import 'package:flutter_unit/model/node_model.dart'; +import 'package:flutter_unit/model/widget_model.dart'; +import 'package:flutter_unit/repositories/itf/widget_repository.dart'; /// create by 张风捷特烈 on 2020-03-03 /// contact me by email 1981462002@qq.com diff --git a/lib/repositories/impl/widget_innner_repository.dart b/lib/repositories/impl/widget_innner_repository.dart index 6c7182a..4c86fe4 100644 --- a/lib/repositories/impl/widget_innner_repository.dart +++ b/lib/repositories/impl/widget_innner_repository.dart @@ -1,16 +1,16 @@ import 'dart:convert'; import 'package:flutter/services.dart'; -import 'package:flutter_unit_mac/app/data/flutter_unit_data.dart'; -import 'package:flutter_unit_mac/storage/app_storage.dart'; -import 'package:flutter_unit_mac/app/enums.dart'; -import 'package:flutter_unit_mac/storage/dao/node_dao.dart'; +import 'package:flutter_unit/app/data/flutter_unit_data.dart'; +import 'package:flutter_unit/storage/app_storage.dart'; +import 'package:flutter_unit/app/enums.dart'; +import 'package:flutter_unit/storage/dao/node_dao.dart'; -import 'package:flutter_unit_mac/storage/po/widget_po.dart'; -import 'package:flutter_unit_mac/storage/dao/widget_dao.dart'; -import 'package:flutter_unit_mac/model/node_model.dart'; -import 'package:flutter_unit_mac/model/widget_model.dart'; -import 'package:flutter_unit_mac/repositories/itf/widget_repository.dart'; +import 'package:flutter_unit/storage/po/widget_po.dart'; +import 'package:flutter_unit/storage/dao/widget_dao.dart'; +import 'package:flutter_unit/model/node_model.dart'; +import 'package:flutter_unit/model/widget_model.dart'; +import 'package:flutter_unit/repositories/itf/widget_repository.dart'; /// create by 张风捷特烈 on 2020-03-03 /// contact me by email 1981462002@qq.com diff --git a/lib/repositories/itf/category_repository.dart b/lib/repositories/itf/category_repository.dart index 526ed8b..fb30e56 100644 --- a/lib/repositories/itf/category_repository.dart +++ b/lib/repositories/itf/category_repository.dart @@ -1,6 +1,6 @@ -import 'package:flutter_unit_mac/model/category_model.dart'; -import 'package:flutter_unit_mac/model/widget_model.dart'; -import 'package:flutter_unit_mac/storage/po/category_po.dart'; +import 'package:flutter_unit/model/category_model.dart'; +import 'package:flutter_unit/model/widget_model.dart'; +import 'package:flutter_unit/storage/po/category_po.dart'; /// create by 张风捷特烈 on 2020-04-21 /// contact me by email 1981462002@qq.com diff --git a/lib/repositories/itf/widget_repository.dart b/lib/repositories/itf/widget_repository.dart index 73e0c28..f93fb05 100644 --- a/lib/repositories/itf/widget_repository.dart +++ b/lib/repositories/itf/widget_repository.dart @@ -1,9 +1,9 @@ -import 'package:flutter_unit_mac/app/enums.dart'; -import 'package:flutter_unit_mac/storage/dao/widget_dao.dart'; -import 'package:flutter_unit_mac/model/node_model.dart'; -import 'package:flutter_unit_mac/model/widget_model.dart'; +import 'package:flutter_unit/app/enums.dart'; +import 'package:flutter_unit/storage/dao/widget_dao.dart'; +import 'package:flutter_unit/model/node_model.dart'; +import 'package:flutter_unit/model/widget_model.dart'; /// create by 张风捷特烈 on 2020-03-03 /// contact me by email 1981462002@qq.com diff --git a/lib/storage/app_storage.dart b/lib/storage/app_storage.dart index 1eba38a..e24a901 100644 --- a/lib/storage/app_storage.dart +++ b/lib/storage/app_storage.dart @@ -3,10 +3,10 @@ import 'dart:io'; import 'dart:typed_data'; import 'package:flutter/services.dart'; -import 'package:flutter_unit_mac/app/res/cons.dart'; -import 'package:flutter_unit_mac/app/res/sp.dart'; -import 'package:flutter_unit_mac/blocs/global/global_state.dart'; -import 'package:flutter_unit_mac/storage/po/node_po.dart'; +import 'package:flutter_unit/app/res/cons.dart'; +import 'package:flutter_unit/app/res/sp.dart'; +import 'package:flutter_unit/blocs/global/global_state.dart'; +import 'package:flutter_unit/storage/po/node_po.dart'; import 'package:shared_preferences/shared_preferences.dart'; import 'package:sqflite/sqflite.dart'; import 'package:path/path.dart' as path; diff --git a/lib/storage/dao/node_dao.dart b/lib/storage/dao/node_dao.dart index 75ee095..c8e3990 100644 --- a/lib/storage/dao/node_dao.dart +++ b/lib/storage/dao/node_dao.dart @@ -1,4 +1,4 @@ -import 'package:flutter_unit_mac/storage/app_storage.dart'; +import 'package:flutter_unit/storage/app_storage.dart'; import '../po/node_po.dart'; diff --git a/lib/storage/dao/widget_dao.dart b/lib/storage/dao/widget_dao.dart index 235ccd1..4ff5e6d 100644 --- a/lib/storage/dao/widget_dao.dart +++ b/lib/storage/dao/widget_dao.dart @@ -1,5 +1,5 @@ -import 'package:flutter_unit_mac/storage/app_storage.dart'; -import 'package:flutter_unit_mac/app/enums.dart'; +import 'package:flutter_unit/storage/app_storage.dart'; +import 'package:flutter_unit/app/enums.dart'; import '../po/widget_po.dart'; diff --git a/lib/views/app/bloc_wrapper.dart b/lib/views/app/bloc_wrapper.dart deleted file mode 100644 index 67bce23..0000000 --- a/lib/views/app/bloc_wrapper.dart +++ /dev/null @@ -1,50 +0,0 @@ -import 'package:flutter/material.dart'; -import 'package:flutter_bloc/flutter_bloc.dart'; -import 'package:flutter_unit_mac/app/enums.dart'; -import 'package:flutter_unit_mac/blocs/bloc_exp.dart'; -import 'package:flutter_unit_mac/repositories/impl/catagory_db_repository.dart'; -import 'package:flutter_unit_mac/repositories/impl/widget_db_repository.dart'; -import 'package:flutter_unit_mac/repositories/impl/widget_innner_repository.dart'; -import 'package:flutter_unit_mac/storage/app_storage.dart'; - -/// create by 张风捷特烈 on 2020/4/28 -/// contact me by email 1981462002@qq.com -/// 说明: - -final storage = AppStorage(); - -class BlocWrapper extends StatelessWidget { - final Widget child; - - BlocWrapper({this.child}); - - final repository = WidgetInnerRepository(storage); - final categoryRepo = CategoryDbRepository(storage); - - @override - Widget build(BuildContext context) { - return MultiBlocProvider(//使用MultiBlocProvider包裹 - providers: [ - //Bloc提供器 - BlocProvider( - create: (_) => GlobalBloc(storage)..add(EventInitApp())), - - BlocProvider( - create: (_) => HomeBloc(repository: repository) - ..add(EventTabTap(WidgetFamily.statelessWidget))), - - BlocProvider( - create: (_) => DetailBloc(repository: repository)), - BlocProvider( - create: (_) => - CategoryBloc(repository: categoryRepo)..add(EventLoadCategory())), - - BlocProvider( - create: (_) => - CollectBloc(repository: repository)..add(EventSetCollectData())), - - BlocProvider( - create: (_) => SearchBloc(repository: repository)), - ], child: child); - } -} \ No newline at end of file diff --git a/lib/views/app/flutter_app.dart b/lib/views/app/flutter_app.dart deleted file mode 100644 index fc60335..0000000 --- a/lib/views/app/flutter_app.dart +++ /dev/null @@ -1,31 +0,0 @@ -import 'package:flutter/material.dart'; -import 'package:flutter_bloc/flutter_bloc.dart'; -import 'package:flutter_unit_mac/app/router.dart'; -import 'package:flutter_unit_mac/blocs/bloc_exp.dart'; -import 'package:flutter_unit_mac/views/app/splash/unit_splash.dart'; - -/// create by 张风捷特烈 on 2020/4/28 -/// contact me by email 1981462002@qq.com -/// 说明: - -class FlutterApp extends StatelessWidget { - @override - Widget build(BuildContext context) { - return BlocBuilder(builder: (_, state) { - return BlocProvider( - create: (_) => CategoryWidgetBloc( - categoryBloc: BlocProvider.of(context)), - child: MaterialApp( - title: 'Flutter Unit', - debugShowCheckedModeBanner: false, - onGenerateRoute: Router.generateRoute, - theme: ThemeData( - visualDensity: VisualDensity.adaptivePlatformDensity, - primarySwatch: state.themeColor, - fontFamily: state.fontFamily, - ), - home: UnitSplash()), - ); - }); - } -} diff --git a/lib/views/app/navigation/unit_bottom_bar.dart b/lib/views/app/navigation/unit_bottom_bar.dart deleted file mode 100644 index 328fac2..0000000 --- a/lib/views/app/navigation/unit_bottom_bar.dart +++ /dev/null @@ -1,90 +0,0 @@ -import 'package:flutter/material.dart'; - -/// create by 张风捷特烈 on 2020-04-11 -/// contact me by email 1981462002@qq.com -/// 说明: - -class UnitBottomBar extends StatefulWidget { - final Color color; - final Map itemData; - final Function(int) onItemClick; - - UnitBottomBar( - {this.color = Colors.blue, - @required this.itemData, - @required this.onItemClick}); - - @override - _UnitBottomBarState createState() => _UnitBottomBarState(); -} - -class _UnitBottomBarState extends State { - int _position = 0; - - @override - Widget build(BuildContext context) { - return BottomAppBar( - elevation: 0, - shape: const CircularNotchedRectangle(), - notchMargin: 5, - color: widget.color, - child: Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: info - .map((e) => _buildChild(context, info.indexOf(e), widget.color)) - .toList(), - )); - } - - List get info => widget.itemData.keys.toList(); - - final borderTR = const BorderRadius.only(topRight: Radius.circular(10)); - final borderTL = const BorderRadius.only(topLeft: Radius.circular(10)); - final paddingTR = const EdgeInsets.only(top: 2, right: 2); - final paddingTL = const EdgeInsets.only(top: 2, left: 2); - - Widget _buildChild(BuildContext context, int i, Color color) { - var active = i == _position; - bool left = i == 0; - - return GestureDetector( - onTap: () => _tapTab(i), - onLongPress: () => _onLongPress(context, i), - child: Material( - elevation: 2, - shape: RoundedRectangleBorder(borderRadius: left ? borderTR : borderTL), - child: Container( - margin: left ? paddingTR : paddingTL, - alignment: Alignment.center, - decoration: BoxDecoration( - color: color.withAlpha(88), - borderRadius: left ? borderTR : borderTL), - height: 45, - width: 100, - child: Icon( - widget.itemData[info[i]], - color: active ? color : Colors.white, - size: active ? 28 : 24, - )), - ), - ); - } - - _tapTab(int i) { - setState(() { - _position = i; - if (widget.onItemClick != null) { - widget.onItemClick(_position); - } - }); - } - - _onLongPress(BuildContext context, int i) { - if (i == 0) { - Scaffold.of(context).openDrawer(); - } - if (i == 1) { - Scaffold.of(context).openEndDrawer(); - } - } -} diff --git a/lib/views/app/navigation/unit_navigation.dart b/lib/views/app/navigation/unit_navigation.dart deleted file mode 100644 index 2b2feb6..0000000 --- a/lib/views/app/navigation/unit_navigation.dart +++ /dev/null @@ -1,290 +0,0 @@ -import 'package:flutter/cupertino.dart'; -import 'package:flutter/material.dart'; -import 'package:flutter_bloc/flutter_bloc.dart'; -import 'package:flutter_unit_mac/app/res/cons.dart'; -import 'package:flutter_unit_mac/app/router.dart'; -import 'package:flutter_unit_mac/app/style/TolyIcon.dart'; -import 'package:flutter_unit_mac/blocs/bloc_exp.dart'; -import 'package:flutter_unit_mac/components/permanent/circle_image.dart'; -import 'package:flutter_unit_mac/components/permanent/feedback_widget.dart'; -import 'package:flutter_unit_mac/views/app/navigation/unit_bottom_bar.dart'; -import 'package:flutter_unit_mac/views/pages/category/collect_page.dart'; -import 'package:flutter_unit_mac/views/pages/category/home_right_drawer.dart'; -import 'package:flutter_unit_mac/views/pages/home/home_drawer.dart'; -import 'package:flutter_unit_mac/views/pages/home/home_page.dart'; -import 'package:flutter_unit_mac/views/pages/unit_todo/bug_unit_page.dart'; -import 'package:flutter_unit_mac/views/pages/unit_todo/layout_unit_page.dart'; -import 'package:flutter_unit_mac/views/pages/unit_todo/paint_unit_page.dart'; -import 'package:url_launcher/url_launcher.dart'; - -class UnitNavigation extends StatefulWidget { - @override - _UnitNavigationState createState() => _UnitNavigationState(); -} - -class _UnitNavigationState extends State { - PageController _controller; //页面控制器,初始0 - - @override - void initState() { - _controller = PageController(); - super.initState(); - } - - @override - void dispose() { - _controller.dispose(); //释放控制器 - super.dispose(); - } - final tempText = Text('这里是一片未知的领域\n等待着勇者的探寻...',style: TextStyle(fontSize: 24,color: Colors.white),); - @override - Widget build(BuildContext context) { - return BlocBuilder( - builder: (_, state) => Scaffold( - drawer: HomeDrawer(color: state.homeColor), - //左滑页 - endDrawer: HomeRightDrawer( - color: state.homeColor, - ), - //右滑页 - floatingActionButton: _buildSearchButton(state.homeColor), - body: Row( - children: [ - _buildLeftNav(), - Expanded( - child: Container( - child: PageView( - physics: const NeverScrollableScrollPhysics(), - //使用PageView实现页面的切换 - controller: _controller, - children: [ - HomePage(), - Container(color: Colors.red,alignment: Alignment.center,child:tempText,), - Container(color: Colors.blue,alignment: Alignment.center,child: tempText), - Container(color: Colors.purpleAccent,alignment: Alignment.center,child: tempText), - Container(color: Colors.green,alignment: Alignment.center,child: tempText), - -// CollectPage(), -// PaintUnitPage(), -// LayoutUnitPage(), -// BugUnitPage(), - ], - ), - ), - ), - ], - ), - )); - } - - Widget _buildSearchButton(Color color) { - return FloatingActionButton( - elevation: 2, - backgroundColor: color, - child: const Icon(Icons.search), - onPressed: () => Navigator.of(context).pushNamed(Router.search), - ); - } - - _onTapNav(int index) { - _controller.jumpToPage(index); - if (index == 1) { - BlocProvider.of(context).add(EventSetCollectData()); - } - } - - Widget _buildLeftNav() { - return Container( - padding: EdgeInsets.only(top: 20), - alignment: Alignment.topCenter, - margin: EdgeInsets.only(right: 1), - width: 120, - decoration: BoxDecoration(color: Color(0xff2C3036), boxShadow: [ - BoxShadow(color: Colors.grey, offset: Offset(1, 0), blurRadius: 2) - ]), - child: Column( - children: [ - Wrap( - direction: Axis.vertical, - spacing: 10, - crossAxisAlignment: WrapCrossAlignment.center, - children: [ - CircleImage( - image: AssetImage('assets/images/icon_head.png'), - size: 60, - ), - Text( - '张风捷特烈', - style: TextStyle(color: Colors.white70), - ) - ], - ), - buildIcons(), - Divider( - color: Colors.white, - height: 1, - endIndent: 20, - ), -// SizedBox(height: 60,), - Expanded( - flex: 5, - child: Center( - child: RightNavBar( - itemData: Cons.ICONS_MAP, - onItemClick: _onTapNav, - color: Theme.of(context).primaryColor, - ), - ), - ), - - Expanded( - child: Container(), - flex: 1, - ), - Divider( - indent: 20, - color: Colors.white, - height: 1, - ), - Builder( - builder: (ctx) => FeedbackWidget( - onPressed: () => Scaffold.of(ctx).openDrawer(), - child: Padding( - padding: const EdgeInsets.only(bottom: 20, top: 20), - child: Icon( - Icons.settings, - color: Colors.white, - ), - ), - ), - ), - ], - ), - ); - } - - Widget buildIcons() { - return Padding( - padding: const EdgeInsets.only(bottom: 20, top: 20), - child: Wrap( - spacing: 5, - children: [ - FeedbackWidget( - onPressed: () => _launchURL("http://blog.toly1994.com"), - child: Icon( - TolyIcon.icon_item, - color: Colors.white, - ), - ), - FeedbackWidget( - onPressed: () => - _launchURL("https://github.com/toly1994328/FlutterUnit"), - child: Icon( - TolyIcon.icon_github, - color: Colors.white, - ), - ), - FeedbackWidget( - onPressed: () => - _launchURL("https://juejin.im/user/5b42c0656fb9a04fe727eb37"), - child: Icon( - TolyIcon.icon_juejin, - color: Colors.white, - ), - ), - ], - ), - ); - } - - _launchURL(String url) async { - if (await canLaunch(url)) { - await launch(url); - } else { - debugPrint('Could not launch $url'); - } - } -} - -class RightNavBar extends StatefulWidget { - final Color color; - final Map itemData; - final Function(int) onItemClick; - final Size itemSize; - - RightNavBar( - {this.color = Colors.blue, - this.itemData, - this.onItemClick, - this.itemSize = const Size(120, 35)}); - - @override - _RightNavBarState createState() => _RightNavBarState(); -} - -class _RightNavBarState extends State { - int _position = 0; - - List get info => widget.itemData.keys.toList(); - - @override - Widget build(BuildContext context) { - return Column( - mainAxisSize: MainAxisSize.min, - children: info - .map((e) => _buildChild(context, info.indexOf(e), widget.color)) - .toList(), - ); - } - - Widget _buildChild(BuildContext context, int i, Color color) { - var active = i == _position; - - return GestureDetector( - onTap: () => _tapTab(i), - child: Container( - alignment: Alignment.topLeft, - margin: EdgeInsets.only(top: 10), - width: widget.itemSize.width, - child: UnconstrainedBox( - child: Container( - alignment: Alignment.center, - decoration: BoxDecoration( - color: active ? widget.color : Colors.white.withAlpha(33), - borderRadius: BorderRadius.only( - topRight: Radius.circular(20), - bottomRight: Radius.circular(20))), - width: - active ? widget.itemSize.width*0.95 : widget.itemSize.width * 0.85, - height: widget.itemSize.height, - child: Wrap( - spacing: 10, - crossAxisAlignment: WrapCrossAlignment.center, - children: [ - Icon( - widget.itemData[info[i]], - size: active ? 24 : 20, - color: active ? Colors.white:Colors.white70, - ), - Text( - info[i], - style: TextStyle( - color: active ? Colors.white:Colors.white70, - ), - ), - ], - ), - ), - ), - )); - } - - _tapTab(int i) { - setState(() { - _position = i; - if (widget.onItemClick != null) { - widget.onItemClick(_position); - } - }); - } -} diff --git a/lib/views/app/splash/unit_paint.dart b/lib/views/app/splash/unit_paint.dart deleted file mode 100644 index 121c40d..0000000 --- a/lib/views/app/splash/unit_paint.dart +++ /dev/null @@ -1,97 +0,0 @@ -import 'package:flutter/material.dart'; - -class UnitPainter extends CustomPainter { - Paint _paint; - double width; - double factor; - Color color; - Path _path1 = Path(); - Path _path2 = Path(); - Path _path3 = Path(); - Path _path4 = Path(); - - UnitPainter({this.width = 200.0, this.factor,this.color=Colors.blue}) { - _paint = Paint(); - } - - @override - void paint(Canvas canvas, Size size) { - - - canvas.translate( - size.width / 2 - width * 0.5, size.height / 2 - width * 0.5); - - canvas.save(); - canvas.translate( - -size.width / 2 * (1 - factor), -size.width / 2 * (1 - factor)); - drawColor1(canvas); - canvas.restore(); - - canvas.save(); - - canvas.translate( - size.width / 2 * (1 - factor), -size.width / 2 * (1 - factor)); - drawColor2(canvas); - canvas.restore(); - - canvas.save(); - canvas.translate( - size.width / 2 * (1 - factor), size.width / 2 * (1 - factor)); - drawColor3(canvas); - canvas.restore(); - - canvas.save(); - canvas.translate( - -size.width / 2 * (1 - factor), size.width / 2 * (1 - factor)); - drawColor4(canvas); - canvas.restore(); - } - - @override - bool shouldRepaint(CustomPainter oldDelegate) { - return true; - } - - void drawColor1(Canvas canvas) { - _path1.moveTo(0, 0); - _path1.lineTo(width * 0.618 * factor - 1, 0); - _path1.lineTo(width * 0.5 - 1, width * 0.5 - 1); - _path1.lineTo(0, width * (1 - 0.618) * factor - 1); - - canvas.drawPath(_clipAngle(_path1), _paint..color = Colors.red); - } - - void drawColor2(Canvas canvas) { - _path2.moveTo(width * 0.618 * factor, 0); - _path2.lineTo(width, 0); - _path2.lineTo(width, width * 0.618 * factor); - _path2.lineTo(width * 0.5, width * 0.5); - - canvas.drawPath(_clipAngle(_path2), _paint..color = Colors.blue); - } - - void drawColor3(Canvas canvas) { - _path3.moveTo(width * 0.5 + 1, width * 0.5 + 1); - _path3.lineTo(width, width * 0.618 * factor + 1); - _path3.lineTo(width, width); - _path3.lineTo(width * (1 - 0.618) * factor + 1, width); - canvas.drawPath(_clipAngle(_path3), _paint..color = Colors.green); - } - - void drawColor4(Canvas canvas) { - _path4.moveTo(0, width * (1 - 0.618) * factor); - _path4.lineTo(width * 0.5, width * 0.5); - _path4.lineTo(width * (1 - 0.618) * factor, width); - _path4.lineTo(0, width); - canvas.drawPath(_clipAngle(_path4), _paint..color = Colors.yellow); - } - - Path _clipAngle(Path path) { - return Path.combine( - PathOperation.difference, - path, - Path() - ..addOval(Rect.fromCircle( - center: Offset(width * 0.5, width * 0.5), radius: 25.0))); - } -} \ No newline at end of file diff --git a/lib/views/app/splash/unit_splash.dart b/lib/views/app/splash/unit_splash.dart deleted file mode 100644 index e3fcb2f..0000000 --- a/lib/views/app/splash/unit_splash.dart +++ /dev/null @@ -1,164 +0,0 @@ -import 'dart:io'; -import 'dart:math'; - -import 'package:flutter/cupertino.dart'; -import 'package:flutter/material.dart'; -import 'package:flutter/services.dart'; -import 'unit_paint.dart'; -import 'package:flutter_unit_mac/app/router.dart'; - -/// create by 张风捷特烈 on 2020-03-07 -/// contact me by email 1981462002@qq.com -/// 说明: app 闪屏页 - -class UnitSplash extends StatefulWidget { - final double size; - - UnitSplash({this.size = 200}); - - @override - _UnitSplashState createState() => _UnitSplashState(); -} - -class _UnitSplashState extends State with TickerProviderStateMixin { - AnimationController _controller; - AnimationController _secondController; - double _factor=0.0; - Animation _curveAnim; - - bool _animEnd = false; - - @override - void initState() { - SystemUiOverlayStyle systemUiOverlayStyle = - SystemUiOverlayStyle(statusBarColor: Colors.transparent); - SystemChrome.setSystemUIOverlayStyle(systemUiOverlayStyle); - - _controller = - AnimationController(duration: Duration(milliseconds: 1000), vsync: this) - ..addListener(() => setState(() { - return _factor = _curveAnim.value; - })) - ..addStatusListener((s) { - if (s == AnimationStatus.completed) { - setState(() { - _animEnd = true; - Future.delayed(Duration(milliseconds: 600)).then((e){ - Navigator.of(context).pushReplacementNamed(Router.nav); - }); - }); - } - }); - - _curveAnim = - CurvedAnimation(parent: _controller, curve: Curves.fastOutSlowIn); - _controller.forward(); - super.initState(); - } - - @override - Widget build(BuildContext context) { - var winH = MediaQuery.of(context).size.height; - var winW = MediaQuery.of(context).size.width; - - return Scaffold( - body: Stack( - alignment: Alignment.center, - children: [ - buildLogo(Colors.blue), - Container( - width: winW, - height: winH, - child: Container() -// CustomPaint( -// painter: UnitPainter(factor: _factor), -// ), - ), - buildText(winH, winW), - buildHead(), - buildPower(), - ], - ), - ); - } - - Positioned buildText(double winH, double winW) { - final shadowStyle = TextStyle( - fontSize: 45, - color: Theme.of(context).primaryColor, - fontWeight: FontWeight.bold, - shadows: [ - const Shadow( - color: Colors.grey, - offset: Offset(1.0, 1.0), - blurRadius: 1.0, - ) - ], - ); - - return Positioned( - top: winH / 1.4, - child: AnimatedOpacity( - duration: const Duration(milliseconds: 600), - opacity: _animEnd ? 1.0 : 0.0, - child: Text( - 'Flutter Unit', - style: shadowStyle, - )), - ); - } - - final colors = [Colors.red, Colors.yellow, Colors.blue]; - - Widget buildLogo(Color primaryColor) { - return SlideTransition( - position: Tween( - begin: const Offset(0, 0), - end: const Offset(0, -1.5), - ).animate(_controller), - child: RotationTransition( - turns: _controller, - child: ScaleTransition( - scale: Tween(begin: 2.0, end: 1.0).animate(_controller), - child: FadeTransition( - opacity: _controller, - child: Container( - height: 120, - child: FlutterLogo( - colors: primaryColor, - size: 60, - ), - )), - )), - ); - } - - Widget buildHead() => SlideTransition( - position: Tween( - end: const Offset(0, 0), - begin: const Offset(0, -5), - ).animate(_controller), - child: Container( - height: 150*_factor, - width: 150*_factor, - child: Image.asset('assets/images/icon_head.png'), - )); - - Widget buildPower() => Positioned( - bottom: 30, - right: 30, - child: AnimatedOpacity( - duration: const Duration(milliseconds: 300), - opacity: _animEnd ? 1.0 : 0.0, - child: const Text("Power By 张风捷特烈", - style: TextStyle( - color: Colors.grey, - shadows: [ - Shadow( - color: Colors.black, - blurRadius: 1, - offset: Offset(0.3, 0.3)) - ], - fontSize: 16))), - ); -} diff --git a/lib/views/common/empty_page.dart b/lib/views/components/project/default/empty_page.dart similarity index 100% rename from lib/views/common/empty_page.dart rename to lib/views/components/project/default/empty_page.dart diff --git a/lib/views/common/loading_page.dart b/lib/views/components/project/default/loading_page.dart similarity index 100% rename from lib/views/common/loading_page.dart rename to lib/views/components/project/default/loading_page.dart diff --git a/lib/views/common/unit_drawer_header.dart b/lib/views/components/project/default/unit_drawer_header.dart similarity index 98% rename from lib/views/common/unit_drawer_header.dart rename to lib/views/components/project/default/unit_drawer_header.dart index e0373b4..0077c41 100644 --- a/lib/views/common/unit_drawer_header.dart +++ b/lib/views/components/project/default/unit_drawer_header.dart @@ -27,7 +27,7 @@ class UnitDrawerHeader extends StatelessWidget { crossAxisAlignment: WrapCrossAlignment.center, children: [ FlutterLogo( - colors: Colors.orange, + // colors: Colors.orange, size: 35, ), Text( diff --git a/lib/views/dialogs/delete_category_dialog.dart b/lib/views/components/project/dialogs/delete_category_dialog.dart similarity index 97% rename from lib/views/dialogs/delete_category_dialog.dart rename to lib/views/components/project/dialogs/delete_category_dialog.dart index b268b4c..6e40bf0 100644 --- a/lib/views/dialogs/delete_category_dialog.dart +++ b/lib/views/components/project/dialogs/delete_category_dialog.dart @@ -1,5 +1,6 @@ import 'package:flutter/material.dart'; -import 'package:flutter_unit_mac/components/permanent/feedback_widget.dart'; +import 'package:flutter_unit/views/components/permanent/feedback_widget.dart'; + /// create by 张风捷特烈 on 2020-04-21 /// contact me by email 1981462002@qq.com diff --git a/lib/views/dialogs/dialog_about.dart b/lib/views/components/project/dialogs/dialog_about.dart similarity index 96% rename from lib/views/dialogs/dialog_about.dart rename to lib/views/components/project/dialogs/dialog_about.dart index f3cd9ac..0be88d3 100644 --- a/lib/views/dialogs/dialog_about.dart +++ b/lib/views/components/project/dialogs/dialog_about.dart @@ -1,5 +1,5 @@ import 'package:flutter/material.dart'; -import 'package:flutter_unit_mac/app/res/cons.dart'; +import 'package:flutter_unit/app/res/cons.dart'; class DialogAbout extends StatelessWidget { static show(BuildContext context){ diff --git a/lib/views/items/category_list_item.dart b/lib/views/components/project/items/category_list_item.dart similarity index 94% rename from lib/views/items/category_list_item.dart rename to lib/views/components/project/items/category_list_item.dart index 36960e9..c307966 100644 --- a/lib/views/items/category_list_item.dart +++ b/lib/views/components/project/items/category_list_item.dart @@ -1,8 +1,8 @@ import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; -import 'package:flutter_unit_mac/components/permanent/circle_text.dart'; -import 'package:flutter_unit_mac/components/permanent/feedback_widget.dart'; -import 'package:flutter_unit_mac/model/category_model.dart'; +import 'package:flutter_unit/model/category_model.dart'; +import 'package:flutter_unit/views/components/permanent/circle_text.dart'; +import 'package:flutter_unit/views/components/permanent/feedback_widget.dart'; /// create by 张风捷特烈 on 2020-04-21 /// contact me by email 1981462002@qq.com diff --git a/lib/views/items/collect_widget_list_item.dart b/lib/views/components/project/items/collect_widget_list_item.dart similarity index 89% rename from lib/views/items/collect_widget_list_item.dart rename to lib/views/components/project/items/collect_widget_list_item.dart index 187766b..c142ff8 100644 --- a/lib/views/items/collect_widget_list_item.dart +++ b/lib/views/components/project/items/collect_widget_list_item.dart @@ -1,12 +1,13 @@ import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:flutter_star/flutter_star.dart'; -import 'package:flutter_unit_mac/app/res/cons.dart'; -import 'package:flutter_unit_mac/app/style/shape/techno_shape.dart'; -import 'package:flutter_unit_mac/components/permanent/circle_image.dart'; -import 'package:flutter_unit_mac/components/permanent/circle_text.dart'; -import 'package:flutter_unit_mac/components/permanent/feedback_widget.dart'; -import 'package:flutter_unit_mac/model/widget_model.dart'; +import 'package:flutter_unit/app/res/cons.dart'; +import 'package:flutter_unit/app/style/shape/techno_shape.dart'; + +import 'package:flutter_unit/model/widget_model.dart'; +import 'package:flutter_unit/views/components/permanent/circle_image.dart'; +import 'package:flutter_unit/views/components/permanent/circle_text.dart'; +import 'package:flutter_unit/views/components/permanent/feedback_widget.dart'; class CollectWidgetListItem extends StatelessWidget { final WidgetModel data; diff --git a/lib/views/items/coupon_widget_list_item.dart b/lib/views/components/project/items/coupon_widget_list_item.dart similarity index 88% rename from lib/views/items/coupon_widget_list_item.dart rename to lib/views/components/project/items/coupon_widget_list_item.dart index e499ca6..a18c14e 100644 --- a/lib/views/items/coupon_widget_list_item.dart +++ b/lib/views/components/project/items/coupon_widget_list_item.dart @@ -1,14 +1,15 @@ import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:flutter_star/flutter_star.dart'; -import 'package:flutter_unit_mac/app/res/cons.dart'; -import 'package:flutter_unit_mac/app/style/shape/coupon_shape_border.dart'; -import 'package:flutter_unit_mac/blocs/collect/collect_bloc.dart'; -import 'package:flutter_unit_mac/blocs/collect/collect_state.dart'; -import 'package:flutter_unit_mac/components/permanent/circle_image.dart'; -import 'package:flutter_unit_mac/components/permanent/circle_text.dart'; -import 'package:flutter_unit_mac/components/permanent/tag.dart'; -import 'package:flutter_unit_mac/model/widget_model.dart'; +import 'package:flutter_unit/app/res/cons.dart'; +import 'package:flutter_unit/app/style/shape/coupon_shape_border.dart'; +import 'package:flutter_unit/blocs/collect/collect_bloc.dart'; +import 'package:flutter_unit/blocs/collect/collect_state.dart'; + +import 'package:flutter_unit/model/widget_model.dart'; +import 'package:flutter_unit/views/components/permanent/circle_image.dart'; +import 'package:flutter_unit/views/components/permanent/circle_text.dart'; +import 'package:flutter_unit/views/components/permanent/tag.dart'; class CouponWidgetListItem extends StatelessWidget { final WidgetModel data; diff --git a/lib/views/items/home_item_support.dart b/lib/views/components/project/items/home_item_support.dart similarity index 94% rename from lib/views/items/home_item_support.dart rename to lib/views/components/project/items/home_item_support.dart index 54ebc97..58dbd31 100644 --- a/lib/views/items/home_item_support.dart +++ b/lib/views/components/project/items/home_item_support.dart @@ -1,8 +1,8 @@ import 'dart:math'; import 'package:flutter/material.dart'; -import 'package:flutter_unit_mac/app/enums.dart'; -import 'package:flutter_unit_mac/model/widget_model.dart'; +import 'package:flutter_unit/app/enums.dart'; +import 'package:flutter_unit/model/widget_model.dart'; import 'coupon_widget_list_item.dart'; import 'techno_widget_list_item.dart'; diff --git a/lib/views/items/techno_widget_list_item.dart b/lib/views/components/project/items/techno_widget_list_item.dart similarity index 88% rename from lib/views/items/techno_widget_list_item.dart rename to lib/views/components/project/items/techno_widget_list_item.dart index ab47d70..7d025d0 100644 --- a/lib/views/items/techno_widget_list_item.dart +++ b/lib/views/components/project/items/techno_widget_list_item.dart @@ -2,14 +2,14 @@ import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:flutter_star/flutter_star.dart'; -import 'package:flutter_unit_mac/app/res/cons.dart'; -import 'package:flutter_unit_mac/app/style/shape/techno_shape.dart'; -import 'package:flutter_unit_mac/blocs/collect/collect_bloc.dart'; -import 'package:flutter_unit_mac/blocs/collect/collect_state.dart'; -import 'package:flutter_unit_mac/components/permanent/circle_image.dart'; -import 'package:flutter_unit_mac/components/permanent/circle_text.dart'; -import 'package:flutter_unit_mac/components/permanent/tag.dart'; -import 'package:flutter_unit_mac/model/widget_model.dart'; +import 'package:flutter_unit/app/res/cons.dart'; +import 'package:flutter_unit/app/style/shape/techno_shape.dart'; +import 'package:flutter_unit/blocs/collect/collect_bloc.dart'; +import 'package:flutter_unit/blocs/collect/collect_state.dart'; +import 'package:flutter_unit/model/widget_model.dart'; +import 'package:flutter_unit/views/components/permanent/circle_image.dart'; +import 'package:flutter_unit/views/components/permanent/circle_text.dart'; +import 'package:flutter_unit/views/components/permanent/tag.dart'; class TechnoWidgetListItem extends StatelessWidget { final WidgetModel data; diff --git a/lib/views/pages/about/about_app_page.dart b/lib/views/pages/about/about_app_page.dart index 779407b..c6fa562 100644 --- a/lib/views/pages/about/about_app_page.dart +++ b/lib/views/pages/about/about_app_page.dart @@ -4,11 +4,12 @@ import 'package:flutter/cupertino.dart'; /// 说明: import 'package:flutter/material.dart'; -import 'package:flutter_unit_mac/app/style/TolyIcon.dart'; -import 'package:flutter_unit_mac/components/permanent/circle.dart'; -import 'package:flutter_unit_mac/components/permanent/circle_image.dart'; -import 'package:flutter_unit_mac/components/permanent/feedback_widget.dart'; -import 'package:flutter_unit_mac/components/permanent/panel.dart'; +import 'package:flutter_unit/app/res/toly_icon.dart'; +import 'package:flutter_unit/views/components/permanent/circle.dart'; +import 'package:flutter_unit/views/components/permanent/circle_image.dart'; +import 'package:flutter_unit/views/components/permanent/feedback_widget.dart'; +import 'package:flutter_unit/views/components/permanent/panel.dart'; + import 'package:url_launcher/url_launcher.dart'; class AboutAppPage extends StatelessWidget { diff --git a/lib/views/pages/about/about_me_page.dart b/lib/views/pages/about/about_me_page.dart index ba6099d..438e648 100644 --- a/lib/views/pages/about/about_me_page.dart +++ b/lib/views/pages/about/about_me_page.dart @@ -3,9 +3,9 @@ /// 说明: import 'package:flutter/material.dart'; -import 'package:flutter_unit_mac/app/style/TolyIcon.dart'; -import 'package:flutter_unit_mac/components/permanent/circle_image.dart'; -import 'package:flutter_unit_mac/components/permanent/feedback_widget.dart'; +import 'package:flutter_unit/app/res/toly_icon.dart'; +import 'package:flutter_unit/views/components/permanent/circle_image.dart'; +import 'package:flutter_unit/views/components/permanent/feedback_widget.dart'; import 'package:url_launcher/url_launcher.dart'; class AboutMePage extends StatelessWidget { diff --git a/lib/views/pages/category/category_page.dart b/lib/views/pages/category/category_page.dart index aabbc4d..c0c7cc3 100644 --- a/lib/views/pages/category/category_page.dart +++ b/lib/views/pages/category/category_page.dart @@ -1,16 +1,16 @@ import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; -import 'package:flutter_unit_mac/app/router.dart'; -import 'package:flutter_unit_mac/blocs/category/category_bloc.dart'; -import 'package:flutter_unit_mac/blocs/category/category_event.dart'; -import 'package:flutter_unit_mac/blocs/category/category_state.dart'; -import 'package:flutter_unit_mac/blocs/category_widget/category_widget_bloc.dart'; -import 'package:flutter_unit_mac/blocs/category_widget/category_widget_event.dart'; -import 'package:flutter_unit_mac/components/permanent/circle.dart'; +import 'package:flutter_unit/app/router.dart'; +import 'package:flutter_unit/blocs/category/category_bloc.dart'; +import 'package:flutter_unit/blocs/category/category_event.dart'; +import 'package:flutter_unit/blocs/category/category_state.dart'; +import 'package:flutter_unit/blocs/category_widget/category_widget_bloc.dart'; +import 'package:flutter_unit/blocs/category_widget/category_widget_event.dart'; -import 'package:flutter_unit_mac/model/category_model.dart'; -import 'package:flutter_unit_mac/views/dialogs/delete_category_dialog.dart'; -import 'package:flutter_unit_mac/views/items/category_list_item.dart'; +import 'package:flutter_unit/model/category_model.dart'; +import 'package:flutter_unit/views/components/permanent/circle.dart'; +import 'package:flutter_unit/views/components/project/dialogs/delete_category_dialog.dart'; +import 'package:flutter_unit/views/components/project/items/category_list_item.dart'; import 'edit_category_panel.dart'; @@ -115,6 +115,6 @@ class CategoryPage extends StatelessWidget { _toDetailPage(BuildContext context, CategoryModel model) { BlocProvider.of(context) .add(EventLoadCategoryWidget(model.id)); - Navigator.pushNamed(context, Router.category_show, arguments: model); + Navigator.pushNamed(context, UnitRouter.category_show, arguments: model); } } diff --git a/lib/views/pages/category/category_show.dart b/lib/views/pages/category/category_show.dart index 51d3e12..f82ee0d 100644 --- a/lib/views/pages/category/category_show.dart +++ b/lib/views/pages/category/category_show.dart @@ -2,18 +2,17 @@ import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:flutter_star/flutter_star.dart'; -import 'package:flutter_unit_mac/app/router.dart'; -import 'package:flutter_unit_mac/blocs/category_widget/category_widget_bloc.dart'; -import 'package:flutter_unit_mac/blocs/category_widget/category_widget_event.dart'; -import 'package:flutter_unit_mac/blocs/category_widget/category_widget_state.dart'; -import 'package:flutter_unit_mac/blocs/detail/detail_bloc.dart'; -import 'package:flutter_unit_mac/blocs/detail/detail_event.dart'; -import 'package:flutter_unit_mac/components/permanent/circle_image.dart'; -import 'package:flutter_unit_mac/components/permanent/circle_text.dart'; -import 'package:flutter_unit_mac/components/permanent/feedback_widget.dart'; -import 'package:flutter_unit_mac/model/category_model.dart'; -import 'package:flutter_unit_mac/model/widget_model.dart'; -import 'package:flutter_unit_mac/views/items/techno_widget_list_item.dart'; +import 'package:flutter_unit/app/router.dart'; +import 'package:flutter_unit/blocs/category_widget/category_widget_bloc.dart'; +import 'package:flutter_unit/blocs/category_widget/category_widget_event.dart'; +import 'package:flutter_unit/blocs/category_widget/category_widget_state.dart'; +import 'package:flutter_unit/blocs/detail/detail_bloc.dart'; +import 'package:flutter_unit/blocs/detail/detail_event.dart'; +import 'package:flutter_unit/model/category_model.dart'; +import 'package:flutter_unit/model/widget_model.dart'; +import 'package:flutter_unit/views/components/permanent/circle_image.dart'; +import 'package:flutter_unit/views/components/permanent/circle_text.dart'; +import 'package:flutter_unit/views/components/permanent/feedback_widget.dart'; /// create by 张风捷特烈 on 2020-04-22 /// contact me by email 1981462002@qq.com @@ -75,7 +74,7 @@ class CategoryShow extends StatelessWidget { _toDetailPage(BuildContext context, WidgetModel model) async { BlocProvider.of(context).add(FetchWidgetDetail(model)); - Navigator.pushNamed(context, Router.widget_detail, arguments: model); + Navigator.pushNamed(context, UnitRouter.widget_detail, arguments: model); } } diff --git a/lib/views/pages/category/collect_page.dart b/lib/views/pages/category/collect_page.dart index 55a2746..8711023 100644 --- a/lib/views/pages/category/collect_page.dart +++ b/lib/views/pages/category/collect_page.dart @@ -1,12 +1,12 @@ import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; -import 'package:flutter_unit_mac/app/router.dart'; -import 'package:flutter_unit_mac/blocs/bloc_exp.dart'; -import 'package:flutter_unit_mac/components/permanent/circle_image.dart'; -import 'package:flutter_unit_mac/model/widget_model.dart'; -import 'package:flutter_unit_mac/views/items/collect_widget_list_item.dart'; +import 'package:flutter_unit/app/router.dart'; +import 'package:flutter_unit/blocs/bloc_exp.dart'; +import 'package:flutter_unit/model/widget_model.dart'; +import 'package:flutter_unit/views/components/permanent/circle_image.dart'; +import 'package:flutter_unit/views/components/project/items/collect_widget_list_item.dart'; import 'category_page.dart'; class CollectPage extends StatelessWidget { @@ -136,6 +136,6 @@ class CollectPage extends StatelessWidget { _toDetailPage(BuildContext context, WidgetModel model) { BlocProvider.of(context).add(FetchWidgetDetail(model)); - Navigator.pushNamed(context, Router.widget_detail, arguments: model); + Navigator.pushNamed(context, UnitRouter.widget_detail, arguments: model); } } diff --git a/lib/views/pages/category/edit_category_panel.dart b/lib/views/pages/category/edit_category_panel.dart index b12cab9..458dff5 100644 --- a/lib/views/pages/category/edit_category_panel.dart +++ b/lib/views/pages/category/edit_category_panel.dart @@ -1,13 +1,13 @@ import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; -import 'package:flutter_unit_mac/app/style/unit_color.dart'; -import 'package:flutter_unit_mac/app/utils/color_utils.dart'; -import 'package:flutter_unit_mac/blocs/category/category_bloc.dart'; -import 'package:flutter_unit_mac/blocs/category/category_event.dart'; -import 'package:flutter_unit_mac/components/permanent/edit_panel.dart'; -import 'package:flutter_unit_mac/components/permanent/input_button.dart'; -import 'package:flutter_unit_mac/components/project/color_chooser.dart'; -import 'package:flutter_unit_mac/model/category_model.dart'; +import 'package:flutter_unit/app/style/unit_color.dart'; +import 'package:flutter_unit/app/utils/color_utils.dart'; +import 'package:flutter_unit/blocs/category/category_bloc.dart'; +import 'package:flutter_unit/blocs/category/category_event.dart'; +import 'package:flutter_unit/model/category_model.dart'; +import 'package:flutter_unit/views/components/permanent/edit_panel.dart'; +import 'package:flutter_unit/views/components/permanent/input_button.dart'; +import 'package:flutter_unit/views/components/project/color_chooser.dart'; /// create by 张风捷特烈 on 2020-04-23 /// contact me by email 1981462002@qq.com diff --git a/lib/views/pages/category/home_right_drawer.dart b/lib/views/pages/category/home_right_drawer.dart index f4f4612..c7e5189 100644 --- a/lib/views/pages/category/home_right_drawer.dart +++ b/lib/views/pages/category/home_right_drawer.dart @@ -1,14 +1,6 @@ import 'package:flutter/material.dart'; -import 'package:flutter_bloc/flutter_bloc.dart'; -import 'package:flutter_unit_mac/app/style/unit_color.dart'; -import 'package:flutter_unit_mac/app/utils/color_utils.dart'; -import 'package:flutter_unit_mac/blocs/category/category_bloc.dart'; -import 'package:flutter_unit_mac/blocs/category/category_event.dart'; -import 'package:flutter_unit_mac/components/permanent/circle.dart'; -import 'package:flutter_unit_mac/components/project/color_chooser.dart'; -import 'package:flutter_unit_mac/views/common/unit_drawer_header.dart'; -import 'package:flutter_unit_mac/components/permanent/input_button.dart'; -import 'package:flutter_unit_mac/components/permanent/edit_panel.dart'; +import 'package:flutter_unit/views/components/permanent/circle.dart'; +import 'package:flutter_unit/views/components/project/default/unit_drawer_header.dart'; import 'edit_category_panel.dart'; diff --git a/lib/views/pages/detail/category_end_drawer.dart b/lib/views/pages/detail/category_end_drawer.dart index 3d6e376..c990242 100644 --- a/lib/views/pages/detail/category_end_drawer.dart +++ b/lib/views/pages/detail/category_end_drawer.dart @@ -1,15 +1,16 @@ import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; -import 'package:flutter_unit_mac/blocs/category/category_bloc.dart'; -import 'package:flutter_unit_mac/blocs/category/category_state.dart'; -import 'package:flutter_unit_mac/blocs/category_widget/category_widget_bloc.dart'; -import 'package:flutter_unit_mac/blocs/category_widget/category_widget_event.dart'; -import 'package:flutter_unit_mac/components/permanent/circle.dart'; -import 'package:flutter_unit_mac/components/permanent/panel.dart'; -import 'package:flutter_unit_mac/model/category_model.dart'; -import 'package:flutter_unit_mac/model/widget_model.dart'; -import 'package:flutter_unit_mac/repositories/itf/category_repository.dart'; -import 'package:flutter_unit_mac/views/common/unit_drawer_header.dart'; +import 'package:flutter_unit/blocs/category/category_bloc.dart'; +import 'package:flutter_unit/blocs/category/category_state.dart'; +import 'package:flutter_unit/blocs/category_widget/category_widget_bloc.dart'; +import 'package:flutter_unit/blocs/category_widget/category_widget_event.dart'; +import 'package:flutter_unit/model/category_model.dart'; +import 'package:flutter_unit/model/widget_model.dart'; +import 'package:flutter_unit/repositories/itf/category_repository.dart'; +import 'package:flutter_unit/views/components/permanent/circle.dart'; +import 'package:flutter_unit/views/components/permanent/panel.dart'; +import 'package:flutter_unit/views/components/project/default/unit_drawer_header.dart'; + /// create by 张风捷特烈 on 2020-04-22 diff --git a/lib/views/pages/detail/widget_detail_page.dart b/lib/views/pages/detail/widget_detail_page.dart index b5b7a6e..f1f8e9f 100644 --- a/lib/views/pages/detail/widget_detail_page.dart +++ b/lib/views/pages/detail/widget_detail_page.dart @@ -1,24 +1,24 @@ import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:flutter_star/flutter_star.dart'; -import 'package:flutter_unit_mac/app/res/cons.dart'; -import 'package:flutter_unit_mac/app/router.dart'; -import 'package:flutter_unit_mac/app/style/TolyIcon.dart'; -import 'package:flutter_unit_mac/app/utils/Toast.dart'; -import 'package:flutter_unit_mac/blocs/collect/collect_bloc.dart'; -import 'package:flutter_unit_mac/blocs/collect/collect_event.dart'; -import 'package:flutter_unit_mac/blocs/collect/collect_state.dart'; -import 'package:flutter_unit_mac/blocs/detail/detail_bloc.dart'; -import 'package:flutter_unit_mac/blocs/detail/detail_event.dart'; -import 'package:flutter_unit_mac/blocs/detail/detail_state.dart'; -import 'package:flutter_unit_mac/blocs/global/global_bloc.dart'; -import 'package:flutter_unit_mac/components/permanent/feedback_widget.dart'; -import 'package:flutter_unit_mac/components/permanent/panel.dart'; -import 'package:flutter_unit_mac/components/project/widget_node_panel.dart'; -import 'package:flutter_unit_mac/model/node_model.dart'; -import 'package:flutter_unit_mac/model/widget_model.dart'; -import 'package:flutter_unit_mac/views/pages/detail/category_end_drawer.dart'; -import 'package:flutter_unit_mac/views/widgets/widgets_map.dart'; +import 'package:flutter_unit/app/res/cons.dart'; +import 'package:flutter_unit/app/router.dart'; +import 'package:flutter_unit/app/res/toly_icon.dart'; +import 'package:flutter_unit/app/utils/Toast.dart'; +import 'package:flutter_unit/blocs/collect/collect_bloc.dart'; +import 'package:flutter_unit/blocs/collect/collect_event.dart'; +import 'package:flutter_unit/blocs/collect/collect_state.dart'; +import 'package:flutter_unit/blocs/detail/detail_bloc.dart'; +import 'package:flutter_unit/blocs/detail/detail_event.dart'; +import 'package:flutter_unit/blocs/detail/detail_state.dart'; +import 'package:flutter_unit/blocs/global/global_bloc.dart'; +import 'package:flutter_unit/model/node_model.dart'; +import 'package:flutter_unit/model/widget_model.dart'; +import 'package:flutter_unit/views/components/permanent/feedback_widget.dart'; +import 'package:flutter_unit/views/components/permanent/panel.dart'; +import 'package:flutter_unit/views/components/project/widget_node_panel.dart'; +import 'package:flutter_unit/views/pages/detail/category_end_drawer.dart'; +import 'package:flutter_unit/views/widgets/widgets_map.dart'; class WidgetDetailPage extends StatefulWidget { final WidgetModel model; diff --git a/lib/views/pages/home/home_drawer.dart b/lib/views/pages/home/home_drawer.dart index 535ce4e..a02804f 100644 --- a/lib/views/pages/home/home_drawer.dart +++ b/lib/views/pages/home/home_drawer.dart @@ -1,8 +1,8 @@ import 'package:flutter/material.dart'; -import 'package:flutter_unit_mac/app/router.dart'; -import 'package:flutter_unit_mac/app/style/TolyIcon.dart'; -import 'package:flutter_unit_mac/components/flutter/no_div_expansion_tile.dart'; -import 'package:flutter_unit_mac/views/common/unit_drawer_header.dart'; +import 'package:flutter_unit/app/router.dart'; +import 'package:flutter_unit/app/res/toly_icon.dart'; +import 'package:flutter_unit/views/components/flutter/no_div_expansion_tile.dart'; +import 'package:flutter_unit/views/components/project/default/unit_drawer_header.dart'; /// create by 张风捷特烈 on 2020-03-26 /// contact me by email 1981462002@qq.com @@ -34,7 +34,7 @@ class HomeDrawer extends StatelessWidget { trailing: _nextIcon(context), title: Text('我的主题'), onTap: () { - Navigator.of(context).pushNamed(Router.setting); + Navigator.of(context).pushNamed(UnitRouter.setting); }, ), @@ -70,7 +70,7 @@ class HomeDrawer extends StatelessWidget { ), title: Text('关于应用'), trailing: _nextIcon(context), - onTap: () => Navigator.of(context).pushNamed(Router.about_app), + onTap: () => Navigator.of(context).pushNamed(UnitRouter.about_app), ), ListTile( leading: Icon( @@ -79,7 +79,7 @@ class HomeDrawer extends StatelessWidget { ), title: Text('联系本王'), trailing: _nextIcon(context), - onTap: () => Navigator.of(context).pushNamed(Router.about_me), + onTap: () => Navigator.of(context).pushNamed(UnitRouter.about_me), ), ], ), diff --git a/lib/views/pages/home/home_page.dart b/lib/views/pages/home/home_page.dart index 5daaa94..dfb70c9 100644 --- a/lib/views/pages/home/home_page.dart +++ b/lib/views/pages/home/home_page.dart @@ -3,15 +3,15 @@ import 'dart:io'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; -import 'package:flutter_unit_mac/app/convert.dart'; -import 'package:flutter_unit_mac/app/res/cons.dart'; -import 'package:flutter_unit_mac/app/router.dart'; -import 'package:flutter_unit_mac/blocs/bloc_exp.dart'; -import 'package:flutter_unit_mac/components/permanent/feedback_widget.dart'; -import 'package:flutter_unit_mac/model/widget_model.dart'; -import 'package:flutter_unit_mac/views/common/empty_page.dart'; -import 'package:flutter_unit_mac/views/items/home_item_support.dart'; -import 'package:flutter_unit_mac/views/pages/home/toly_app_bar.dart'; +import 'package:flutter_unit/app/convert.dart'; +import 'package:flutter_unit/app/res/cons.dart'; +import 'package:flutter_unit/app/router.dart'; +import 'package:flutter_unit/blocs/bloc_exp.dart'; +import 'package:flutter_unit/model/widget_model.dart'; +import 'package:flutter_unit/views/components/permanent/feedback_widget.dart'; +import 'package:flutter_unit/views/components/project/default/empty_page.dart'; +import 'package:flutter_unit/views/components/project/items/home_item_support.dart'; +import 'package:flutter_unit/views/pages/home/toly_app_bar.dart'; import 'background.dart'; @@ -111,6 +111,6 @@ class _HomePageState extends State { _toDetailPage(WidgetModel model) async { BlocProvider.of(context).add(FetchWidgetDetail(model)); - Navigator.pushNamed(context, Router.widget_detail, arguments: model); + Navigator.pushNamed(context, UnitRouter.widget_detail, arguments: model); } } diff --git a/lib/views/pages/home/toly_app_bar.dart b/lib/views/pages/home/toly_app_bar.dart index f8c66bc..d92264d 100644 --- a/lib/views/pages/home/toly_app_bar.dart +++ b/lib/views/pages/home/toly_app_bar.dart @@ -1,6 +1,6 @@ import 'package:flutter/material.dart'; -import 'package:flutter_unit_mac/app/res/cons.dart'; -import 'package:flutter_unit_mac/components/permanent/circle.dart'; +import 'package:flutter_unit/app/res/cons.dart'; +import 'package:flutter_unit/views/components/permanent/circle.dart'; class TolyAppBar extends StatefulWidget implements PreferredSizeWidget { final Function(int, Color) onItemClick; diff --git a/lib/views/pages/search/app_search_bar.dart b/lib/views/pages/search/app_search_bar.dart index 559d7cb..5582686 100644 --- a/lib/views/pages/search/app_search_bar.dart +++ b/lib/views/pages/search/app_search_bar.dart @@ -1,8 +1,8 @@ import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; -import 'package:flutter_unit_mac/blocs/search/search_bloc.dart'; -import 'package:flutter_unit_mac/blocs/search/search_event.dart'; -import 'package:flutter_unit_mac/storage/dao/widget_dao.dart'; +import 'package:flutter_unit/blocs/search/search_bloc.dart'; +import 'package:flutter_unit/blocs/search/search_event.dart'; +import 'package:flutter_unit/storage/dao/widget_dao.dart'; class AppSearchBar extends StatefulWidget { diff --git a/lib/views/pages/search/serach_page.dart b/lib/views/pages/search/serach_page.dart index 0319491..bf7450d 100644 --- a/lib/views/pages/search/serach_page.dart +++ b/lib/views/pages/search/serach_page.dart @@ -1,18 +1,17 @@ import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; -import 'package:flutter_unit_mac/app/router.dart'; -import 'package:flutter_unit_mac/app/style/TolyIcon.dart'; -import 'package:flutter_unit_mac/blocs/bloc_exp.dart'; -import 'package:flutter_unit_mac/components/permanent/circle.dart'; -import 'package:flutter_unit_mac/storage/dao/widget_dao.dart'; -import 'package:flutter_unit_mac/model/widget_model.dart'; -import 'package:flutter_unit_mac/views/items/home_item_support.dart'; -import 'package:flutter_unit_mac/views/items/techno_widget_list_item.dart'; -import 'package:flutter_unit_mac/views/pages/search/app_search_bar.dart'; -import 'package:flutter_unit_mac/views/pages/search/error_page.dart'; -import 'package:flutter_unit_mac/views/common/loading_page.dart'; -import 'package:flutter_unit_mac/views/pages/search/not_search_page.dart'; -import 'package:flutter_unit_mac/views/pages/search/start_filter.dart'; +import 'package:flutter_unit/app/router.dart'; +import 'package:flutter_unit/app/res/toly_icon.dart'; +import 'package:flutter_unit/blocs/bloc_exp.dart'; +import 'package:flutter_unit/storage/dao/widget_dao.dart'; +import 'package:flutter_unit/model/widget_model.dart'; +import 'package:flutter_unit/views/components/permanent/circle.dart'; +import 'package:flutter_unit/views/components/project/default/loading_page.dart'; +import 'package:flutter_unit/views/components/project/items/home_item_support.dart'; +import 'package:flutter_unit/views/pages/search/app_search_bar.dart'; +import 'package:flutter_unit/views/pages/search/error_page.dart'; +import 'package:flutter_unit/views/pages/search/not_search_page.dart'; +import 'package:flutter_unit/views/pages/search/start_filter.dart'; import 'empty_page.dart'; @@ -151,6 +150,6 @@ class _SearchPageState extends State { _toDetailPage(WidgetModel model) { BlocProvider.of(context).add(FetchWidgetDetail(model)); - Navigator.pushNamed(context, Router.widget_detail, arguments: model); + Navigator.pushNamed(context, UnitRouter.widget_detail, arguments: model); } } diff --git a/lib/views/pages/search/start_filter.dart b/lib/views/pages/search/start_filter.dart index 04182f5..a2537d7 100644 --- a/lib/views/pages/search/start_filter.dart +++ b/lib/views/pages/search/start_filter.dart @@ -1,8 +1,8 @@ import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; -import 'package:flutter_unit_mac/blocs/search/search_bloc.dart'; -import 'package:flutter_unit_mac/blocs/search/search_event.dart'; -import 'package:flutter_unit_mac/storage/dao/widget_dao.dart'; +import 'package:flutter_unit/blocs/search/search_bloc.dart'; +import 'package:flutter_unit/blocs/search/search_event.dart'; +import 'package:flutter_unit/storage/dao/widget_dao.dart'; /// create by 张风捷特烈 on 2020-04-07 /// contact me by email 1981462002@qq.com diff --git a/lib/views/pages/setting/code_style_setting.dart b/lib/views/pages/setting/code_style_setting.dart index ac02bb4..2baba8f 100644 --- a/lib/views/pages/setting/code_style_setting.dart +++ b/lib/views/pages/setting/code_style_setting.dart @@ -1,13 +1,14 @@ import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; -import 'package:flutter_unit_mac/app/res/cons.dart'; -import 'package:flutter_unit_mac/blocs/global/global_bloc.dart'; -import 'package:flutter_unit_mac/blocs/global/global_event.dart'; -import 'package:flutter_unit_mac/blocs/global/global_state.dart'; -import 'package:flutter_unit_mac/components/permanent/code/code_widget.dart'; -import 'package:flutter_unit_mac/components/permanent/code/highlighter_style.dart'; -import 'package:flutter_unit_mac/components/permanent/feedback_widget.dart'; -import 'package:flutter_unit_mac/components/permanent/circle.dart'; +import 'package:flutter_unit/app/res/cons.dart'; +import 'package:flutter_unit/blocs/global/global_bloc.dart'; +import 'package:flutter_unit/blocs/global/global_event.dart'; +import 'package:flutter_unit/blocs/global/global_state.dart'; +import 'package:flutter_unit/views/components/permanent/circle.dart'; +import 'package:flutter_unit/views/components/permanent/code/back/code_panel.dart'; +import 'package:flutter_unit/views/components/permanent/code/highlighter_style.dart'; +import 'package:flutter_unit/views/components/permanent/feedback_widget.dart'; + /// create by 张风捷特烈 on 2020-04-10 /// contact me by email 1981462002@qq.com diff --git a/lib/views/pages/setting/font_setting.dart b/lib/views/pages/setting/font_setting.dart index 3e804f6..7634c07 100644 --- a/lib/views/pages/setting/font_setting.dart +++ b/lib/views/pages/setting/font_setting.dart @@ -1,11 +1,12 @@ import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; -import 'package:flutter_unit_mac/app/res/cons.dart'; -import 'package:flutter_unit_mac/blocs/global/global_bloc.dart'; -import 'package:flutter_unit_mac/blocs/global/global_event.dart'; -import 'package:flutter_unit_mac/blocs/global/global_state.dart'; -import 'package:flutter_unit_mac/components/permanent/feedback_widget.dart'; -import 'package:flutter_unit_mac/components/permanent/circle.dart'; +import 'package:flutter_unit/app/res/cons.dart'; +import 'package:flutter_unit/blocs/global/global_bloc.dart'; +import 'package:flutter_unit/blocs/global/global_event.dart'; +import 'package:flutter_unit/blocs/global/global_state.dart'; +import 'package:flutter_unit/views/components/permanent/circle.dart'; +import 'package:flutter_unit/views/components/permanent/feedback_widget.dart'; + /// create by 张风捷特烈 on 2020-04-10 /// contact me by email 1981462002@qq.com diff --git a/lib/views/pages/setting/item_style_setting.dart b/lib/views/pages/setting/item_style_setting.dart index 3bbb1a7..ada26d2 100644 --- a/lib/views/pages/setting/item_style_setting.dart +++ b/lib/views/pages/setting/item_style_setting.dart @@ -2,12 +2,12 @@ import 'dart:math'; import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; -import 'package:flutter_unit_mac/blocs/global/global_bloc.dart'; -import 'package:flutter_unit_mac/blocs/global/global_event.dart'; -import 'package:flutter_unit_mac/blocs/global/global_state.dart'; -import 'package:flutter_unit_mac/components/permanent/feedback_widget.dart'; -import 'package:flutter_unit_mac/components/permanent/circle.dart'; -import 'package:flutter_unit_mac/views/items/home_item_support.dart'; +import 'package:flutter_unit/blocs/global/global_bloc.dart'; +import 'package:flutter_unit/blocs/global/global_event.dart'; +import 'package:flutter_unit/blocs/global/global_state.dart'; +import 'package:flutter_unit/views/components/permanent/circle.dart'; +import 'package:flutter_unit/views/components/permanent/feedback_widget.dart'; +import 'package:flutter_unit/views/components/project/items/home_item_support.dart'; /// create by 张风捷特烈 on 2020-04-10 diff --git a/lib/views/pages/setting/setting_page.dart b/lib/views/pages/setting/setting_page.dart index cacabfa..c4dda77 100644 --- a/lib/views/pages/setting/setting_page.dart +++ b/lib/views/pages/setting/setting_page.dart @@ -1,10 +1,10 @@ import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; -import 'package:flutter_unit_mac/app/router.dart'; -import 'package:flutter_unit_mac/app/style/TolyIcon.dart'; -import 'package:flutter_unit_mac/blocs/global/global_bloc.dart'; -import 'package:flutter_unit_mac/blocs/global/global_event.dart'; -import 'package:flutter_unit_mac/blocs/global/global_state.dart'; +import 'package:flutter_unit/app/router.dart'; +import 'package:flutter_unit/app/res/toly_icon.dart'; +import 'package:flutter_unit/blocs/global/global_bloc.dart'; +import 'package:flutter_unit/blocs/global/global_event.dart'; +import 'package:flutter_unit/blocs/global/global_state.dart'; class SettingPage extends StatelessWidget { @@ -23,7 +23,7 @@ class SettingPage extends StatelessWidget { ), title: Text('主题色设置'), trailing: _nextIcon(context), - onTap: () => Navigator.of(context).pushNamed(Router.theme_color_setting), + onTap: () => Navigator.of(context).pushNamed(UnitRouter.theme_color_setting), ), Divider(), ListTile( @@ -33,7 +33,7 @@ class SettingPage extends StatelessWidget { ), title: Text('字体设置'), trailing: _nextIcon(context), - onTap: () => Navigator.of(context).pushNamed(Router.font_setting), + onTap: () => Navigator.of(context).pushNamed(UnitRouter.font_setting), ), // Divider(), // ListTile( @@ -53,7 +53,7 @@ class SettingPage extends StatelessWidget { ), title: Text('代码高亮样式'), trailing: _nextIcon(context), - onTap: () => Navigator.of(context).pushNamed(Router.code_style_setting), + onTap: () => Navigator.of(context).pushNamed(UnitRouter.code_style_setting), ), Divider(), _buildShowBg(context), diff --git a/lib/views/pages/setting/theme_color_setting.dart b/lib/views/pages/setting/theme_color_setting.dart index 693a5df..eb8faab 100644 --- a/lib/views/pages/setting/theme_color_setting.dart +++ b/lib/views/pages/setting/theme_color_setting.dart @@ -1,11 +1,11 @@ import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; -import 'package:flutter_unit_mac/app/res/cons.dart'; -import 'package:flutter_unit_mac/blocs/global/global_bloc.dart'; -import 'package:flutter_unit_mac/blocs/global/global_event.dart'; -import 'package:flutter_unit_mac/blocs/global/global_state.dart'; -import 'package:flutter_unit_mac/components/permanent/feedback_widget.dart'; -import 'package:flutter_unit_mac/components/permanent/circle.dart'; +import 'package:flutter_unit/app/res/cons.dart'; +import 'package:flutter_unit/blocs/global/global_bloc.dart'; +import 'package:flutter_unit/blocs/global/global_event.dart'; +import 'package:flutter_unit/blocs/global/global_state.dart'; +import 'package:flutter_unit/views/components/permanent/circle.dart'; +import 'package:flutter_unit/views/components/permanent/feedback_widget.dart'; /// create by 张风捷特烈 on 2020-04-10 /// contact me by email 1981462002@qq.com diff --git a/lib/views/pages/unit_todo/attr_unit_page.dart b/lib/views/pages/unit_todo/attr_unit_page.dart index e2e620f..dfc9bed 100644 --- a/lib/views/pages/unit_todo/attr_unit_page.dart +++ b/lib/views/pages/unit_todo/attr_unit_page.dart @@ -1,18 +1,6 @@ import 'package:flutter/material.dart'; -import 'package:flutter_bloc/flutter_bloc.dart'; -import 'package:flutter_unit_mac/app/router.dart'; -import 'package:flutter_unit_mac/blocs/collect/collect_bloc.dart'; -import 'package:flutter_unit_mac/blocs/collect/collect_event.dart'; -import 'package:flutter_unit_mac/blocs/collect/collect_state.dart'; -import 'package:flutter_unit_mac/blocs/detail/detail_bloc.dart'; -import 'package:flutter_unit_mac/blocs/detail/detail_event.dart'; -import 'package:flutter_unit_mac/components/permanent/animated_text.dart'; -import 'package:flutter_unit_mac/components/permanent/circle_image.dart'; -import 'package:flutter_unit_mac/model/widget_model.dart'; -import 'package:flutter_unit_mac/views/items/collect_widget_list_item.dart'; -import 'package:flutter_unit_mac/views/items/techno_widget_list_item.dart'; - -import '../../common/empty_page.dart'; +import 'package:flutter_unit/views/components/permanent/animated_text.dart'; +import 'package:flutter_unit/views/components/permanent/circle_image.dart'; class AttrUnitPage extends StatelessWidget { final info = '【Flutter属性集录】是Unit项目计划的第二阶段的功能之一。' diff --git a/lib/views/pages/unit_todo/bug_unit_page.dart b/lib/views/pages/unit_todo/bug_unit_page.dart index ef4284b..7b5cd68 100644 --- a/lib/views/pages/unit_todo/bug_unit_page.dart +++ b/lib/views/pages/unit_todo/bug_unit_page.dart @@ -1,20 +1,9 @@ import 'package:flutter/material.dart'; -import 'package:flutter_bloc/flutter_bloc.dart'; -import 'package:flutter_unit_mac/app/router.dart'; -import 'package:flutter_unit_mac/blocs/collect/collect_bloc.dart'; -import 'package:flutter_unit_mac/blocs/collect/collect_event.dart'; -import 'package:flutter_unit_mac/blocs/collect/collect_state.dart'; -import 'package:flutter_unit_mac/blocs/detail/detail_bloc.dart'; -import 'package:flutter_unit_mac/blocs/detail/detail_event.dart'; -import 'package:flutter_unit_mac/components/permanent/animated_text.dart'; -import 'package:flutter_unit_mac/components/permanent/circle_image.dart'; -import 'package:flutter_unit_mac/model/widget_model.dart'; -import 'package:flutter_unit_mac/views/items/collect_widget_list_item.dart'; -import 'package:flutter_unit_mac/views/items/techno_widget_list_item.dart'; +import 'package:flutter_unit/views/components/permanent/animated_text.dart'; +import 'package:flutter_unit/views/components/permanent/circle_image.dart'; -import '../../common/empty_page.dart'; class BugUnitPage extends StatelessWidget { final info = '【Flutter异常集录】是Unit项目计划的第二阶段的功能之一。' diff --git a/lib/views/pages/unit_todo/layout_unit_page.dart b/lib/views/pages/unit_todo/layout_unit_page.dart index 1640975..5a9ced1 100644 --- a/lib/views/pages/unit_todo/layout_unit_page.dart +++ b/lib/views/pages/unit_todo/layout_unit_page.dart @@ -1,20 +1,9 @@ import 'package:flutter/material.dart'; -import 'package:flutter_bloc/flutter_bloc.dart'; -import 'package:flutter_unit_mac/app/router.dart'; -import 'package:flutter_unit_mac/blocs/collect/collect_bloc.dart'; -import 'package:flutter_unit_mac/blocs/collect/collect_event.dart'; -import 'package:flutter_unit_mac/blocs/collect/collect_state.dart'; -import 'package:flutter_unit_mac/blocs/detail/detail_bloc.dart'; -import 'package:flutter_unit_mac/blocs/detail/detail_event.dart'; -import 'package:flutter_unit_mac/components/permanent/animated_text.dart'; -import 'package:flutter_unit_mac/components/permanent/circle_image.dart'; -import 'package:flutter_unit_mac/model/widget_model.dart'; -import 'package:flutter_unit_mac/views/items/collect_widget_list_item.dart'; -import 'package:flutter_unit_mac/views/items/techno_widget_list_item.dart'; +import 'package:flutter_unit/views/components/permanent/animated_text.dart'; +import 'package:flutter_unit/views/components/permanent/circle_image.dart'; -import '../../common/empty_page.dart'; class LayoutUnitPage extends StatelessWidget { final info = '【Flutter布局集录】是Unit项目计划的第二阶段的功能之一。' diff --git a/lib/views/pages/unit_todo/paint_unit_page.dart b/lib/views/pages/unit_todo/paint_unit_page.dart index 45c6fed..68829a0 100644 --- a/lib/views/pages/unit_todo/paint_unit_page.dart +++ b/lib/views/pages/unit_todo/paint_unit_page.dart @@ -1,20 +1,9 @@ import 'package:flutter/material.dart'; -import 'package:flutter_bloc/flutter_bloc.dart'; -import 'package:flutter_unit_mac/app/router.dart'; -import 'package:flutter_unit_mac/blocs/collect/collect_bloc.dart'; -import 'package:flutter_unit_mac/blocs/collect/collect_event.dart'; -import 'package:flutter_unit_mac/blocs/collect/collect_state.dart'; -import 'package:flutter_unit_mac/blocs/detail/detail_bloc.dart'; -import 'package:flutter_unit_mac/blocs/detail/detail_event.dart'; -import 'package:flutter_unit_mac/components/permanent/animated_text.dart'; -import 'package:flutter_unit_mac/components/permanent/circle_image.dart'; -import 'package:flutter_unit_mac/model/widget_model.dart'; -import 'package:flutter_unit_mac/views/items/collect_widget_list_item.dart'; -import 'package:flutter_unit_mac/views/items/techno_widget_list_item.dart'; +import 'package:flutter_unit/views/components/permanent/animated_text.dart'; +import 'package:flutter_unit/views/components/permanent/circle_image.dart'; -import '../../common/empty_page.dart'; class PaintUnitPage extends StatelessWidget { final info = '【Flutter绘制集录】是Unit项目计划的第二阶段的功能之一。' diff --git a/lib/views/widgets/MultiChildRenderObjectWidget/CustomMultiChildLayout/node1_base.dart b/lib/views/widgets/MultiChildRenderObjectWidget/CustomMultiChildLayout/node1_base.dart index 10961cb..95d83f3 100644 --- a/lib/views/widgets/MultiChildRenderObjectWidget/CustomMultiChildLayout/node1_base.dart +++ b/lib/views/widgets/MultiChildRenderObjectWidget/CustomMultiChildLayout/node1_base.dart @@ -1,5 +1,3 @@ -import 'dart:io'; - import 'package:flutter/material.dart'; /// create by 张风捷特烈 on 2020/6/6 diff --git a/lib/views/widgets/MultiChildRenderObjectWidget/Flow/node1_base.dart b/lib/views/widgets/MultiChildRenderObjectWidget/Flow/node1_base.dart index d134b50..3b41103 100644 --- a/lib/views/widgets/MultiChildRenderObjectWidget/Flow/node1_base.dart +++ b/lib/views/widgets/MultiChildRenderObjectWidget/Flow/node1_base.dart @@ -16,8 +16,8 @@ class CircleFlow extends StatelessWidget { final data = List.generate( 16, (index) => index.isEven - ? "assets/images/icon_head.png" - : "assets/images/wy_300x200.jpg"); + ? "assets/images/icon_head.webp" + : "assets/images/wy_300x200.webp"); @override Widget build(BuildContext context) { diff --git a/lib/views/widgets/MultiChildRenderObjectWidget/Flow/node2_anim.dart b/lib/views/widgets/MultiChildRenderObjectWidget/Flow/node2_anim.dart index 9a37c0c..46bd526 100644 --- a/lib/views/widgets/MultiChildRenderObjectWidget/Flow/node2_anim.dart +++ b/lib/views/widgets/MultiChildRenderObjectWidget/Flow/node2_anim.dart @@ -16,8 +16,8 @@ class BurstFlow extends StatefulWidget { static final data = List.generate( 16, (index) => index.isEven - ? "assets/images/icon_head.png" - : "assets/images/wy_300x200.jpg"); + ? "assets/images/icon_head.webp" + : "assets/images/wy_300x200.webp"); static final show = Container( width: 300, height: 300, @@ -27,7 +27,7 @@ class BurstFlow extends StatefulWidget { .map((e) => CircleAvatar(backgroundImage: AssetImage(e))) .toList(), menu: CircleAvatar( - backgroundImage: AssetImage('assets/images/icon_head.png'), + backgroundImage: AssetImage('assets/images/icon_head.webp'), ))); final List children; diff --git a/lib/views/widgets/MultiChildRenderObjectWidget/ListBody/node1_base.dart b/lib/views/widgets/MultiChildRenderObjectWidget/ListBody/node1_base.dart index dde5f66..65086b2 100644 --- a/lib/views/widgets/MultiChildRenderObjectWidget/ListBody/node1_base.dart +++ b/lib/views/widgets/MultiChildRenderObjectWidget/ListBody/node1_base.dart @@ -1,4 +1,3 @@ -import 'package:flutter/gestures.dart'; import 'package:flutter/material.dart'; import 'package:flutter/rendering.dart'; diff --git a/lib/views/widgets/MultiChildRenderObjectWidget/RichText/node2_widget.dart b/lib/views/widgets/MultiChildRenderObjectWidget/RichText/node2_widget.dart index 3595b9f..9f1b110 100644 --- a/lib/views/widgets/MultiChildRenderObjectWidget/RichText/node2_widget.dart +++ b/lib/views/widgets/MultiChildRenderObjectWidget/RichText/node2_widget.dart @@ -12,51 +12,45 @@ import 'package:flutter/material.dart'; class RichTextWithWidget extends StatelessWidget { @override Widget build(BuildContext context) { - return Container( - width: 300, - height: 60, - alignment: Alignment.center, - child: Text('暂不支持Web') -// RichText( -// text: TextSpan( -// text: 'hello ', -// style: TextStyle(color: Colors.black, fontSize: 18), -// children: [ -// WidgetSpan( -// child: Image.asset( -// 'assets/images/icon_head.png', -// width: 30, -// ), -// alignment: PlaceholderAlignment.baseline, -// baseline: TextBaseline.ideographic), -// TextSpan( -// text: ' , welcome to ', -// style: TextStyle(color: Colors.blue, fontSize: 18), -// ), -// WidgetSpan( -// child: FlutterLogo(), -// alignment: PlaceholderAlignment.baseline, -// baseline: TextBaseline.ideographic), -// TextSpan( -// text: ' .\n', -// ), -// TextSpan( -// text: 'focus me on ', -// style: TextStyle(color: Colors.orange, fontSize: 16), -// ), -// TextSpan( -// text: 'https://github.com/toly1994328', -// style: TextStyle( -// color: Colors.blue, -// fontSize: 18, -// decoration: TextDecoration.underline), -// ), -// TextSpan( -// text: ' .\n', -// ), -// ], -// ), -// ), + return RichText( + text: TextSpan( + text: 'hello ', + style: TextStyle(color: Colors.black, fontSize: 18), + children: [ + WidgetSpan( + child: Image.asset( + 'assets/images/icon_head.webp', + width: 30, + ), + alignment: PlaceholderAlignment.baseline, + baseline: TextBaseline.ideographic), + TextSpan( + text: ' , welcome to ', + style: TextStyle(color: Colors.blue, fontSize: 18), + ), + WidgetSpan( + child: FlutterLogo(), + alignment: PlaceholderAlignment.baseline, + baseline: TextBaseline.ideographic), + TextSpan( + text: ' .\n', + ), + TextSpan( + text: 'focus me on ', + style: TextStyle(color: Colors.orange, fontSize: 16), + ), + TextSpan( + text: 'https://github.com/toly1994328', + style: TextStyle( + color: Colors.blue, + fontSize: 18, + decoration: TextDecoration.underline), + ), + TextSpan( + text: ' .\n', + ), + ], + ), ); } } diff --git a/lib/views/widgets/MultiChildRenderObjectWidget/Stack/node1_base.dart b/lib/views/widgets/MultiChildRenderObjectWidget/Stack/node1_base.dart index 6fca46e..ce16eaf 100644 --- a/lib/views/widgets/MultiChildRenderObjectWidget/Stack/node1_base.dart +++ b/lib/views/widgets/MultiChildRenderObjectWidget/Stack/node1_base.dart @@ -48,7 +48,7 @@ class CustomStack extends StatelessWidget { textDirection: TextDirection.rtl, fit: StackFit.loose, alignment: Alignment.topRight, - overflow: Overflow.clip, + // overflow: Overflow.clip, // 1.22.0 被去除 children: [yellowBox, redBox, greenBox, cyanBox], ), ); diff --git a/lib/views/widgets/Other/RawImage/node1_base.dart b/lib/views/widgets/Other/RawImage/node1_base.dart index f8a5a0a..dd31189 100644 --- a/lib/views/widgets/Other/RawImage/node1_base.dart +++ b/lib/views/widgets/Other/RawImage/node1_base.dart @@ -29,7 +29,7 @@ class _RawImageDemoState extends State { @override void initState() { super.initState(); - _loadImageFromAssets('assets/images/icon_head.png'); + _loadImageFromAssets('assets/images/icon_head.webp'); } @override diff --git a/lib/views/widgets/ProxyWidget/LayoutId/node1_base.dart b/lib/views/widgets/ProxyWidget/LayoutId/node1_base.dart index b4215aa..1bd5ee7 100644 --- a/lib/views/widgets/ProxyWidget/LayoutId/node1_base.dart +++ b/lib/views/widgets/ProxyWidget/LayoutId/node1_base.dart @@ -1,5 +1,3 @@ -import 'dart:io'; - import 'package:flutter/material.dart'; /// create by 张风捷特烈 on 2020/6/6 diff --git a/lib/views/widgets/ProxyWidget/ListTileTheme/node1_base.dart b/lib/views/widgets/ProxyWidget/ListTileTheme/node1_base.dart index f3d65c8..a5a032b 100644 --- a/lib/views/widgets/ProxyWidget/ListTileTheme/node1_base.dart +++ b/lib/views/widgets/ProxyWidget/ListTileTheme/node1_base.dart @@ -39,7 +39,7 @@ class _ListTileSimpleState extends State<_ListTileSimple> { margin: EdgeInsets.all(10), color: Colors.grey.withAlpha(22), child: ListTile( - leading: Image.asset("assets/images/icon_head.png"), + leading: Image.asset("assets/images/icon_head.webp"), selected: _selected, title: Text("以梦为马"), subtitle: Text("海子"), diff --git a/lib/views/widgets/ProxyWidget/SliderTheme/node1_base.dart b/lib/views/widgets/ProxyWidget/SliderTheme/node1_base.dart index 217daa9..b9108c9 100644 --- a/lib/views/widgets/ProxyWidget/SliderTheme/node1_base.dart +++ b/lib/views/widgets/ProxyWidget/SliderTheme/node1_base.dart @@ -1,5 +1,3 @@ -import 'dart:math'; - import 'package:flutter/material.dart'; /// create by 张风捷特烈 on 2020-04-12 diff --git a/lib/views/widgets/SingleChildRenderObjectWidget/BackdropFilter/node1_base.dart b/lib/views/widgets/SingleChildRenderObjectWidget/BackdropFilter/node1_base.dart index f2fc80e..98b7cce 100644 --- a/lib/views/widgets/SingleChildRenderObjectWidget/BackdropFilter/node1_base.dart +++ b/lib/views/widgets/SingleChildRenderObjectWidget/BackdropFilter/node1_base.dart @@ -58,7 +58,7 @@ class _CustomBackdropFilterState extends State { height: 150, width: 150, child: Image.asset( - 'assets/images/sabar.jpg', + 'assets/images/sabar.webp', fit: BoxFit.cover, ), ), @@ -66,7 +66,7 @@ class _CustomBackdropFilterState extends State { height: 150, width: 150, child: Image.asset( - 'assets/images/wy_200x300.jpg', + 'assets/images/wy_200x300.webp', fit: BoxFit.cover, ), ), diff --git a/lib/views/widgets/SingleChildRenderObjectWidget/ClipOval/node1_base.dart b/lib/views/widgets/SingleChildRenderObjectWidget/ClipOval/node1_base.dart index 6ad96c2..64e5a95 100644 --- a/lib/views/widgets/SingleChildRenderObjectWidget/ClipOval/node1_base.dart +++ b/lib/views/widgets/SingleChildRenderObjectWidget/ClipOval/node1_base.dart @@ -22,14 +22,14 @@ class CustomClipOval extends StatelessWidget { ClipOval( child: Image.asset( - "assets/images/wy_300x200.jpg", + "assets/images/wy_300x200.webp", width: 150, height: 100, ), ), ClipOval( child: Image.asset( - "assets/images/wy_300x200.jpg", + "assets/images/wy_300x200.webp", width: 100, height: 100, fit: BoxFit.cover, diff --git a/lib/views/widgets/SingleChildRenderObjectWidget/ClipPath/node1_base.dart b/lib/views/widgets/SingleChildRenderObjectWidget/ClipPath/node1_base.dart index efd25b3..1fdb022 100644 --- a/lib/views/widgets/SingleChildRenderObjectWidget/ClipPath/node1_base.dart +++ b/lib/views/widgets/SingleChildRenderObjectWidget/ClipPath/node1_base.dart @@ -20,7 +20,7 @@ class CustomClipPath extends StatelessWidget { return ClipPath( clipper: ShapeBorderClipper(shape: _StarShapeBorder()), child: Image.asset( - "assets/images/wy_300x200.jpg", + "assets/images/wy_300x200.webp", width: 150, height: 100, fit: BoxFit.cover, diff --git a/lib/views/widgets/SingleChildRenderObjectWidget/ClipRRect/node1_base.dart b/lib/views/widgets/SingleChildRenderObjectWidget/ClipRRect/node1_base.dart index b1d1fc0..d84b81b 100644 --- a/lib/views/widgets/SingleChildRenderObjectWidget/ClipRRect/node1_base.dart +++ b/lib/views/widgets/SingleChildRenderObjectWidget/ClipRRect/node1_base.dart @@ -19,7 +19,7 @@ class CustomClipRRect extends StatelessWidget { return ClipRRect( borderRadius: BorderRadius.all(Radius.elliptical(35, 30)), child: Image.asset( - "assets/images/wy_300x200.jpg", + "assets/images/wy_300x200.webp", width: 150, height: 100, ), diff --git a/lib/views/widgets/SingleChildRenderObjectWidget/ClipRect/node1_base.dart b/lib/views/widgets/SingleChildRenderObjectWidget/ClipRect/node1_base.dart index d1e58b6..20ca84e 100644 --- a/lib/views/widgets/SingleChildRenderObjectWidget/ClipRect/node1_base.dart +++ b/lib/views/widgets/SingleChildRenderObjectWidget/ClipRect/node1_base.dart @@ -20,7 +20,7 @@ class CustomClipRect extends StatelessWidget { height: 100, width: 100, child: Image.asset( - "assets/images/wy_300x200.jpg", + "assets/images/wy_300x200.webp", fit: BoxFit.cover,), ), ); diff --git a/lib/views/widgets/SingleChildRenderObjectWidget/ColorFiltered/node1_base.dart b/lib/views/widgets/SingleChildRenderObjectWidget/ColorFiltered/node1_base.dart index 928447f..496ba3e 100644 --- a/lib/views/widgets/SingleChildRenderObjectWidget/ColorFiltered/node1_base.dart +++ b/lib/views/widgets/SingleChildRenderObjectWidget/ColorFiltered/node1_base.dart @@ -44,14 +44,13 @@ class _CustomColorFilteredState extends State { ]), ], ); - ; } Widget _buildChild(m) => Container( width: 58, height: 58, child: ColorFiltered( - child: Image(image: AssetImage("assets/images/icon_head.png")), + child: Image(image: AssetImage("assets/images/icon_head.webp")), colorFilter: ColorFilter.mode(_color, m)), ); diff --git a/lib/views/widgets/SingleChildRenderObjectWidget/CustomPaint/node2_bezier.dart b/lib/views/widgets/SingleChildRenderObjectWidget/CustomPaint/node2_bezier.dart index c903f32..fdc124b 100644 --- a/lib/views/widgets/SingleChildRenderObjectWidget/CustomPaint/node2_bezier.dart +++ b/lib/views/widgets/SingleChildRenderObjectWidget/CustomPaint/node2_bezier.dart @@ -29,7 +29,7 @@ class _PlayBezier3PageState extends State { } void _initPoints() { - _pos = List(); + _pos = []; _pos.add(Offset(0, 0)); _pos.add(Offset(60, -60)); _pos.add(Offset(-90, -90)); diff --git a/lib/views/widgets/SingleChildRenderObjectWidget/DecoratedBox/node2_image.dart b/lib/views/widgets/SingleChildRenderObjectWidget/DecoratedBox/node2_image.dart index f30aece..bdd66b1 100644 --- a/lib/views/widgets/SingleChildRenderObjectWidget/DecoratedBox/node2_image.dart +++ b/lib/views/widgets/SingleChildRenderObjectWidget/DecoratedBox/node2_image.dart @@ -20,7 +20,7 @@ class ShapeImageDemo extends StatelessWidget { image: DecorationImage( fit: BoxFit.cover, image: AssetImage( - 'assets/images/wy_200x300.jpg', + 'assets/images/wy_200x300.webp', ))), child: SizedBox( height: 80, diff --git a/lib/views/widgets/SingleChildRenderObjectWidget/DecoratedBox/node3_border.dart b/lib/views/widgets/SingleChildRenderObjectWidget/DecoratedBox/node3_border.dart index 39f7c76..8b02b5e 100644 --- a/lib/views/widgets/SingleChildRenderObjectWidget/DecoratedBox/node3_border.dart +++ b/lib/views/widgets/SingleChildRenderObjectWidget/DecoratedBox/node3_border.dart @@ -23,7 +23,7 @@ class BorderDemo extends StatelessWidget { height: 80, width: 100, child: Image.asset( - 'assets/images/wy_200x300.jpg', + 'assets/images/wy_200x300.webp', fit: BoxFit.cover, ), ), diff --git a/lib/views/widgets/SingleChildRenderObjectWidget/DecoratedBox/node4_shape.dart b/lib/views/widgets/SingleChildRenderObjectWidget/DecoratedBox/node4_shape.dart index 54d8ecb..1a213d3 100644 --- a/lib/views/widgets/SingleChildRenderObjectWidget/DecoratedBox/node4_shape.dart +++ b/lib/views/widgets/SingleChildRenderObjectWidget/DecoratedBox/node4_shape.dart @@ -24,7 +24,7 @@ class ShapeDecorationDemo extends StatelessWidget { image: DecorationImage( fit: BoxFit.cover, image: AssetImage( - 'assets/images/wy_200x300.jpg', + 'assets/images/wy_200x300.webp', )), shape: CircleBorder( side: BorderSide(width: 1.0, color: Colors.orangeAccent), diff --git a/lib/views/widgets/SingleChildRenderObjectWidget/DecoratedBox/node6_flutterLogo.dart b/lib/views/widgets/SingleChildRenderObjectWidget/DecoratedBox/node6_flutterLogo.dart index 573856c..f0799a4 100644 --- a/lib/views/widgets/SingleChildRenderObjectWidget/DecoratedBox/node6_flutterLogo.dart +++ b/lib/views/widgets/SingleChildRenderObjectWidget/DecoratedBox/node6_flutterLogo.dart @@ -2,7 +2,7 @@ import 'package:flutter/material.dart'; /// create by 张风捷特烈 on 2020/4/30 /// contact me by email 1981462002@qq.com -/// 说明: +/// 说明: // { // "widgetId": 70, // "name": 'FlutterLogoDecoration装饰', @@ -15,8 +15,9 @@ class FlutterLogoDecorationDemo extends StatelessWidget { Widget build(BuildContext context) { return DecoratedBox( decoration: FlutterLogoDecoration( - darkColor: Colors.orange, - lightColor: Colors.deepPurpleAccent, +// darkColor: Colors.orange, +// lightColor: Colors.deepPurpleAccent, + margin: EdgeInsets.all(8), style: FlutterLogoStyle.stacked), child: SizedBox( width: 100, diff --git a/lib/views/widgets/SingleChildRenderObjectWidget/Opacity/node1_base.dart b/lib/views/widgets/SingleChildRenderObjectWidget/Opacity/node1_base.dart index 301240f..aacb7ee 100644 --- a/lib/views/widgets/SingleChildRenderObjectWidget/Opacity/node1_base.dart +++ b/lib/views/widgets/SingleChildRenderObjectWidget/Opacity/node1_base.dart @@ -29,7 +29,7 @@ class _CustomOpacityState extends State { Widget _buildOpacity() => Opacity( opacity: _opacity, child: Image.asset(// 图片 - 'assets/images/icon_head.png', + 'assets/images/icon_head.webp', width: 100, ), ); diff --git a/lib/views/widgets/SingleChildRenderObjectWidget/PhysicalShape/node1_base.dart b/lib/views/widgets/SingleChildRenderObjectWidget/PhysicalShape/node1_base.dart index 7a22984..601cd7f 100644 --- a/lib/views/widgets/SingleChildRenderObjectWidget/PhysicalShape/node1_base.dart +++ b/lib/views/widgets/SingleChildRenderObjectWidget/PhysicalShape/node1_base.dart @@ -6,7 +6,7 @@ import 'package:flutter/material.dart'; /// 说明: 279 PhysicalShape 物理形状 可以让子组件按照路径进行剪裁,并且可以指定背景色、影深、阴影颜色、剪切行为。 // { // "widgetId": 279, -// "name": "返回按钮基本使用", +// "name": "PhysicalShape基本使用", // "priority": 1, // "subtitle": "【clipper】 : 裁剪器 【CustomClipper】\n" // "【clipBehavior】 : 裁剪行为 【Clip】\n" @@ -26,7 +26,7 @@ class PhysicalShapeDemo extends StatelessWidget { shadowColor: Colors.orange, elevation: 3, child: Image.asset( - 'assets/images/caver.jpeg', + 'assets/images/caver.webp', fit: BoxFit.cover, ), clipBehavior: Clip.hardEdge, diff --git a/lib/views/widgets/SingleChildRenderObjectWidget/RepaintBoundary/node1_base.dart b/lib/views/widgets/SingleChildRenderObjectWidget/RepaintBoundary/node1_base.dart index 2cf57af..abd4c46 100644 --- a/lib/views/widgets/SingleChildRenderObjectWidget/RepaintBoundary/node1_base.dart +++ b/lib/views/widgets/SingleChildRenderObjectWidget/RepaintBoundary/node1_base.dart @@ -39,7 +39,7 @@ class _TempPlayBezier3PageState extends State { } void _initPoints() { - _pos = List(); + _pos = []; _pos.add(Offset(0, 0)); _pos.add(Offset(60, -60)); _pos.add(Offset(-90, -90)); diff --git a/lib/views/widgets/SingleChildRenderObjectWidget/ShaderMask/node1_radial.dart b/lib/views/widgets/SingleChildRenderObjectWidget/ShaderMask/node1_radial.dart index 6980613..e37ec4d 100644 --- a/lib/views/widgets/SingleChildRenderObjectWidget/ShaderMask/node1_radial.dart +++ b/lib/views/widgets/SingleChildRenderObjectWidget/ShaderMask/node1_radial.dart @@ -24,7 +24,7 @@ class RadialShaderMask extends StatelessWidget { ShaderMask( shaderCallback: _buildShader, child: Image.asset( - 'assets/images/icon_head.png', + 'assets/images/icon_head.webp', height: 70, width: 70, ), diff --git a/lib/views/widgets/SingleChildRenderObjectWidget/ShaderMask/node2_linear.dart b/lib/views/widgets/SingleChildRenderObjectWidget/ShaderMask/node2_linear.dart index d5dfd66..2004b0e 100644 --- a/lib/views/widgets/SingleChildRenderObjectWidget/ShaderMask/node2_linear.dart +++ b/lib/views/widgets/SingleChildRenderObjectWidget/ShaderMask/node2_linear.dart @@ -21,7 +21,7 @@ class LinearShaderMask extends StatelessWidget { ShaderMask( shaderCallback: _buildShader, child: Image.asset( - 'assets/images/icon_head.png', + 'assets/images/icon_head.webp', height: 70, width: 70, ), diff --git a/lib/views/widgets/SingleChildRenderObjectWidget/Transform/node1_skew.dart b/lib/views/widgets/SingleChildRenderObjectWidget/Transform/node1_skew.dart index 6bfa97b..067c9c0 100644 --- a/lib/views/widgets/SingleChildRenderObjectWidget/Transform/node1_skew.dart +++ b/lib/views/widgets/SingleChildRenderObjectWidget/Transform/node1_skew.dart @@ -55,7 +55,7 @@ class _SkewTransformState extends State { width: 100, height: 100, child: Image.asset( - 'assets/images/wy_300x200.jpg', + 'assets/images/wy_300x200.webp', fit: BoxFit.cover, )), ); diff --git a/lib/views/widgets/SingleChildRenderObjectWidget/Transform/node2_translation.dart b/lib/views/widgets/SingleChildRenderObjectWidget/Transform/node2_translation.dart index 8584a0a..4d3980e 100644 --- a/lib/views/widgets/SingleChildRenderObjectWidget/Transform/node2_translation.dart +++ b/lib/views/widgets/SingleChildRenderObjectWidget/Transform/node2_translation.dart @@ -54,7 +54,7 @@ class _TranslationTransformState extends State { width: 100, height: 100, child: Image.asset( - 'assets/images/wy_300x200.jpg', + 'assets/images/wy_300x200.webp', fit: BoxFit.cover, )), ); diff --git a/lib/views/widgets/SingleChildRenderObjectWidget/Transform/node3_scale.dart b/lib/views/widgets/SingleChildRenderObjectWidget/Transform/node3_scale.dart index a3b317c..ef27825 100644 --- a/lib/views/widgets/SingleChildRenderObjectWidget/Transform/node3_scale.dart +++ b/lib/views/widgets/SingleChildRenderObjectWidget/Transform/node3_scale.dart @@ -53,7 +53,7 @@ class _ScaleTransformState extends State { width: 100, height: 100, child: Image.asset( - 'assets/images/wy_300x200.jpg', + 'assets/images/wy_300x200.webp', fit: BoxFit.cover, )), ); diff --git a/lib/views/widgets/SingleChildRenderObjectWidget/Transform/node4_rotate.dart b/lib/views/widgets/SingleChildRenderObjectWidget/Transform/node4_rotate.dart index c8f955a..2becac1 100644 --- a/lib/views/widgets/SingleChildRenderObjectWidget/Transform/node4_rotate.dart +++ b/lib/views/widgets/SingleChildRenderObjectWidget/Transform/node4_rotate.dart @@ -62,7 +62,7 @@ class _RotateTransformState extends State { width: 100, height: 100, child: Image.asset( - 'assets/images/wy_300x200.jpg', + 'assets/images/wy_300x200.webp', fit: BoxFit.cover, )), ); diff --git a/lib/views/widgets/SingleChildRenderObjectWidget/Transform/node5_perspective.dart b/lib/views/widgets/SingleChildRenderObjectWidget/Transform/node5_perspective.dart index fb21a00..97b37a4 100644 --- a/lib/views/widgets/SingleChildRenderObjectWidget/Transform/node5_perspective.dart +++ b/lib/views/widgets/SingleChildRenderObjectWidget/Transform/node5_perspective.dart @@ -41,7 +41,7 @@ class _R3C2State extends State { width: 100, height: 100, child: Image.asset( - 'assets/images/wy_300x200.jpg', + 'assets/images/wy_300x200.webp', fit: BoxFit.cover, )), ), diff --git a/lib/views/widgets/SingleChildRenderObjectWidget/Transform/zz_node_op.dart b/lib/views/widgets/SingleChildRenderObjectWidget/Transform/zz_node_op.dart index b473275..9e69fce 100644 --- a/lib/views/widgets/SingleChildRenderObjectWidget/Transform/zz_node_op.dart +++ b/lib/views/widgets/SingleChildRenderObjectWidget/Transform/zz_node_op.dart @@ -41,7 +41,7 @@ class _CustomTransformState extends State { width: 100, height: 100, child: Image.asset( - 'assets/images/wy_300x200.jpg', + 'assets/images/wy_300x200.webp', fit: BoxFit.cover, )), ); diff --git a/lib/views/widgets/Sliver/CustomScrollView/node1_base.dart b/lib/views/widgets/Sliver/CustomScrollView/node1_base.dart index f8c7db1..2ff09ea 100644 --- a/lib/views/widgets/Sliver/CustomScrollView/node1_base.dart +++ b/lib/views/widgets/Sliver/CustomScrollView/node1_base.dart @@ -14,7 +14,7 @@ import 'package:flutter/material.dart'; // "【controller】 : 控制器 【ScrollController】", // } class CustomScrollViewDemo extends StatelessWidget { - final data = [ + final List data = [ Colors.purple[50], Colors.purple[100], Colors.purple[200], @@ -69,7 +69,7 @@ class CustomScrollViewDemo extends StatelessWidget { expandedHeight: 190.0, leading: Container( margin: EdgeInsets.all(10), - child: Image.asset('assets/images/icon_head.png')), + child: Image.asset('assets/images/icon_head.webp')), flexibleSpace: FlexibleSpaceBar( //伸展处布局 titlePadding: EdgeInsets.only(left: 55, bottom: 15), //标题边距 @@ -82,7 +82,7 @@ class CustomScrollViewDemo extends StatelessWidget { ]), ), background: Image.asset( - "assets/images/caver.jpeg", fit: BoxFit.cover, + "assets/images/caver.webp", fit: BoxFit.cover, ), ), ); diff --git a/lib/views/widgets/Sliver/FlexibleSpaceBar/node1_base.dart b/lib/views/widgets/Sliver/FlexibleSpaceBar/node1_base.dart index 600a198..39c745b 100644 --- a/lib/views/widgets/Sliver/FlexibleSpaceBar/node1_base.dart +++ b/lib/views/widgets/Sliver/FlexibleSpaceBar/node1_base.dart @@ -62,7 +62,7 @@ class FlexibleSpaceBarDemo extends StatelessWidget { collapseMode: CollapseMode.parallax, //视差效果 stretchModes: [StretchMode.blurBackground,StretchMode.zoomBackground], background: Image.asset( - "assets/images/caver.jpeg", + "assets/images/caver.webp", fit: BoxFit.cover, ), ), @@ -71,7 +71,7 @@ class FlexibleSpaceBarDemo extends StatelessWidget { Widget _buildLeading() => Container( margin: EdgeInsets.all(10), - child: Image.asset('assets/images/icon_head.png')); + child: Image.asset('assets/images/icon_head.webp')); List _buildActions() => [ IconButton( diff --git a/lib/views/widgets/Sliver/SliverAppBar/node1_base.dart b/lib/views/widgets/Sliver/SliverAppBar/node1_base.dart index 67dd92e..d48f587 100644 --- a/lib/views/widgets/Sliver/SliverAppBar/node1_base.dart +++ b/lib/views/widgets/Sliver/SliverAppBar/node1_base.dart @@ -79,7 +79,7 @@ class _SliverAppBarDemoState extends State { titlePadding: EdgeInsets.only(left: 55, bottom: 15), //标题边距 collapseMode: CollapseMode.parallax, //视差效果 background: Image.asset( - "assets/images/caver.jpeg", + "assets/images/caver.webp", fit: BoxFit.cover, ), ), @@ -88,7 +88,7 @@ class _SliverAppBarDemoState extends State { Widget _buildLeading() => Container( margin: EdgeInsets.all(10), - child: Image.asset('assets/images/icon_head.png')); + child: Image.asset('assets/images/icon_head.webp')); List _buildActions() => [ IconButton( diff --git a/lib/views/widgets/Sliver/SliverFillViewport/node1_base.dart b/lib/views/widgets/Sliver/SliverFillViewport/node1_base.dart index b27cf12..01d5237 100644 --- a/lib/views/widgets/Sliver/SliverFillViewport/node1_base.dart +++ b/lib/views/widgets/Sliver/SliverFillViewport/node1_base.dart @@ -81,7 +81,7 @@ class _SliverFillViewportDemoState extends State { titlePadding: EdgeInsets.only(left: 55, bottom: 15), //标题边距 collapseMode: CollapseMode.parallax, //视差效果 background: Image.asset( - "assets/images/caver.jpeg", + "assets/images/caver.webp", fit: BoxFit.cover, ), ), @@ -90,7 +90,7 @@ class _SliverFillViewportDemoState extends State { Widget _buildLeading() => Container( margin: EdgeInsets.all(10), - child: Image.asset('assets/images/icon_head.png')); + child: Image.asset('assets/images/icon_head.webp')); List _buildActions() => [ IconButton( diff --git a/lib/views/widgets/Sliver/SliverFixedExtentList/node1_base.dart b/lib/views/widgets/Sliver/SliverFixedExtentList/node1_base.dart index b5c18f5..c43fae0 100644 --- a/lib/views/widgets/Sliver/SliverFixedExtentList/node1_base.dart +++ b/lib/views/widgets/Sliver/SliverFixedExtentList/node1_base.dart @@ -75,7 +75,7 @@ class _SliverFixedExtentListDemoState extends State { titlePadding: EdgeInsets.only(left: 55, bottom: 15), //标题边距 collapseMode: CollapseMode.parallax, //视差效果 background: Image.asset( - "assets/images/caver.jpeg", + "assets/images/caver.webp", fit: BoxFit.cover, ), ), @@ -84,7 +84,7 @@ class _SliverFixedExtentListDemoState extends State { Widget _buildLeading() => Container( margin: EdgeInsets.all(10), - child: Image.asset('assets/images/icon_head.png')); + child: Image.asset('assets/images/icon_head.webp')); List _buildActions() => [ IconButton( diff --git a/lib/views/widgets/Sliver/SliverGrid/node1_base.dart b/lib/views/widgets/Sliver/SliverGrid/node1_base.dart index 298ac32..3781a8e 100644 --- a/lib/views/widgets/Sliver/SliverGrid/node1_base.dart +++ b/lib/views/widgets/Sliver/SliverGrid/node1_base.dart @@ -63,7 +63,7 @@ class SliverGirdDemo extends StatelessWidget { titlePadding: EdgeInsets.only(left: 55, bottom: 15), //标题边距 collapseMode: CollapseMode.parallax, //视差效果 background: Image.asset( - "assets/images/caver.jpeg", + "assets/images/caver.webp", fit: BoxFit.cover, ), ), @@ -72,7 +72,7 @@ class SliverGirdDemo extends StatelessWidget { Widget _buildLeading() => Container( margin: EdgeInsets.all(10), - child: Image.asset('assets/images/icon_head.png')); + child: Image.asset('assets/images/icon_head.webp')); List _buildActions() => [ IconButton( diff --git a/lib/views/widgets/Sliver/SliverList/node1_base.dart b/lib/views/widgets/Sliver/SliverList/node1_base.dart index 1ae36b5..06c62af 100644 --- a/lib/views/widgets/Sliver/SliverList/node1_base.dart +++ b/lib/views/widgets/Sliver/SliverList/node1_base.dart @@ -68,7 +68,7 @@ class SliverListDemo extends StatelessWidget { titlePadding: EdgeInsets.only(left: 55, bottom: 15), //标题边距 collapseMode: CollapseMode.parallax, //视差效果 background: Image.asset( - "assets/images/caver.jpeg", + "assets/images/caver.webp", fit: BoxFit.cover, ), ), @@ -77,7 +77,7 @@ class SliverListDemo extends StatelessWidget { Widget _buildLeading() => Container( margin: EdgeInsets.all(10), - child: Image.asset('assets/images/icon_head.png')); + child: Image.asset('assets/images/icon_head.webp')); List _buildActions() => [ IconButton( diff --git a/lib/views/widgets/Sliver/SliverOpacity/node1_base.dart b/lib/views/widgets/Sliver/SliverOpacity/node1_base.dart index e320514..f3e0c26 100644 --- a/lib/views/widgets/Sliver/SliverOpacity/node1_base.dart +++ b/lib/views/widgets/Sliver/SliverOpacity/node1_base.dart @@ -67,7 +67,7 @@ class SliverOpacityDemo extends StatelessWidget { titlePadding: EdgeInsets.only(left: 55, bottom: 15), //标题边距 collapseMode: CollapseMode.parallax, //视差效果 background: Image.asset( - "assets/images/caver.jpeg", + "assets/images/caver.webp", fit: BoxFit.cover, ), ), @@ -76,7 +76,7 @@ class SliverOpacityDemo extends StatelessWidget { Widget _buildLeading() => Container( margin: EdgeInsets.all(10), - child: Image.asset('assets/images/icon_head.png')); + child: Image.asset('assets/images/icon_head.webp')); List _buildActions() => [ IconButton( diff --git a/lib/views/widgets/Sliver/SliverOverlapAbsorber/node1_base.dart b/lib/views/widgets/Sliver/SliverOverlapAbsorber/node1_base.dart index 8f62261..6767c4d 100644 --- a/lib/views/widgets/Sliver/SliverOverlapAbsorber/node1_base.dart +++ b/lib/views/widgets/Sliver/SliverOverlapAbsorber/node1_base.dart @@ -39,7 +39,7 @@ class SliverOverlapAbsorberDemo extends StatelessWidget { forceElevated: innerBoxIsScrolled, //为true时展开有阴影 flexibleSpace: FlexibleSpaceBar( background: Image.asset( - "assets/images/wy_300x200_filter.jpg", + "assets/images/wy_300x200_filter.webp", fit: BoxFit.cover, ), ), diff --git a/lib/views/widgets/Sliver/SliverOverlapInjector/node1_base.dart b/lib/views/widgets/Sliver/SliverOverlapInjector/node1_base.dart index 4381e06..f0cb843 100644 --- a/lib/views/widgets/Sliver/SliverOverlapInjector/node1_base.dart +++ b/lib/views/widgets/Sliver/SliverOverlapInjector/node1_base.dart @@ -39,7 +39,7 @@ class SliverOverlapInjectorDemo extends StatelessWidget { forceElevated: innerBoxIsScrolled, //为true时展开有阴影 flexibleSpace: FlexibleSpaceBar( background: Image.asset( - "assets/images/wy_300x200_filter.jpg", + "assets/images/wy_300x200_filter.webp", fit: BoxFit.cover, ), ), diff --git a/lib/views/widgets/Sliver/SliverPadding/node1_base.dart b/lib/views/widgets/Sliver/SliverPadding/node1_base.dart index 96e286e..f77e6e5 100644 --- a/lib/views/widgets/Sliver/SliverPadding/node1_base.dart +++ b/lib/views/widgets/Sliver/SliverPadding/node1_base.dart @@ -65,7 +65,7 @@ class SliverPaddingDemo extends StatelessWidget { titlePadding: EdgeInsets.only(left: 55, bottom: 15), //标题边距 collapseMode: CollapseMode.parallax, //视差效果 background: Image.asset( - "assets/images/caver.jpeg", + "assets/images/caver.webp", fit: BoxFit.cover, ), ), @@ -74,7 +74,7 @@ class SliverPaddingDemo extends StatelessWidget { Widget _buildLeading() => Container( margin: EdgeInsets.all(10), - child: Image.asset('assets/images/icon_head.png')); + child: Image.asset('assets/images/icon_head.webp')); List _buildActions() => [ IconButton( diff --git a/lib/views/widgets/Sliver/SliverPersistentHeader/node1_base.dart b/lib/views/widgets/Sliver/SliverPersistentHeader/node1_base.dart index cec3816..1e1a607 100644 --- a/lib/views/widgets/Sliver/SliverPersistentHeader/node1_base.dart +++ b/lib/views/widgets/Sliver/SliverPersistentHeader/node1_base.dart @@ -49,7 +49,7 @@ class SliverPersistentHeaderDemo extends StatelessWidget { padding: EdgeInsets.symmetric(horizontal: 10), color: Colors.grey.withAlpha(22), child: ListTile( - leading: Image.asset("assets/images/icon_head.png"), + leading: Image.asset("assets/images/icon_head.webp"), title: Text("以梦为马"), subtitle: Text("海子"), selected: true, @@ -107,7 +107,7 @@ class SliverPersistentHeaderDemo extends StatelessWidget { titlePadding: EdgeInsets.only(left: 55, bottom: 15), //标题边距 collapseMode: CollapseMode.parallax, //视差效果 background: Image.asset( - "assets/images/caver.jpeg", + "assets/images/caver.webp", fit: BoxFit.cover, ), ), @@ -116,7 +116,7 @@ class SliverPersistentHeaderDemo extends StatelessWidget { Widget _buildLeading() => Container( margin: EdgeInsets.all(10), - child: Image.asset('assets/images/icon_head.png')); + child: Image.asset('assets/images/icon_head.webp')); List _buildActions() => [ IconButton( diff --git a/lib/views/widgets/Sliver/SliverToBoxAdapter/node1_base.dart b/lib/views/widgets/Sliver/SliverToBoxAdapter/node1_base.dart index 3eaa525..167baa3 100644 --- a/lib/views/widgets/Sliver/SliverToBoxAdapter/node1_base.dart +++ b/lib/views/widgets/Sliver/SliverToBoxAdapter/node1_base.dart @@ -43,7 +43,7 @@ class SliverToBoxAdapterDemo extends StatelessWidget { padding: EdgeInsets.symmetric(horizontal: 10), color: Colors.grey.withAlpha(22), child: ListTile( - leading: Image.asset("assets/images/icon_head.png"), + leading: Image.asset("assets/images/icon_head.webp"), title: Text("以梦为马"), subtitle: Text("海子"), selected: true, @@ -87,7 +87,7 @@ class SliverToBoxAdapterDemo extends StatelessWidget { titlePadding: EdgeInsets.only(left: 55, bottom: 15), //标题边距 collapseMode: CollapseMode.parallax, //视差效果 background: Image.asset( - "assets/images/caver.jpeg", + "assets/images/caver.webp", fit: BoxFit.cover, ), ), @@ -96,7 +96,7 @@ class SliverToBoxAdapterDemo extends StatelessWidget { Widget _buildLeading() => Container( margin: EdgeInsets.all(10), - child: Image.asset('assets/images/icon_head.png')); + child: Image.asset('assets/images/icon_head.webp')); List _buildActions() => [ IconButton( diff --git a/lib/views/widgets/StatefulWidget/AnimatedContainer/node1_base.dart b/lib/views/widgets/StatefulWidget/AnimatedContainer/node1_base.dart index ca9e749..37d925c 100644 --- a/lib/views/widgets/StatefulWidget/AnimatedContainer/node1_base.dart +++ b/lib/views/widgets/StatefulWidget/AnimatedContainer/node1_base.dart @@ -32,11 +32,11 @@ class _CustomAnimatedContainerState extends State { final Decoration startDecoration = BoxDecoration( color: Colors.blue, image: DecorationImage( - image: AssetImage('assets/images/wy_200x300.jpg'), fit: BoxFit.cover), + image: AssetImage('assets/images/wy_200x300.webp'), fit: BoxFit.cover), borderRadius: BorderRadius.all(Radius.circular(20))); final Decoration endDecoration = BoxDecoration( image: DecorationImage( - image: AssetImage('assets/images/wy_200x300.jpg'), fit: BoxFit.cover), + image: AssetImage('assets/images/wy_200x300.webp'), fit: BoxFit.cover), color: Colors.orange, borderRadius: BorderRadius.all(Radius.circular(50))); diff --git a/lib/views/widgets/StatefulWidget/AnimatedCrossFade/node1_base.dart b/lib/views/widgets/StatefulWidget/AnimatedCrossFade/node1_base.dart index 5083040..cc72e64 100644 --- a/lib/views/widgets/StatefulWidget/AnimatedCrossFade/node1_base.dart +++ b/lib/views/widgets/StatefulWidget/AnimatedCrossFade/node1_base.dart @@ -37,7 +37,7 @@ class _CustomAnimatedCrossFadeState extends State { width: 200, height: 150, color: Colors.orange, - child: FlutterLogo(colors: Colors.blue, size: 100,), + child: FlutterLogo(textColor: Colors.blue, size: 100,), ), secondChild: Container( width: 200, @@ -46,7 +46,7 @@ class _CustomAnimatedCrossFadeState extends State { color: Colors.blue, child: FlutterLogo( textColor: Colors.white, - colors: Colors.orange, +// colors: Colors.orange, size: 100, style: FlutterLogoStyle.stacked,), ), diff --git a/lib/views/widgets/StatefulWidget/AnimatedCrossFade/node2_curve.dart b/lib/views/widgets/StatefulWidget/AnimatedCrossFade/node2_curve.dart index 7522f70..e4ac90f 100644 --- a/lib/views/widgets/StatefulWidget/AnimatedCrossFade/node2_curve.dart +++ b/lib/views/widgets/StatefulWidget/AnimatedCrossFade/node2_curve.dart @@ -37,7 +37,7 @@ class _CurveAnimatedCrossFadeState extends State { width: 200, height: 80, color: Colors.orange , - child: FlutterLogo(colors: Colors.blue,size: 50,), + child: FlutterLogo(textColor: Colors.blue,size: 50,), ), secondChild: Container( width: 200, @@ -46,7 +46,8 @@ class _CurveAnimatedCrossFadeState extends State { color: Colors.blue, child: FlutterLogo( textColor: Colors.white, - colors: Colors.orange,size: 100,style: FlutterLogoStyle.stacked,), +// colors: Colors.orange, + size: 100,style: FlutterLogoStyle.stacked,), ), duration: Duration(milliseconds: 1000), crossFadeState: _crossFadeState, diff --git a/lib/views/widgets/StatefulWidget/AppBar/node2_tab.dart b/lib/views/widgets/StatefulWidget/AppBar/node2_tab.dart index d8aff46..ac8f30e 100755 --- a/lib/views/widgets/StatefulWidget/AppBar/node2_tab.dart +++ b/lib/views/widgets/StatefulWidget/AppBar/node2_tab.dart @@ -41,7 +41,7 @@ class _TabAppBarState extends State decoration: BoxDecoration( image: DecorationImage( image: AssetImage( - "assets/images/sabar.jpg", + "assets/images/sabar.webp", ), fit: BoxFit.cover)), child: _buildAppBar(), diff --git a/lib/views/widgets/StatefulWidget/CupertinoContextMenu/node1_base.dart b/lib/views/widgets/StatefulWidget/CupertinoContextMenu/node1_base.dart index 5bf17ab..8508d4a 100644 --- a/lib/views/widgets/StatefulWidget/CupertinoContextMenu/node1_base.dart +++ b/lib/views/widgets/StatefulWidget/CupertinoContextMenu/node1_base.dart @@ -27,7 +27,7 @@ class CustomCupertinoContextMenu extends StatelessWidget { Widget _buildCupertinoContextMenu(context) => Container( decoration: BoxDecoration( image: DecorationImage( - image: AssetImage('assets/images/sabar_bar.jpg'), + image: AssetImage('assets/images/sabar_bar.webp'), fit: BoxFit.cover), borderRadius: BorderRadius.all(Radius.circular(50))), width: 100, @@ -36,7 +36,7 @@ class CustomCupertinoContextMenu extends StatelessWidget { child: Container( decoration: BoxDecoration( image: DecorationImage( - image: AssetImage('assets/images/sabar_bar.jpg'), + image: AssetImage('assets/images/sabar_bar.webp'), fit: BoxFit.cover), borderRadius: BorderRadius.all(Radius.circular(50))), ), diff --git a/lib/views/widgets/StatefulWidget/CupertinoNavigationBar/node1_base.dart b/lib/views/widgets/StatefulWidget/CupertinoNavigationBar/node1_base.dart index 786aa02..e259daa 100755 --- a/lib/views/widgets/StatefulWidget/CupertinoNavigationBar/node1_base.dart +++ b/lib/views/widgets/StatefulWidget/CupertinoNavigationBar/node1_base.dart @@ -26,7 +26,7 @@ class CustomCupertinoNavigationBar extends StatelessWidget { ), middle: Text("风雪雅舍"), trailing: Image.asset( - "assets/images/icon_head.png", + "assets/images/icon_head.webp", width: 25.0, height: 25.0, ), diff --git a/lib/views/widgets/StatefulWidget/CupertinoSegmentedControl/node1_base.dart b/lib/views/widgets/StatefulWidget/CupertinoSegmentedControl/node1_base.dart index 49bc1b2..59ef2c9 100644 --- a/lib/views/widgets/StatefulWidget/CupertinoSegmentedControl/node1_base.dart +++ b/lib/views/widgets/StatefulWidget/CupertinoSegmentedControl/node1_base.dart @@ -7,11 +7,11 @@ import 'package:flutter/material.dart'; /// // { // "widgetId": 262, -// "name": '基本使用', +// "name": 'iOS页签基本使用', // "priority": 1, // "subtitle": // "【children】 : 组件Map 【Map】\n" -// "【onValueChanged】 : 最小值 【ValueChanged】\n" +// "【onValueChanged】 : 值改变回调 【ValueChanged】\n" // "【groupValue】 : 选中值 【T】\n" // "【padding】 : 内边距 【EdgeInsetsGeometry】", // } diff --git a/lib/views/widgets/StatefulWidget/Hero/node1_base.dart b/lib/views/widgets/StatefulWidget/Hero/node1_base.dart index b6c2e1b..8c1aeba 100644 --- a/lib/views/widgets/StatefulWidget/Hero/node1_base.dart +++ b/lib/views/widgets/StatefulWidget/Hero/node1_base.dart @@ -21,7 +21,7 @@ class CustomHero extends StatelessWidget { child: ClipRRect( borderRadius: BorderRadius.all(Radius.circular(30)), child: Image.asset( - "assets/images/icon_head.png", + "assets/images/icon_head.webp", width: 60, height: 60, fit: BoxFit.cover, @@ -65,7 +65,7 @@ class TargetPage extends StatelessWidget { child: CircleAvatar( backgroundColor: Colors.transparent, backgroundImage: AssetImage( - "assets/images/icon_head.png", + "assets/images/icon_head.webp", ), ), ), diff --git a/lib/views/widgets/StatefulWidget/Image/node1_base.dart b/lib/views/widgets/StatefulWidget/Image/node1_base.dart index 248df53..54fa4c0 100644 --- a/lib/views/widgets/StatefulWidget/Image/node1_base.dart +++ b/lib/views/widgets/StatefulWidget/Image/node1_base.dart @@ -17,7 +17,7 @@ import 'package:flutter/material.dart'; // } class LoadImage extends StatelessWidget { - final assetsImagePath = "assets/images/icon_head.png"; + final assetsImagePath = "assets/images/icon_head.webp"; final assetsGif = "assets/images/pica.gif"; final netImageUrl = "https://user-gold-cdn.xitu.io" "/2019/7/24/16c225e78234ec26?" diff --git a/lib/views/widgets/StatefulWidget/Image/node2_fit.dart b/lib/views/widgets/StatefulWidget/Image/node2_fit.dart index 425d834..17573d8 100644 --- a/lib/views/widgets/StatefulWidget/Image/node2_fit.dart +++ b/lib/views/widgets/StatefulWidget/Image/node2_fit.dart @@ -31,8 +31,8 @@ class _FitImageState extends State { color: Colors.grey.withAlpha(88), child: Image( image: AssetImage(!_smallImage - ? "assets/images/wy_300x200.jpg" - : "assets/images/wy_30x20.jpg"), + ? "assets/images/wy_300x200.webp" + : "assets/images/wy_30x20.webp"), fit: mode)), Text(mode.toString().split(".")[1]) ])) diff --git a/lib/views/widgets/StatefulWidget/Image/node3_alignment.dart b/lib/views/widgets/StatefulWidget/Image/node3_alignment.dart index 7ccf5f5..fc2750a 100644 --- a/lib/views/widgets/StatefulWidget/Image/node3_alignment.dart +++ b/lib/views/widgets/StatefulWidget/Image/node3_alignment.dart @@ -35,7 +35,7 @@ class AlignmentImage extends StatelessWidget { height: 60, color: Colors.grey.withAlpha(88), child: Image( - image: AssetImage("assets/images/wy_30x20.jpg"), + image: AssetImage("assets/images/wy_30x20.webp"), alignment: alignment, )), Text(alignment.toString()) diff --git a/lib/views/widgets/StatefulWidget/Image/node4_colorBlendMode.dart b/lib/views/widgets/StatefulWidget/Image/node4_colorBlendMode.dart index 50a202b..647ea8c 100644 --- a/lib/views/widgets/StatefulWidget/Image/node4_colorBlendMode.dart +++ b/lib/views/widgets/StatefulWidget/Image/node4_colorBlendMode.dart @@ -25,7 +25,7 @@ class BlendModeImage extends StatelessWidget { height: 60, color: Colors.red, child: Image( - image: AssetImage("assets/images/icon_head.png"), + image: AssetImage("assets/images/icon_head.webp"), color: Colors.blue.withAlpha(88), colorBlendMode: mode)), Text(mode.toString().split(".")[1]) diff --git a/lib/views/widgets/StatefulWidget/Image/node5_repeat.dart b/lib/views/widgets/StatefulWidget/Image/node5_repeat.dart index 64eeffa..27c45f8 100644 --- a/lib/views/widgets/StatefulWidget/Image/node5_repeat.dart +++ b/lib/views/widgets/StatefulWidget/Image/node5_repeat.dart @@ -24,7 +24,7 @@ class RepeatImage extends StatelessWidget { height: 60, color: Colors.red, child: Image( - image: AssetImage("assets/images/wy_30x20.jpg"), + image: AssetImage("assets/images/wy_30x20.webp"), repeat: mode)), Text(mode.toString().split(".")[1]) ])) diff --git a/lib/views/widgets/StatefulWidget/Ink/node2_image.dart b/lib/views/widgets/StatefulWidget/Ink/node2_image.dart index ca82740..23226b8 100644 --- a/lib/views/widgets/StatefulWidget/Ink/node2_image.dart +++ b/lib/views/widgets/StatefulWidget/Ink/node2_image.dart @@ -18,7 +18,7 @@ class InkImage extends StatelessWidget { color: Colors.grey[800], child: Center( child: Ink.image( - image: AssetImage('assets/images/sabar.jpg'), + image: AssetImage('assets/images/sabar.webp'), fit: BoxFit.cover, width: 300.0, height: 200.0, diff --git a/lib/views/widgets/StatefulWidget/InteractiveViewer/node1_base.dart b/lib/views/widgets/StatefulWidget/InteractiveViewer/node1_base.dart index e34cccc..41979fd 100644 --- a/lib/views/widgets/StatefulWidget/InteractiveViewer/node1_base.dart +++ b/lib/views/widgets/StatefulWidget/InteractiveViewer/node1_base.dart @@ -34,7 +34,7 @@ class InteractiveViewerDemo extends StatelessWidget { panEnabled: true, scaleEnabled: true, child: Container( - child: Image.asset('assets/images/caver.jpeg'), + child: Image.asset('assets/images/caver.webp'), ), onInteractionStart: _onInteractionStart, onInteractionUpdate: _onInteractionUpdate, diff --git a/lib/views/widgets/StatefulWidget/InteractiveViewer/node3_controller.dart b/lib/views/widgets/StatefulWidget/InteractiveViewer/node3_controller.dart index c1a84ff..6533789 100644 --- a/lib/views/widgets/StatefulWidget/InteractiveViewer/node3_controller.dart +++ b/lib/views/widgets/StatefulWidget/InteractiveViewer/node3_controller.dart @@ -1,4 +1,3 @@ -import 'dart:math'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; @@ -90,7 +89,7 @@ class _InteractiveViewerDemo3State extends State maxScale: 1.8, onInteractionStart: _onInteractionStart, child: Container( - child: Image.asset('assets/images/caver.jpeg'), + child: Image.asset('assets/images/caver.webp'), ), ), ), diff --git a/lib/views/widgets/StatefulWidget/MaterialApp/node1_base.dart b/lib/views/widgets/StatefulWidget/MaterialApp/node1_base.dart index cfb7494..a315923 100644 --- a/lib/views/widgets/StatefulWidget/MaterialApp/node1_base.dart +++ b/lib/views/widgets/StatefulWidget/MaterialApp/node1_base.dart @@ -1,6 +1,4 @@ import 'package:flutter/material.dart'; -import '../../../../app/router.dart'; -import '../../StatefulWidget/Scaffold/node1_base.dart'; /// create by 张风捷特烈 on 2020-03-17 /// contact me by email 1981462002@qq.com @@ -13,22 +11,117 @@ import '../../StatefulWidget/Scaffold/node1_base.dart'; // "subtitle": // "【theme】 : 主题 【ThemeData】\n" // "【title】 : 任务栏标题 【String】\n" +// "【debugShowCheckedModeBanner】 : 开启角标 【bool】\n" +// "【showPerformanceOverlay】 : 开启性能浮层 【bool】\n" +// "【debugShowMaterialGrid】 : 开启网格 【bool】\n" // "【onGenerateRoute】 : 路由生成器 【RouteFactory】\n" // "【home】 : 主页 【Widget】", // } -class CustomMaterialApp extends StatelessWidget { +class MaterialAppDemo extends StatefulWidget { + @override + _WidgetsAppDemoState createState() => _WidgetsAppDemoState(); +} + +class _WidgetsAppDemoState extends State { + var _debugShowCheckedModeBanner = false; + var _showPerformanceOverlay = false; + var _debugShowMaterialGrid = false; + @override Widget build(BuildContext context) { - return Container( - width: MediaQuery.of(context).size.width, - height: MediaQuery.of(context).size.height - 200, - child: MaterialApp( - title: 'Flutter Demo', - onGenerateRoute: Router.generateRoute, - theme: ThemeData( - primarySwatch: Colors.blue, + return Column( + mainAxisSize: MainAxisSize.min, + children: [ + _buildSwitchers(), + Container( + height: 250, + child: MaterialApp( + debugShowCheckedModeBanner: _debugShowCheckedModeBanner, + showPerformanceOverlay: _showPerformanceOverlay, + debugShowMaterialGrid: _debugShowMaterialGrid, + home: HomePage(), + ), ), - home: CustomScaffold(), + ], + ); + } + + Widget _buildSwitchers() { + return DefaultTextStyle( + style: TextStyle(color: Colors.blue), + child: Wrap( + spacing: 10, + children: [ + Column( + children: [ + Switch( + value: _showPerformanceOverlay, + onChanged: (v) { + setState(() { + _showPerformanceOverlay = v; + }); + }, + ), + Text('性能浮层') + ], + ), + Column( + children: [ + Switch( + value: _debugShowCheckedModeBanner, + onChanged: (v) { + setState(() { + _debugShowCheckedModeBanner = v; + }); + }, + ), + Text('开启角标') + ], + ), + Column( + children: [ + Switch( + value: _debugShowMaterialGrid, + onChanged: (v) { + setState(() { + _debugShowMaterialGrid = v; + }); + }, + ), + Text('开启网格') + ], + ) + ], + ), + ); + } +} + +class HomePage extends StatefulWidget { + @override + _HomePageState createState() => _HomePageState(); +} + +class _HomePageState extends State { + var _count = 0; + + @override + Widget build(BuildContext context) { + return Scaffold( + body: Container( + alignment: Alignment(0, 0.7), + child: Text( + '你点击了$_count次', + style: TextStyle(fontSize: 18, color: Colors.blue), + ), + ), + floatingActionButton: FloatingActionButton( + child: Icon(Icons.add), + onPressed: () { + setState(() { + _count++; + }); + }, ), ); } diff --git a/lib/views/widgets/StatefulWidget/NestedScrollView/node1_base.dart b/lib/views/widgets/StatefulWidget/NestedScrollView/node1_base.dart index 1c97db1..51b2cc6 100644 --- a/lib/views/widgets/StatefulWidget/NestedScrollView/node1_base.dart +++ b/lib/views/widgets/StatefulWidget/NestedScrollView/node1_base.dart @@ -34,8 +34,7 @@ class NestedScrollViewDemo extends StatelessWidget { (BuildContext context, bool innerBoxIsScrolled) { return [ SliverOverlapAbsorber( - handle: NestedScrollView.sliverOverlapAbsorberHandleFor( - context), + handle: NestedScrollView.sliverOverlapAbsorberHandleFor(context), sliver: SliverAppBar( title: const Text('旷古奇书'), pinned: true, @@ -44,7 +43,7 @@ class NestedScrollViewDemo extends StatelessWidget { forceElevated: innerBoxIsScrolled, //为true时展开有阴影 flexibleSpace: FlexibleSpaceBar( background: Image.asset( - "assets/images/wy_300x200_filter.jpg", + "assets/images/wy_300x200_filter.webp", fit: BoxFit.cover, ), ), diff --git a/lib/views/widgets/StatefulWidget/Overlay/node1_base.dart b/lib/views/widgets/StatefulWidget/Overlay/node1_base.dart index 5de2b41..4589626 100644 --- a/lib/views/widgets/StatefulWidget/Overlay/node1_base.dart +++ b/lib/views/widgets/StatefulWidget/Overlay/node1_base.dart @@ -11,61 +11,6 @@ import 'package:flutter/material.dart'; // " Overlay.of(context).insert插入全局组件", // } - -bool show = false; -Offset offset = Offset(200, 200); - -final double radius = 60; -var entry = OverlayEntry( - builder: (context) => Stack( - children: [ - Positioned( - left: offset.dx, - top: offset.dy, - child: _buildFloating(), - ), - ], - )); - -///绘制悬浮控件 -_buildFloating() => GestureDetector( - onPanDown: (details) { - offset = details.globalPosition - Offset(radius / 2, radius / 2); - entry.markNeedsBuild(); - }, - onPanUpdate: (DragUpdateDetails details) { - offset = offset + details.delta; - entry.markNeedsBuild(); - }, - onLongPress: hideFloating, - child: Material( - color: Colors.transparent, - child: Container( - height: radius, - width: radius, - alignment: Alignment.center, - decoration: BoxDecoration( - shape: BoxShape.circle, - image: DecorationImage( - image: AssetImage('assets/images/icon_head.png')), - ), - ), - )); - -showFloating(BuildContext context) { - if (!show) { - Overlay.of(context).insert(entry); - show = true; - } -} - -hideFloating() { - if (show) { - entry.remove(); - show = false; - } -} - class CustomOverlay extends StatelessWidget { @override Widget build(BuildContext context) { @@ -103,3 +48,57 @@ class CustomOverlay extends StatelessWidget { ); } } + +bool show = false; +Offset offset = Offset(200, 200); + +final double radius = 60; +var entry = OverlayEntry( + builder: (context) => Stack( + children: [ + Positioned( + left: offset.dx, + top: offset.dy, + child: _buildFloating(), + ), + ], + )); + +///绘制悬浮控件 +_buildFloating() => GestureDetector( + onPanDown: (details) { + offset = details.globalPosition - Offset(radius / 2, radius / 2); + entry.markNeedsBuild(); + }, + onPanUpdate: (DragUpdateDetails details) { + offset = offset + details.delta; + entry.markNeedsBuild(); + }, + onLongPress: hideFloating, + child: Material( + color: Colors.transparent, + child: Container( + height: radius, + width: radius, + alignment: Alignment.center, + decoration: BoxDecoration( + shape: BoxShape.circle, + image: DecorationImage( + image: AssetImage('assets/images/icon_head.webp')), + ), + ), + )); + +showFloating(BuildContext context) { + if (!show) { + Overlay.of(context).insert(entry); + show = true; + } +} + +hideFloating() { + if (show) { + entry.remove(); + show = false; + } +} diff --git a/lib/views/widgets/StatefulWidget/PopupMenuButton/node1_base.dart b/lib/views/widgets/StatefulWidget/PopupMenuButton/node1_base.dart index e7e99db..2e2330b 100644 --- a/lib/views/widgets/StatefulWidget/PopupMenuButton/node1_base.dart +++ b/lib/views/widgets/StatefulWidget/PopupMenuButton/node1_base.dart @@ -1,5 +1,5 @@ import 'package:flutter/material.dart'; -import '../../../dialogs/dialog_about.dart'; +import '../../../components/project/dialogs/dialog_about.dart'; /// create by 张风捷特烈 on 2020-03-16 /// contact me by email 1981462002@qq.com diff --git a/lib/views/widgets/StatefulWidget/PopupMenuDivider/node1_base.dart b/lib/views/widgets/StatefulWidget/PopupMenuDivider/node1_base.dart index e657c5c..3dc594d 100644 --- a/lib/views/widgets/StatefulWidget/PopupMenuDivider/node1_base.dart +++ b/lib/views/widgets/StatefulWidget/PopupMenuDivider/node1_base.dart @@ -1,5 +1,5 @@ import 'package:flutter/material.dart'; -import '../../../dialogs/dialog_about.dart'; +import '../../../components/project/dialogs/dialog_about.dart'; /// create by 张风捷特烈 on 2020-03-29 /// contact me by email 1981462002@qq.com diff --git a/lib/views/widgets/StatefulWidget/RawChip/node1_press.dart b/lib/views/widgets/StatefulWidget/RawChip/node1_press.dart index 45cdbbd..9b3938c 100644 --- a/lib/views/widgets/StatefulWidget/RawChip/node1_press.dart +++ b/lib/views/widgets/StatefulWidget/RawChip/node1_press.dart @@ -27,7 +27,7 @@ class PressRawChip extends StatelessWidget { padding: EdgeInsets.all(5), labelPadding: EdgeInsets.all(3), label: Text('张风捷特烈'), - avatar: Image.asset("assets/images/icon_head.png"), + avatar: Image.asset("assets/images/icon_head.webp"), elevation: 3, pressElevation: 5, shadowColor: Colors.orangeAccent, diff --git a/lib/views/widgets/StatefulWidget/RawChip/node2_select.dart b/lib/views/widgets/StatefulWidget/RawChip/node2_select.dart index 5427766..e4fc3b1 100644 --- a/lib/views/widgets/StatefulWidget/RawChip/node2_select.dart +++ b/lib/views/widgets/StatefulWidget/RawChip/node2_select.dart @@ -34,7 +34,7 @@ class _SelectRawChipState extends State { deleteIconColor: Colors.red, selectedColor: Colors.orangeAccent.withAlpha(44), label: Text('张风捷特烈'), - avatar: Image.asset("assets/images/icon_head.png"), + avatar: Image.asset("assets/images/icon_head.webp"), elevation: 3, pressElevation: 5, shadowColor: Colors.orangeAccent, diff --git a/lib/views/widgets/StatefulWidget/Scaffold/node1_base.dart b/lib/views/widgets/StatefulWidget/Scaffold/node1_base.dart index 7228d42..d18c178 100755 --- a/lib/views/widgets/StatefulWidget/Scaffold/node1_base.dart +++ b/lib/views/widgets/StatefulWidget/Scaffold/node1_base.dart @@ -86,7 +86,7 @@ class _CustomScaffoldState extends State with SingleTickerProviderStateMixin { Drawer _buildLeftDrawer() => Drawer( elevation: 1, child: Image.asset( - 'assets/images/sabar.jpg', + 'assets/images/sabar.webp', fit: BoxFit.cover, ), ); diff --git a/lib/views/widgets/StatefulWidget/Switch/node2_image.dart b/lib/views/widgets/StatefulWidget/Switch/node2_image.dart index bd73408..42a28d6 100644 --- a/lib/views/widgets/StatefulWidget/Switch/node2_image.dart +++ b/lib/views/widgets/StatefulWidget/Switch/node2_image.dart @@ -19,10 +19,10 @@ class ImageSwitch extends StatefulWidget { class _ImageSwitchState extends State { final imgs = [ - "assets/images/head_icon/icon_5.jpg", - "assets/images/head_icon/icon_6.jpg", - "assets/images/head_icon/icon_7.jpg", - "assets/images/head_icon/icon_8.jpg"]; + "assets/images/head_icon/icon_5.webp", + "assets/images/head_icon/icon_6.webp", + "assets/images/head_icon/icon_7.webp", + "assets/images/head_icon/icon_8.webp"]; bool _checked = false; @override diff --git a/lib/views/widgets/StatefulWidget/TextField/node1_base.dart b/lib/views/widgets/StatefulWidget/TextField/node1_base.dart index 9c8bcf4..ae14934 100644 --- a/lib/views/widgets/StatefulWidget/TextField/node1_base.dart +++ b/lib/views/widgets/StatefulWidget/TextField/node1_base.dart @@ -1,5 +1,4 @@ import 'package:flutter/material.dart'; -import 'package:flutter/services.dart'; /// create by 张风捷特烈 on 2020/4/30 /// contact me by email 1981462002@qq.com /// 说明: diff --git a/lib/views/widgets/StatefulWidget/TextField/node2_cursor.dart b/lib/views/widgets/StatefulWidget/TextField/node2_cursor.dart index 4725093..3e75a79 100644 --- a/lib/views/widgets/StatefulWidget/TextField/node2_cursor.dart +++ b/lib/views/widgets/StatefulWidget/TextField/node2_cursor.dart @@ -1,5 +1,4 @@ import 'package:flutter/material.dart'; -import 'package:flutter/services.dart'; /// create by 张风捷特烈 on 2020-03-29 /// contact me by email 1981462002@qq.com diff --git a/lib/views/widgets/StatefulWidget/TextFormField/node1_base.dart b/lib/views/widgets/StatefulWidget/TextFormField/node1_base.dart index 97d1f02..2605f83 100644 --- a/lib/views/widgets/StatefulWidget/TextFormField/node1_base.dart +++ b/lib/views/widgets/StatefulWidget/TextFormField/node1_base.dart @@ -23,37 +23,23 @@ class _CustomTextFormFieldState extends State { @override Widget build(BuildContext context) { - return Container( - child: Form( - key: _formKey, - child: - Stack( - alignment: Alignment.centerRight, - children: [ - Container( - width: 350, - child: UnconstrainedBox( - child: Container( - width: 200, - height: 70, - child: TextFormField( - style: TextStyle(textBaseline: TextBaseline.alphabetic), - decoration: InputDecoration( - border: OutlineInputBorder(), - labelText: 'username', - ), - validator: _validateUsername, - onFieldSubmitted: _onFieldSubmitted, - onSaved: _onSaved, - ), - ), - ), + return Row( + children: [ + SizedBox(width: 40), + Expanded( + child: TextFormField( + style: TextStyle(textBaseline: TextBaseline.alphabetic), + decoration: InputDecoration( + border: OutlineInputBorder(), + labelText: 'username', ), - Positioned( - top: 0, right: 0, child: _buildSubmitButton(context)), - ], + validator: _validateUsername, + onFieldSubmitted: _onFieldSubmitted, + onSaved: _onSaved, + ), ), - ), + _buildSubmitButton(context), + ], ); } diff --git a/lib/views/widgets/StatelessWidget/AboutDialog/node1_base.dart b/lib/views/widgets/StatelessWidget/AboutDialog/node1_base.dart index 53069d5..4d717ab 100644 --- a/lib/views/widgets/StatelessWidget/AboutDialog/node1_base.dart +++ b/lib/views/widgets/StatelessWidget/AboutDialog/node1_base.dart @@ -52,7 +52,7 @@ class CustomAboutDialog extends StatelessWidget { margin: EdgeInsets.only(top: 20), width: 80, height: 80, - child: Image.asset('assets/images/icon_head.png')), + child: Image.asset('assets/images/icon_head.webp')), Container( margin: EdgeInsets.only(top: 10), alignment: Alignment.center, diff --git a/lib/views/widgets/StatelessWidget/ActionChip/node1_base.dart b/lib/views/widgets/StatelessWidget/ActionChip/node1_base.dart index 0100d90..9366799 100644 --- a/lib/views/widgets/StatelessWidget/ActionChip/node1_base.dart +++ b/lib/views/widgets/StatelessWidget/ActionChip/node1_base.dart @@ -15,7 +15,7 @@ import 'package:flutter/material.dart'; -import '../../../dialogs/dialog_about.dart'; +import '../../../components/project/dialogs/dialog_about.dart'; class CustomActionChip extends StatelessWidget { @@ -26,7 +26,7 @@ class CustomActionChip extends StatelessWidget { labelPadding: EdgeInsets.all(3), label: Text("This is a ActionChip."), backgroundColor: Colors.grey.withAlpha(66), - avatar: Image.asset("assets/images/icon_head.png"), + avatar: Image.asset("assets/images/icon_head.webp"), shadowColor: Colors.orangeAccent, elevation: 3, pressElevation: 5, diff --git a/lib/views/widgets/StatelessWidget/AlertDialog/node1_base.dart b/lib/views/widgets/StatelessWidget/AlertDialog/node1_base.dart index 3f2892f..3477382 100644 --- a/lib/views/widgets/StatelessWidget/AlertDialog/node1_base.dart +++ b/lib/views/widgets/StatelessWidget/AlertDialog/node1_base.dart @@ -75,7 +75,7 @@ class CustomAlertDialog extends StatelessWidget { //标题 children: [ Image.asset( - "assets/images/icon_head.png", + "assets/images/icon_head.webp", width: 30, height: 30, ), diff --git a/lib/views/widgets/StatelessWidget/Banner/node1_base.dart b/lib/views/widgets/StatelessWidget/Banner/node1_base.dart index 4b7e3a0..5fff743 100644 --- a/lib/views/widgets/StatelessWidget/Banner/node1_base.dart +++ b/lib/views/widgets/StatelessWidget/Banner/node1_base.dart @@ -38,7 +38,7 @@ class CustomBanner extends StatelessWidget { color: data[e], child: Padding( padding: EdgeInsets.all(20), - child: FlutterLogo(colors: Colors.blue, + child: FlutterLogo(textColor: Colors.blue, style: FlutterLogoStyle.horizontal,)), ), )).toList()); diff --git a/lib/views/widgets/StatelessWidget/BottomSheet/node1_base.dart b/lib/views/widgets/StatelessWidget/BottomSheet/node1_base.dart index 2dc88a3..eb7a774 100644 --- a/lib/views/widgets/StatelessWidget/BottomSheet/node1_base.dart +++ b/lib/views/widgets/StatelessWidget/BottomSheet/node1_base.dart @@ -58,7 +58,7 @@ class _CustomBottomSheetState extends State { height: 250, decoration: BoxDecoration( image: DecorationImage( - image: AssetImage('assets/images/sabar_bar.jpg'), + image: AssetImage('assets/images/sabar_bar.webp'), fit: BoxFit.cover), borderRadius: BorderRadius.only( topRight: Radius.circular(60), diff --git a/lib/views/widgets/StatelessWidget/ButtonBar/node1_base.dart b/lib/views/widgets/StatelessWidget/ButtonBar/node1_base.dart index c469d3f..0dd4a36 100755 --- a/lib/views/widgets/StatelessWidget/ButtonBar/node1_base.dart +++ b/lib/views/widgets/StatelessWidget/ButtonBar/node1_base.dart @@ -10,7 +10,7 @@ // } import 'package:flutter/material.dart'; -import '../../../dialogs/dialog_about.dart'; +import '../../../components/project/dialogs/dialog_about.dart'; class CustomButtonBar extends StatelessWidget { diff --git a/lib/views/widgets/StatelessWidget/ButtonBar/node2_padding.dart b/lib/views/widgets/StatelessWidget/ButtonBar/node2_padding.dart index 0f58bc6..0d24862 100644 --- a/lib/views/widgets/StatelessWidget/ButtonBar/node2_padding.dart +++ b/lib/views/widgets/StatelessWidget/ButtonBar/node2_padding.dart @@ -1,6 +1,6 @@ import 'package:flutter/material.dart'; -import '../../../dialogs/dialog_about.dart'; +import '../../../components/project/dialogs/dialog_about.dart'; /// create by 张风捷特烈 on 2020-03-25 /// contact me by email 1981462002@qq.com diff --git a/lib/views/widgets/StatelessWidget/CheckboxListTile/node1_base.dart b/lib/views/widgets/StatelessWidget/CheckboxListTile/node1_base.dart index 8bf6fbc..b644f1c 100644 --- a/lib/views/widgets/StatelessWidget/CheckboxListTile/node1_base.dart +++ b/lib/views/widgets/StatelessWidget/CheckboxListTile/node1_base.dart @@ -33,7 +33,7 @@ class _CustomCheckBoxListTileState extends State { value: _selected, checkColor: Colors.yellow, activeColor: Colors.orangeAccent, - secondary: Image.asset("assets/images/icon_head.png"), + secondary: Image.asset("assets/images/icon_head.webp"), title: Text("张风捷特烈"), subtitle: Text("@万花过尽知无物"), onChanged: (v) => setState(() => _selected = !_selected), diff --git a/lib/views/widgets/StatelessWidget/CheckboxListTile/node2_select.dart b/lib/views/widgets/StatelessWidget/CheckboxListTile/node2_select.dart index abe5014..dcc38d8 100644 --- a/lib/views/widgets/StatelessWidget/CheckboxListTile/node2_select.dart +++ b/lib/views/widgets/StatelessWidget/CheckboxListTile/node2_select.dart @@ -29,7 +29,7 @@ class _SelectCheckBoxListTileState extends State { selected: _selected, checkColor: Colors.yellow, activeColor: Colors.orangeAccent, - secondary: Image.asset("assets/images/icon_head.png"), + secondary: Image.asset("assets/images/icon_head.webp"), title: Text("张风捷特烈"), subtitle: Text("@万花过尽知无物"), onChanged: (v) => setState(() => _selected = !_selected), diff --git a/lib/views/widgets/StatelessWidget/CheckboxListTile/node3_dense.dart b/lib/views/widgets/StatelessWidget/CheckboxListTile/node3_dense.dart index 15e133e..81c9888 100644 --- a/lib/views/widgets/StatelessWidget/CheckboxListTile/node3_dense.dart +++ b/lib/views/widgets/StatelessWidget/CheckboxListTile/node3_dense.dart @@ -29,7 +29,7 @@ class _DenseCheckBoxListTileState extends State { dense: true, checkColor: Colors.yellow, activeColor: Colors.orangeAccent, - secondary: Image.asset("assets/images/icon_head.png"), + secondary: Image.asset("assets/images/icon_head.webp"), title: Text("张风捷特烈"), subtitle: Text("@万花过尽知无物"), onChanged: (v) => setState(() => _selected = !_selected), diff --git a/lib/views/widgets/StatelessWidget/Chip/node1_base.dart b/lib/views/widgets/StatelessWidget/Chip/node1_base.dart index c0ff799..7c829f5 100644 --- a/lib/views/widgets/StatelessWidget/Chip/node1_base.dart +++ b/lib/views/widgets/StatelessWidget/Chip/node1_base.dart @@ -22,7 +22,7 @@ class CustomChip extends StatelessWidget { spacing: 20, children: [ Chip( - avatar: Image.asset("assets/images/icon_head.png"), + avatar: Image.asset("assets/images/icon_head.webp"), label: Text("张风捷特烈"), padding: EdgeInsets.all(5), labelPadding: EdgeInsets.all(5), @@ -30,7 +30,7 @@ class CustomChip extends StatelessWidget { Chip( avatar: CircleAvatar( backgroundImage: - AssetImage("assets/images/wy_200x300.jpg")), + AssetImage("assets/images/wy_200x300.webp")), label: Text("百里巫缨"), padding: EdgeInsets.all(8), labelPadding: EdgeInsets.all(6), diff --git a/lib/views/widgets/StatelessWidget/Chip/node2_color.dart b/lib/views/widgets/StatelessWidget/Chip/node2_color.dart index a9f4f1f..edbc8ca 100644 --- a/lib/views/widgets/StatelessWidget/Chip/node2_color.dart +++ b/lib/views/widgets/StatelessWidget/Chip/node2_color.dart @@ -20,7 +20,7 @@ class ColorOfChip extends StatelessWidget { spacing: 20, children: [ Chip( - avatar: Image.asset("assets/images/icon_head.png"), + avatar: Image.asset("assets/images/icon_head.webp"), label: Text("张风捷特烈"), padding: EdgeInsets.all(5), labelPadding: EdgeInsets.all(5), @@ -29,7 +29,7 @@ class ColorOfChip extends StatelessWidget { elevation: 3, ), Chip( - avatar: Image.asset("assets/images/icon_head.png"), + avatar: Image.asset("assets/images/icon_head.webp"), label: Text("张风捷特烈"), padding: EdgeInsets.all(5), labelPadding: EdgeInsets.all(5), diff --git a/lib/views/widgets/StatelessWidget/Chip/node3_delete.dart b/lib/views/widgets/StatelessWidget/Chip/node3_delete.dart index 910d936..0f5a2dd 100644 --- a/lib/views/widgets/StatelessWidget/Chip/node3_delete.dart +++ b/lib/views/widgets/StatelessWidget/Chip/node3_delete.dart @@ -13,13 +13,13 @@ // "【onDeleted】: 右侧组件点击事件 【Function】", // } import 'package:flutter/material.dart'; -import '../../../dialogs/dialog_about.dart'; +import '../../../components/project/dialogs/dialog_about.dart'; class DeleteOfChip extends StatelessWidget { @override Widget build(BuildContext context) { return Chip( - avatar: Image.asset("assets/images/icon_head.png"), + avatar: Image.asset("assets/images/icon_head.webp"), label: Text("张风捷特烈"), padding: EdgeInsets.all(5), labelPadding: EdgeInsets.all(3), diff --git a/lib/views/widgets/StatelessWidget/ChoiceChip/node1_base.dart b/lib/views/widgets/StatelessWidget/ChoiceChip/node1_base.dart index 65beaea..5c548cf 100644 --- a/lib/views/widgets/StatelessWidget/ChoiceChip/node1_base.dart +++ b/lib/views/widgets/StatelessWidget/ChoiceChip/node1_base.dart @@ -35,7 +35,7 @@ class _CustomChoiceChipState extends State { style: TextStyle(fontSize: 16), ), backgroundColor: Colors.grey.withAlpha(66), - avatar: Image.asset("assets/images/icon_head.png"), + avatar: Image.asset("assets/images/icon_head.webp"), selectedColor: Colors.orangeAccent.withAlpha(44), selectedShadowColor: Colors.blue, shadowColor: Colors.orangeAccent, diff --git a/lib/views/widgets/StatelessWidget/CircleAvatar/node1_base.dart b/lib/views/widgets/StatelessWidget/CircleAvatar/node1_base.dart index 0e0c7bc..f1fbd0d 100644 --- a/lib/views/widgets/StatelessWidget/CircleAvatar/node1_base.dart +++ b/lib/views/widgets/StatelessWidget/CircleAvatar/node1_base.dart @@ -21,7 +21,7 @@ class CustomCircleAvatar extends StatelessWidget { Widget build(BuildContext context) { return CircleAvatar( radius: 50, - backgroundImage: AssetImage("assets/images/wy_200x300.jpg"), + backgroundImage: AssetImage("assets/images/wy_200x300.webp"), foregroundColor: Colors.white, child: Icon( Icons.check, diff --git a/lib/views/widgets/StatelessWidget/Container/node4_decoration.dart b/lib/views/widgets/StatelessWidget/Container/node4_decoration.dart index febe711..15423df 100644 --- a/lib/views/widgets/StatelessWidget/Container/node4_decoration.dart +++ b/lib/views/widgets/StatelessWidget/Container/node4_decoration.dart @@ -14,7 +14,7 @@ import 'package:flutter/material.dart'; class ContainerDecoration extends StatelessWidget { - static const rainbow = [ + final List rainbow = [ 0xffff0000, 0xffFF7F00, 0xffFFFF00, @@ -23,10 +23,10 @@ class ContainerDecoration extends StatelessWidget { 0xff0000FF, 0xff8B00FF ]; - + final List stops = [0.0, 1 / 6, 2 / 6, 3 / 6, 4 / 6, 5 / 6, 1.0]; @override Widget build(BuildContext context) { - var stops = [0.0, 1 / 6, 2 / 6, 3 / 6, 4 / 6, 5 / 6, 1.0]; + return Container(//容器 alignment: Alignment.center, width: 200, diff --git a/lib/views/widgets/StatelessWidget/CupertinoActionSheetAction/node1_base.dart b/lib/views/widgets/StatelessWidget/CupertinoActionSheetAction/node1_base.dart index b38d8d1..8c032b5 100644 --- a/lib/views/widgets/StatelessWidget/CupertinoActionSheetAction/node1_base.dart +++ b/lib/views/widgets/StatelessWidget/CupertinoActionSheetAction/node1_base.dart @@ -13,7 +13,7 @@ import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; -import '../../../dialogs/dialog_about.dart'; +import '../../../components/project/dialogs/dialog_about.dart'; class CustomCupertinoActionSheetAction extends StatelessWidget { @override diff --git a/lib/views/widgets/StatelessWidget/CupertinoDialogAction/node1_base.dart b/lib/views/widgets/StatelessWidget/CupertinoDialogAction/node1_base.dart index bc68abc..1f1b576 100644 --- a/lib/views/widgets/StatelessWidget/CupertinoDialogAction/node1_base.dart +++ b/lib/views/widgets/StatelessWidget/CupertinoDialogAction/node1_base.dart @@ -1,8 +1,5 @@ -import 'dart:async'; - import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; -import 'dart:ui' as ui; /// create by 张风捷特烈 on 2020/7/22 /// contact me by email 1981462002@qq.com diff --git a/lib/views/widgets/StatelessWidget/Drawer/node1_base.dart b/lib/views/widgets/StatelessWidget/Drawer/node1_base.dart index e557a26..98bf6a1 100644 --- a/lib/views/widgets/StatelessWidget/Drawer/node1_base.dart +++ b/lib/views/widgets/StatelessWidget/Drawer/node1_base.dart @@ -35,7 +35,7 @@ class CustomDrawer extends StatelessWidget { DrawerHeader( decoration: BoxDecoration( image: DecorationImage( - image: AssetImage('assets/images/caver.jpeg'), + image: AssetImage('assets/images/caver.webp'), fit: BoxFit.cover), ), child: Text( diff --git a/lib/views/widgets/StatelessWidget/DrawerHeader/node1_base.dart b/lib/views/widgets/StatelessWidget/DrawerHeader/node1_base.dart index 527e69e..724d6f6 100644 --- a/lib/views/widgets/StatelessWidget/DrawerHeader/node1_base.dart +++ b/lib/views/widgets/StatelessWidget/DrawerHeader/node1_base.dart @@ -70,7 +70,7 @@ class CustomDrawerHeader extends StatelessWidget { topRight:Radius.circular(40) ), image: DecorationImage( - image: AssetImage('assets/images/caver.jpeg'), + image: AssetImage('assets/images/caver.webp'), fit: BoxFit.cover), ), child: Text( diff --git a/lib/views/widgets/StatelessWidget/FadeInImage/node1_base.dart b/lib/views/widgets/StatelessWidget/FadeInImage/node1_base.dart index 447191e..7ff1738 100644 --- a/lib/views/widgets/StatelessWidget/FadeInImage/node1_base.dart +++ b/lib/views/widgets/StatelessWidget/FadeInImage/node1_base.dart @@ -23,7 +23,7 @@ import 'package:flutter/material.dart'; class CustomFadeInImage extends StatelessWidget { @override Widget build(BuildContext context) { - var placeholder = "assets/images/icon_head.png"; + var placeholder = "assets/images/icon_head.webp"; var img = "https://user-gold-cdn.xitu.io/2017/8/24/" "d324efef8cbee6468a018aad7ab2ba6b?imageView2/" diff --git a/lib/views/widgets/StatelessWidget/FlutterLogo/node1_base.dart b/lib/views/widgets/StatelessWidget/FlutterLogo/node1_base.dart index fae2963..fe426b7 100644 --- a/lib/views/widgets/StatelessWidget/FlutterLogo/node1_base.dart +++ b/lib/views/widgets/StatelessWidget/FlutterLogo/node1_base.dart @@ -26,7 +26,7 @@ class CustomFlutterLogo extends StatelessWidget { children: data.keys .map((e) => FlutterLogo( size: data[e], - colors: e, + textColor: e, )) .toList(), ); diff --git a/lib/views/widgets/StatelessWidget/GestureDetector/node1_base.dart b/lib/views/widgets/StatelessWidget/GestureDetector/node1_base.dart index e9f2dfc..040abfd 100644 --- a/lib/views/widgets/StatelessWidget/GestureDetector/node1_base.dart +++ b/lib/views/widgets/StatelessWidget/GestureDetector/node1_base.dart @@ -15,8 +15,8 @@ import 'package:flutter/material.dart'; // "subtitle": // "【child】 : 子组件 【Widget】\n" // "【onTap】 : 点击事件 【Function()】\n" -// "【onDoubleTap】 : 双击事件 【Function()】\n" -// "【onLongPress】 : 长按事件 【Function()】", +// "【onDoubleTap】 : 双击事件 【GestureTapCallback】\n" +// "【onLongPress】 : 长按事件 【GestureLongPressCallback】", // } class CustomGestureDetector extends StatefulWidget { diff --git a/lib/views/widgets/StatelessWidget/GestureDetector/node2_tap.dart b/lib/views/widgets/StatelessWidget/GestureDetector/node2_tap.dart index b2e6242..2d36002 100644 --- a/lib/views/widgets/StatelessWidget/GestureDetector/node2_tap.dart +++ b/lib/views/widgets/StatelessWidget/GestureDetector/node2_tap.dart @@ -9,9 +9,9 @@ import 'package:flutter/material.dart'; // "name": 'GestureDetector详情信息', // "priority": 2, // "subtitle": -// "【onTapDown】 : 按下回调 【Function(TapDownDetails)】\n" -// "【onTapUp】 : 子组件 【Function(TapUpDetails)】\n" -// "【onTapCancel】 : 点击取消 【Function()】", +// "【onTapDown】 : 按下回调 【GestureTapDownCallback】\n" +// "【onTapUp】 : 点击抬起回调 【GestureTapUpCallback】\n" +// "【onTapCancel】 : 点击取消 【GestureTapCancelCallback】", // } class TapGestureDetector extends StatefulWidget { @override diff --git a/lib/views/widgets/StatelessWidget/GestureDetector/node3_pan.dart b/lib/views/widgets/StatelessWidget/GestureDetector/node3_pan.dart index ab62bfe..d4989fa 100644 --- a/lib/views/widgets/StatelessWidget/GestureDetector/node3_pan.dart +++ b/lib/views/widgets/StatelessWidget/GestureDetector/node3_pan.dart @@ -9,11 +9,11 @@ import 'package:flutter/material.dart'; // "name": 'GestureDetector的Pan事件', // "priority": 3, // "subtitle": -// "【onPanDown】 : 按下回调 【Function(DragDownDetails)】\n" -// "【onPanEnd】 : 拖动结束 【Function(DragEndDetails)】\n" -// "【onPanStart】 : 开始拖动 【Function(DragStartDetails)】\n" -// "【onPanUpdate】 : 拖动更新 【Function(TapUpDetails)】\n" -// "【onPanCancel】 : 拖动取消 【Function()】", +// "【onPanDown】 : 按下回调 【GestureDragDownCallback】\n" +// "【onPanEnd】 : 拖动结束 【GestureDragEndCallback】\n" +// "【onPanStart】 : 开始拖动 【GestureDragStartCallback】\n" +// "【onPanUpdate】 : 拖动更新 【GestureDragUpdateCallback】\n" +// "【onPanCancel】 : 拖动取消 【GestureDragCancelCallback】", // } class PanGestureDetector extends StatefulWidget { @override diff --git a/lib/views/widgets/StatelessWidget/GridPaper/node1_base.dart b/lib/views/widgets/StatelessWidget/GridPaper/node1_base.dart index 045818d..e4bdb81 100644 --- a/lib/views/widgets/StatelessWidget/GridPaper/node1_base.dart +++ b/lib/views/widgets/StatelessWidget/GridPaper/node1_base.dart @@ -22,7 +22,7 @@ class CustomGridPage extends StatelessWidget { color: Colors.red, interval: 50, child: Image.asset( - "assets/images/wy_300x200.jpg", + "assets/images/wy_300x200.webp", fit: BoxFit.cover, ))); } diff --git a/lib/views/widgets/StatelessWidget/GridPaper/node2_divisions.dart b/lib/views/widgets/StatelessWidget/GridPaper/node2_divisions.dart index fba4cc6..14b4d01 100644 --- a/lib/views/widgets/StatelessWidget/GridPaper/node2_divisions.dart +++ b/lib/views/widgets/StatelessWidget/GridPaper/node2_divisions.dart @@ -24,7 +24,7 @@ class DivisionsGridPage extends StatelessWidget { divisions: 4, subdivisions: 4, child: Image.asset( - "assets/images/wy_300x200.jpg", + "assets/images/wy_300x200.webp", fit: BoxFit.cover, ))); } diff --git a/lib/views/widgets/StatelessWidget/GridTile/node1_base.dart b/lib/views/widgets/StatelessWidget/GridTile/node1_base.dart index 576bf25..f3085d5 100644 --- a/lib/views/widgets/StatelessWidget/GridTile/node1_base.dart +++ b/lib/views/widgets/StatelessWidget/GridTile/node1_base.dart @@ -25,7 +25,7 @@ class CustomGridTile extends StatelessWidget { color: Colors.red, ), leading: CircleAvatar( - backgroundImage: AssetImage("assets/images/wy_200x300.jpg"), + backgroundImage: AssetImage("assets/images/wy_200x300.webp"), ), title: Text("百里·巫缨"), subtitle: Text("倾国必倾城"), @@ -33,7 +33,7 @@ class CustomGridTile extends StatelessWidget { child: Opacity( opacity: 0.5, child: Image.asset( - "assets/images/sabar.jpg", + "assets/images/sabar.webp", fit: BoxFit.cover, ), ), diff --git a/lib/views/widgets/StatelessWidget/GridTileBar/node1_base.dart b/lib/views/widgets/StatelessWidget/GridTileBar/node1_base.dart index 6e95d79..eb6658d 100644 --- a/lib/views/widgets/StatelessWidget/GridTileBar/node1_base.dart +++ b/lib/views/widgets/StatelessWidget/GridTileBar/node1_base.dart @@ -27,7 +27,7 @@ class CustomGridTileBar extends StatelessWidget { color: Colors.red, ), leading: CircleAvatar( - backgroundImage: AssetImage("assets/images/wy_200x300.jpg"), + backgroundImage: AssetImage("assets/images/wy_200x300.webp"), ), title: Text("百里·巫缨"), subtitle: Text("倾国必倾城"), diff --git a/lib/views/widgets/StatelessWidget/Icon/node2_diy.dart b/lib/views/widgets/StatelessWidget/Icon/node2_diy.dart index 8651fea..cd0cb24 100644 --- a/lib/views/widgets/StatelessWidget/Icon/node2_diy.dart +++ b/lib/views/widgets/StatelessWidget/Icon/node2_diy.dart @@ -1,5 +1,5 @@ import 'package:flutter/material.dart'; -import '../../../../app/style/TolyIcon.dart'; +import '../../../../app/res/toly_icon.dart'; /// create by 张风捷特烈 on 2020/4/27 /// contact me by email 1981462002@qq.com diff --git a/lib/views/widgets/StatelessWidget/ImageIcon/node1_base.dart b/lib/views/widgets/StatelessWidget/ImageIcon/node1_base.dart index 47eee46..a13615c 100644 --- a/lib/views/widgets/StatelessWidget/ImageIcon/node1_base.dart +++ b/lib/views/widgets/StatelessWidget/ImageIcon/node1_base.dart @@ -25,7 +25,7 @@ class CustomImageIcon extends StatelessWidget { spacing: 10, children: data.keys .map((e) => ImageIcon( - AssetImage("assets/images/leaf.png"), + AssetImage("assets/images/leaf.webp"), color: e, size: data[e], )) diff --git a/lib/views/widgets/StatelessWidget/InputChip/node1_base.dart b/lib/views/widgets/StatelessWidget/InputChip/node1_base.dart index 3b80bda..c4d4beb 100644 --- a/lib/views/widgets/StatelessWidget/InputChip/node1_base.dart +++ b/lib/views/widgets/StatelessWidget/InputChip/node1_base.dart @@ -29,7 +29,7 @@ class _PressInputChipState extends State { "This is a InputChip." : "You are clicked delete icon."), backgroundColor: Colors.grey.withAlpha(66), - avatar: Image.asset("assets/images/icon_head.png"), + avatar: Image.asset("assets/images/icon_head.webp"), selectedColor: Colors.orangeAccent.withAlpha(88), selectedShadowColor: Colors.blue, shadowColor: Colors.orangeAccent, diff --git a/lib/views/widgets/StatelessWidget/InputChip/node2_select.dart b/lib/views/widgets/StatelessWidget/InputChip/node2_select.dart index 64b33fd..ed4bcfa 100644 --- a/lib/views/widgets/StatelessWidget/InputChip/node2_select.dart +++ b/lib/views/widgets/StatelessWidget/InputChip/node2_select.dart @@ -29,7 +29,7 @@ class _SelectInputChipState extends State { labelPadding: EdgeInsets.all(3), label: Text("This is a InputChip."), backgroundColor: Colors.grey.withAlpha(66), - avatar: Image.asset("assets/images/icon_head.png"), + avatar: Image.asset("assets/images/icon_head.webp"), selectedColor: Colors.orangeAccent.withAlpha(88), selectedShadowColor: Colors.blue, shadowColor: Colors.orangeAccent, diff --git a/lib/views/widgets/StatelessWidget/ListTile/node1_base.dart b/lib/views/widgets/StatelessWidget/ListTile/node1_base.dart index 01c41b3..7e8417e 100644 --- a/lib/views/widgets/StatelessWidget/ListTile/node1_base.dart +++ b/lib/views/widgets/StatelessWidget/ListTile/node1_base.dart @@ -22,7 +22,7 @@ class CustomListTile extends StatelessWidget { margin: EdgeInsets.all(10), color: Colors.grey.withAlpha(22), child: ListTile( - leading: Image.asset("assets/images/icon_head.png"), + leading: Image.asset("assets/images/icon_head.webp"), title: Text("以梦为马"), subtitle: Text("海子"), contentPadding: EdgeInsets.all(5), diff --git a/lib/views/widgets/StatelessWidget/ListTile/node2_select.dart b/lib/views/widgets/StatelessWidget/ListTile/node2_select.dart index 127a10a..fa8f8f0 100644 --- a/lib/views/widgets/StatelessWidget/ListTile/node2_select.dart +++ b/lib/views/widgets/StatelessWidget/ListTile/node2_select.dart @@ -25,7 +25,7 @@ class _SelectListTileState extends State { margin: EdgeInsets.all(10), color: Colors.grey.withAlpha(22), child: ListTile( - leading: Image.asset("assets/images/icon_head.png"), + leading: Image.asset("assets/images/icon_head.webp"), selected: _selected, title: Text("以梦为马"), subtitle: Text("海子"), diff --git a/lib/views/widgets/StatelessWidget/ListTile/node3_dense.dart b/lib/views/widgets/StatelessWidget/ListTile/node3_dense.dart index baf7e38..bb67d12 100644 --- a/lib/views/widgets/StatelessWidget/ListTile/node3_dense.dart +++ b/lib/views/widgets/StatelessWidget/ListTile/node3_dense.dart @@ -24,7 +24,7 @@ class _DenseListTileState extends State { margin: EdgeInsets.all(10), color: Colors.grey.withAlpha(22), child: ListTile( - leading: Image.asset("assets/images/icon_head.png"), + leading: Image.asset("assets/images/icon_head.webp"), title: Text("以梦为马"), subtitle: Text("海子"), selected: false, diff --git a/lib/views/widgets/StatelessWidget/ListView/node1_base.dart b/lib/views/widgets/StatelessWidget/ListView/node1_base.dart index 457db7a..0d417a6 100644 --- a/lib/views/widgets/StatelessWidget/ListView/node1_base.dart +++ b/lib/views/widgets/StatelessWidget/ListView/node1_base.dart @@ -9,7 +9,7 @@ import 'package:flutter/material.dart'; // "priority": 1, // "subtitle": // "【children】 : 子组件列表 【List】\n" -// "【padding】 : 点击事件 【EdgeInsetsGeometry】", +// "【padding】 : 内边距 【EdgeInsetsGeometry】", // } class CustomListView extends StatelessWidget { final data = [ diff --git a/lib/views/widgets/StatelessWidget/RadioListTile/node1_base.dart b/lib/views/widgets/StatelessWidget/RadioListTile/node1_base.dart index 80978d0..7687994 100644 --- a/lib/views/widgets/StatelessWidget/RadioListTile/node1_base.dart +++ b/lib/views/widgets/StatelessWidget/RadioListTile/node1_base.dart @@ -39,11 +39,11 @@ class CustomRadioListTile extends StatefulWidget { class _CustomRadioListTileState extends State { final Map languages = { ItemType.java: - ItemBean("Java", "曾经世界上最流行的语言", "assets/images/java.jpeg"), + ItemBean("Java", "曾经世界上最流行的语言", "assets/images/java.webp"), ItemType.kotlin: - ItemBean("Kotlin", "未来世界上最流行的语言", "assets/images/kotlin.jpg"), + ItemBean("Kotlin", "未来世界上最流行的语言", "assets/images/kotlin.webp"), ItemType.dart: - ItemBean("Dart", "世界上最优雅的语言", "assets/images/dart.jpg"), + ItemBean("Dart", "世界上最优雅的语言", "assets/images/dart.webp"), }; var _type = ItemType.java; diff --git a/lib/views/widgets/StatelessWidget/RadioListTile/node2_dense.dart b/lib/views/widgets/StatelessWidget/RadioListTile/node2_dense.dart index 5611535..df7b743 100644 --- a/lib/views/widgets/StatelessWidget/RadioListTile/node2_dense.dart +++ b/lib/views/widgets/StatelessWidget/RadioListTile/node2_dense.dart @@ -34,11 +34,11 @@ class DenseRadioListTile extends StatefulWidget { class _DenseRadioListTileState extends State { final Map languages = { ItemType.java: - ItemBean("Java", "曾经世界上最流行的语言", "assets/images/java.jpeg"), + ItemBean("Java", "曾经世界上最流行的语言", "assets/images/java.webp"), ItemType.kotlin: - ItemBean("Kotlin", "未来世界上最流行的语言", "assets/images/kotlin.jpg"), + ItemBean("Kotlin", "未来世界上最流行的语言", "assets/images/kotlin.webp"), ItemType.dart: - ItemBean("Dart", "世界上最优雅的语言", "assets/images/dart.jpg"), + ItemBean("Dart", "世界上最优雅的语言", "assets/images/dart.webp"), }; var _type = ItemType.java; diff --git a/lib/views/widgets/StatelessWidget/SimpleDialog/node1_base.dart b/lib/views/widgets/StatelessWidget/SimpleDialog/node1_base.dart index 2ffcf48..f566d99 100644 --- a/lib/views/widgets/StatelessWidget/SimpleDialog/node1_base.dart +++ b/lib/views/widgets/StatelessWidget/SimpleDialog/node1_base.dart @@ -1,4 +1,3 @@ -import 'dart:math'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; @@ -103,7 +102,7 @@ class CustomSimpleDialog extends StatelessWidget { //标题 children: [ Image.asset( - "assets/images/icon_head.png", + "assets/images/icon_head.webp", width: 30, height: 30, ), diff --git a/lib/views/widgets/StatelessWidget/SingleChildScrollView/node1_base.dart b/lib/views/widgets/StatelessWidget/SingleChildScrollView/node1_base.dart index 501935f..d6bc4fd 100644 --- a/lib/views/widgets/StatelessWidget/SingleChildScrollView/node1_base.dart +++ b/lib/views/widgets/StatelessWidget/SingleChildScrollView/node1_base.dart @@ -10,7 +10,7 @@ import 'package:flutter/material.dart'; // "priority": 1, // "subtitle": // "【child】 : 子组件 【Widget】\n" -// "【padding】 : 点击事件 【EdgeInsetsGeometry】", +// "【padding】 : 内边距 【EdgeInsetsGeometry】", // } class CustomSingleChildScrollView extends StatelessWidget { final data = [ diff --git a/lib/views/widgets/StatelessWidget/SwitchListTile/node1_base.dart b/lib/views/widgets/StatelessWidget/SwitchListTile/node1_base.dart index d588c06..2a53db2 100644 --- a/lib/views/widgets/StatelessWidget/SwitchListTile/node1_base.dart +++ b/lib/views/widgets/StatelessWidget/SwitchListTile/node1_base.dart @@ -35,7 +35,7 @@ class _CustomSwitchListTileState extends State { inactiveTrackColor: Colors.blue.withAlpha(88), activeColor: Colors.orangeAccent, activeTrackColor: Colors.orange, - secondary: Image.asset("assets/images/icon_head.png"), + secondary: Image.asset("assets/images/icon_head.webp"), title: Text("张风捷特烈"), subtitle: Text("@万花过尽知无物"), onChanged: (v) => setState(() => _value = !_value), diff --git a/lib/views/widgets/StatelessWidget/SwitchListTile/node2_select.dart b/lib/views/widgets/StatelessWidget/SwitchListTile/node2_select.dart index 3edd0c3..2b3a1cf 100644 --- a/lib/views/widgets/StatelessWidget/SwitchListTile/node2_select.dart +++ b/lib/views/widgets/StatelessWidget/SwitchListTile/node2_select.dart @@ -29,9 +29,9 @@ class _SelectSwitchListTileState extends State { value: _value, selected: _value, activeColor: Colors.orangeAccent, - secondary: Image.asset("assets/images/icon_head.png"), + secondary: Image.asset("assets/images/icon_head.webp"), inactiveThumbImage: AssetImage("assets/images/pica.gif"), - activeThumbImage: AssetImage("assets/images/icon_head.png"), + activeThumbImage: AssetImage("assets/images/icon_head.webp"), title: Text("张风捷特烈"), subtitle: Text("@万花过尽知无物"), onChanged: (v) => setState(() => _value = !_value), diff --git a/lib/views/widgets/StatelessWidget/SwitchListTile/node3_dense.dart b/lib/views/widgets/StatelessWidget/SwitchListTile/node3_dense.dart index 94010c3..29d84b5 100644 --- a/lib/views/widgets/StatelessWidget/SwitchListTile/node3_dense.dart +++ b/lib/views/widgets/StatelessWidget/SwitchListTile/node3_dense.dart @@ -28,7 +28,7 @@ class _DenseSwitchListTileState extends State { dense: true, selected: _value, activeColor: Colors.orangeAccent, - secondary: Image.asset("assets/images/icon_head.png"), + secondary: Image.asset("assets/images/icon_head.webp"), title: Text("张风捷特烈"), subtitle: Text("@万花过尽知无物"), onChanged: (v) => setState(() => _value = !_value), diff --git a/lib/views/widgets/StatelessWidget/TabBar/no_shadow_tab_bar.dart b/lib/views/widgets/StatelessWidget/TabBar/no_shadow_tab_bar.dart deleted file mode 100644 index a1ae1ae..0000000 --- a/lib/views/widgets/StatelessWidget/TabBar/no_shadow_tab_bar.dart +++ /dev/null @@ -1,1345 +0,0 @@ -/// create by 张风捷特烈 on 2020-03-16 -/// contact me by email 1981462002@qq.com -/// 说明: - -// Copyright 2015 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -import 'dart:async'; -import 'dart:ui' show lerpDouble; - -import 'package:flutter/material.dart'; -import 'package:flutter/rendering.dart'; -import 'package:flutter/widgets.dart'; -import 'package:flutter/gestures.dart' show DragStartBehavior; - - -const double _kTabHeight = 46.0; -const double _kTextAndIconTabHeight = 72.0; - -/// Defines how the bounds of the selected tab indicator are computed. -/// -/// See also: -/// -/// * [TabBar], which displays a row of tabs. -/// * [TabBarView], which displays a widget for the currently selected tab. -/// * [TabBar.indicator], which defines the appearance of the selected tab -/// indicator relative to the tab's bounds. -enum TabBarIndicatorSize { - /// The tab indicator's bounds are as wide as the space occupied by the tab - /// in the tab bar: from the right edge of the previous tab to the left edge - /// of the next tab. - tab, - - /// The tab's bounds are only as wide as the (centered) tab widget itself. - /// - /// This value is used to align the tab's label, typically a [Tab] - /// widget's text or icon, with the selected tab indicator. - label, -} - -class _TabStyle extends AnimatedWidget { - const _TabStyle({ - Key key, - Animation animation, - this.selected, - this.labelColor, - this.unselectedLabelColor, - this.labelStyle, - this.unselectedLabelStyle, - @required this.child, - }) : super(key: key, listenable: animation); - - final TextStyle labelStyle; - final TextStyle unselectedLabelStyle; - final bool selected; - final Color labelColor; - final Color unselectedLabelColor; - final Widget child; - - @override - Widget build(BuildContext context) { - final ThemeData themeData = Theme.of(context); - final TabBarTheme tabBarTheme = TabBarTheme.of(context); - final Animation animation = listenable; - - // To enable TextStyle.lerp(style1, style2, value), both styles must have - // the same value of inherit. Force that to be inherit=true here. - final TextStyle defaultStyle = (labelStyle - ?? tabBarTheme.labelStyle - ?? themeData.primaryTextTheme.body2 - ).copyWith(inherit: true); - final TextStyle defaultUnselectedStyle = (unselectedLabelStyle - ?? tabBarTheme.unselectedLabelStyle - ?? labelStyle - ?? themeData.primaryTextTheme.body2 - ).copyWith(inherit: true); - final TextStyle textStyle = selected - ? TextStyle.lerp(defaultStyle, defaultUnselectedStyle, animation.value) - : TextStyle.lerp(defaultUnselectedStyle, defaultStyle, animation.value); - - final Color selectedColor = labelColor - ?? tabBarTheme.labelColor - ?? themeData.primaryTextTheme.body2.color; - final Color unselectedColor = unselectedLabelColor - ?? tabBarTheme.unselectedLabelColor - ?? selectedColor.withAlpha(0xB2); // 70% alpha - final Color color = selected - ? Color.lerp(selectedColor, unselectedColor, animation.value) - : Color.lerp(unselectedColor, selectedColor, animation.value); - - return DefaultTextStyle( - style: textStyle.copyWith(color: color), - child: IconTheme.merge( - data: IconThemeData( - size: 24.0, - color: color, - ), - child: child, - ), - ); - } -} - -typedef _LayoutCallback = void Function(List xOffsets, TextDirection textDirection, double width); - -class _TabLabelBarRenderer extends RenderFlex { - _TabLabelBarRenderer({ - List children, - @required Axis direction, - @required MainAxisSize mainAxisSize, - @required MainAxisAlignment mainAxisAlignment, - @required CrossAxisAlignment crossAxisAlignment, - @required TextDirection textDirection, - @required VerticalDirection verticalDirection, - @required this.onPerformLayout, - }) : assert(onPerformLayout != null), - assert(textDirection != null), - super( - children: children, - direction: direction, - mainAxisSize: mainAxisSize, - mainAxisAlignment: mainAxisAlignment, - crossAxisAlignment: crossAxisAlignment, - textDirection: textDirection, - verticalDirection: verticalDirection, - ); - - _LayoutCallback onPerformLayout; - - @override - void performLayout() { - super.performLayout(); - // xOffsets will contain childCount+1 values, giving the offsets of the - // leading edge of the first tab as the first value, of the leading edge of - // the each subsequent tab as each subsequent value, and of the trailing - // edge of the last tab as the last value. - RenderBox child = firstChild; - final List xOffsets = []; - while (child != null) { - final FlexParentData childParentData = child.parentData; - xOffsets.add(childParentData.offset.dx); - assert(child.parentData == childParentData); - child = childParentData.nextSibling; - } - assert(textDirection != null); - switch (textDirection) { - case TextDirection.rtl: - xOffsets.insert(0, size.width); - break; - case TextDirection.ltr: - xOffsets.add(size.width); - break; - } - onPerformLayout(xOffsets, textDirection, size.width); - } -} - -// This class and its renderer class only exist to report the widths of the tabs -// upon layout. The tab widths are only used at paint time (see _IndicatorPainter) -// or in response to input. -class _TabLabelBar extends Flex { - _TabLabelBar({ - Key key, - List children = const [], - this.onPerformLayout, - }) : super( - key: key, - children: children, - direction: Axis.horizontal, - mainAxisSize: MainAxisSize.max, - mainAxisAlignment: MainAxisAlignment.start, - crossAxisAlignment: CrossAxisAlignment.center, - verticalDirection: VerticalDirection.down, - ); - - final _LayoutCallback onPerformLayout; - - @override - RenderFlex createRenderObject(BuildContext context) { - return _TabLabelBarRenderer( - direction: direction, - mainAxisAlignment: mainAxisAlignment, - mainAxisSize: mainAxisSize, - crossAxisAlignment: crossAxisAlignment, - textDirection: getEffectiveTextDirection(context), - verticalDirection: verticalDirection, - onPerformLayout: onPerformLayout, - ); - } - - @override - void updateRenderObject(BuildContext context, _TabLabelBarRenderer renderObject) { - super.updateRenderObject(context, renderObject); - renderObject.onPerformLayout = onPerformLayout; - } -} - -double _indexChangeProgress(TabController controller) { - final double controllerValue = controller.animation.value; - final double previousIndex = controller.previousIndex.toDouble(); - final double currentIndex = controller.index.toDouble(); - - // The controller's offset is changing because the user is dragging the - // TabBarView's PageView to the left or right. - if (!controller.indexIsChanging) - return (currentIndex - controllerValue).abs().clamp(0.0, 1.0); - - // The TabController animation's value is changing from previousIndex to currentIndex. - return (controllerValue - currentIndex).abs() / (currentIndex - previousIndex).abs(); -} - -class _IndicatorPainter extends CustomPainter { - _IndicatorPainter({ - @required this.controller, - @required this.indicator, - @required this.indicatorSize, - @required this.tabKeys, - _IndicatorPainter old, - }) : assert(controller != null), - assert(indicator != null), - super(repaint: controller.animation) { - if (old != null) - saveTabOffsets(old._currentTabOffsets, old._currentTextDirection); - } - - final TabController controller; - final Decoration indicator; - final TabBarIndicatorSize indicatorSize; - final List tabKeys; - - List _currentTabOffsets; - TextDirection _currentTextDirection; - Rect _currentRect; - BoxPainter _painter; - bool _needsPaint = false; - void markNeedsPaint() { - _needsPaint = true; - } - - void dispose() { - _painter?.dispose(); - } - - void saveTabOffsets(List tabOffsets, TextDirection textDirection) { - _currentTabOffsets = tabOffsets; - _currentTextDirection = textDirection; - } - - // _currentTabOffsets[index] is the offset of the start edge of the tab at index, and - // _currentTabOffsets[_currentTabOffsets.length] is the end edge of the last tab. - int get maxTabIndex => _currentTabOffsets.length - 2; - - double centerOf(int tabIndex) { - assert(_currentTabOffsets != null); - assert(_currentTabOffsets.isNotEmpty); - assert(tabIndex >= 0); - assert(tabIndex <= maxTabIndex); - return (_currentTabOffsets[tabIndex] + _currentTabOffsets[tabIndex + 1]) / 2.0; - } - - Rect indicatorRect(Size tabBarSize, int tabIndex) { - assert(_currentTabOffsets != null); - assert(_currentTextDirection != null); - assert(_currentTabOffsets.isNotEmpty); - assert(tabIndex >= 0); - assert(tabIndex <= maxTabIndex); - double tabLeft, tabRight; - switch (_currentTextDirection) { - case TextDirection.rtl: - tabLeft = _currentTabOffsets[tabIndex + 1]; - tabRight = _currentTabOffsets[tabIndex]; - break; - case TextDirection.ltr: - tabLeft = _currentTabOffsets[tabIndex]; - tabRight = _currentTabOffsets[tabIndex + 1]; - break; - } - - if (indicatorSize == TabBarIndicatorSize.label) { - final double tabWidth = tabKeys[tabIndex].currentContext.size.width; - final double delta = ((tabRight - tabLeft) - tabWidth) / 2.0; - tabLeft += delta; - tabRight -= delta; - } - - return Rect.fromLTWH(tabLeft, 0.0, tabRight - tabLeft, tabBarSize.height); - } - - @override - void paint(Canvas canvas, Size size) { - _needsPaint = false; - _painter ??= indicator.createBoxPainter(markNeedsPaint); - - if (controller.indexIsChanging) { - // The user tapped on a tab, the tab controller's animation is running. - final Rect targetRect = indicatorRect(size, controller.index); - _currentRect = Rect.lerp(targetRect, _currentRect ?? targetRect, _indexChangeProgress(controller)); - } else { - // The user is dragging the TabBarView's PageView left or right. - final int currentIndex = controller.index; - final Rect previous = currentIndex > 0 ? indicatorRect(size, currentIndex - 1) : null; - final Rect middle = indicatorRect(size, currentIndex); - final Rect next = currentIndex < maxTabIndex ? indicatorRect(size, currentIndex + 1) : null; - final double index = controller.index.toDouble(); - final double value = controller.animation.value; - if (value == index - 1.0) - _currentRect = previous ?? middle; - else if (value == index + 1.0) - _currentRect = next ?? middle; - else if (value == index) - _currentRect = middle; - else if (value < index) - _currentRect = previous == null ? middle : Rect.lerp(middle, previous, index - value); - else - _currentRect = next == null ? middle : Rect.lerp(middle, next, value - index); - } - assert(_currentRect != null); - - final ImageConfiguration configuration = ImageConfiguration( - size: _currentRect.size, - textDirection: _currentTextDirection, - ); - _painter.paint(canvas, _currentRect.topLeft, configuration); - } - - static bool _tabOffsetsEqual(List a, List b) { - // TODO(shihaohong): The following null check should be replaced when a fix - // for https://github.com/flutter/flutter/issues/40014 is available. - if (a == null || b == null || a.length != b.length) - return false; - for (int i = 0; i < a.length; i += 1) { - if (a[i] != b[i]) - return false; - } - return true; - } - - @override - bool shouldRepaint(_IndicatorPainter old) { - return _needsPaint - || controller != old.controller - || indicator != old.indicator - || tabKeys.length != old.tabKeys.length - || (!_tabOffsetsEqual(_currentTabOffsets, old._currentTabOffsets)) - || _currentTextDirection != old._currentTextDirection; - } -} - -class _ChangeAnimation extends Animation with AnimationWithParentMixin { - _ChangeAnimation(this.controller); - - final TabController controller; - - @override - Animation get parent => controller.animation; - - @override - void removeStatusListener(AnimationStatusListener listener) { - if (parent != null) - super.removeStatusListener(listener); - } - - @override - void removeListener(VoidCallback listener) { - if (parent != null) - super.removeListener(listener); - } - - @override - double get value => _indexChangeProgress(controller); -} - -class _DragAnimation extends Animation with AnimationWithParentMixin { - _DragAnimation(this.controller, this.index); - - final TabController controller; - final int index; - - @override - Animation get parent => controller.animation; - - @override - void removeStatusListener(AnimationStatusListener listener) { - if (parent != null) - super.removeStatusListener(listener); - } - - @override - void removeListener(VoidCallback listener) { - if (parent != null) - super.removeListener(listener); - } - - @override - double get value { - assert(!controller.indexIsChanging); - return (controller.animation.value - index.toDouble()).abs().clamp(0.0, 1.0); - } -} - -// This class, and TabBarScrollController, only exist to handle the case -// where a scrollable TabBar has a non-zero initialIndex. In that case we can -// only compute the scroll position's initial scroll offset (the "correct" -// pixels value) after the TabBar viewport width and scroll limits are known. -class _TabBarScrollPosition extends ScrollPositionWithSingleContext { - _TabBarScrollPosition({ - ScrollPhysics physics, - ScrollContext context, - ScrollPosition oldPosition, - this.tabBar, - }) : super( - physics: physics, - context: context, - initialPixels: null, - oldPosition: oldPosition, - ); - - final _TabBarState tabBar; - - bool _initialViewportDimensionWasZero; - - @override - bool applyContentDimensions(double minScrollExtent, double maxScrollExtent) { - bool result = true; - if (_initialViewportDimensionWasZero != true) { - // If the viewport never had a non-zero dimension, we just want to jump - // to the initial scroll position to avoid strange scrolling effects in - // release mode: In release mode, the viewport temporarily may have a - // dimension of zero before the actual dimension is calculated. In that - // scenario, setting the actual dimension would cause a strange scroll - // effect without this guard because the super call below would starts a - // ballistic scroll activity. - assert(viewportDimension != null); - _initialViewportDimensionWasZero = viewportDimension != 0.0; - correctPixels(tabBar._initialScrollOffset(viewportDimension, minScrollExtent, maxScrollExtent)); - result = false; - } - return super.applyContentDimensions(minScrollExtent, maxScrollExtent) && result; - } -} - -// This class, and TabBarScrollPosition, only exist to handle the case -// where a scrollable TabBar has a non-zero initialIndex. -class _TabBarScrollController extends ScrollController { - _TabBarScrollController(this.tabBar); - - final _TabBarState tabBar; - - @override - ScrollPosition createScrollPosition(ScrollPhysics physics, ScrollContext context, ScrollPosition oldPosition) { - return _TabBarScrollPosition( - physics: physics, - context: context, - oldPosition: oldPosition, - tabBar: tabBar, - ); - } -} - -/// A material design widget that displays a horizontal row of tabs. -/// -/// Typically created as the [AppBar.bottom] part of an [AppBar] and in -/// conjunction with a [TabBarView]. -/// -/// If a [TabController] is not provided, then a [DefaultTabController] ancestor -/// must be provided instead. The tab controller's [TabController.length] must -/// equal the length of the [tabs] list and the length of the -/// [TabBarView.children] list. -/// -/// Requires one of its ancestors to be a [Material] widget. -/// -/// Uses values from [TabBarTheme] if it is set in the current context. -/// -/// To see a sample implementation, visit the [TabController] documentation. -/// -/// See also: -/// -/// * [TabBarView], which displays page views that correspond to each tab. -class NoShadowTabBar extends StatefulWidget implements PreferredSizeWidget { - /// Creates a material design tab bar. - /// - /// The [tabs] argument must not be null and its length must match the [controller]'s - /// [TabController.length]. - /// - /// If a [TabController] is not provided, then there must be a - /// [DefaultTabController] ancestor. - /// - /// The [indicatorWeight] parameter defaults to 2, and must not be null. - /// - /// The [indicatorPadding] parameter defaults to [EdgeInsets.zero], and must not be null. - /// - /// If [indicator] is not null, then [indicatorWeight], [indicatorPadding], and - /// [indicatorColor] are ignored. - const NoShadowTabBar({ - Key key, - @required this.tabs, - this.controller, - this.isScrollable = false, - this.indicatorColor, - this.indicatorWeight = 2.0, - this.indicatorPadding = EdgeInsets.zero, - this.indicator, - this.indicatorSize, - this.labelColor, - this.labelStyle, - this.labelPadding, - this.unselectedLabelColor, - this.unselectedLabelStyle, - this.dragStartBehavior = DragStartBehavior.start, - this.onTap, - }) : assert(tabs != null), - assert(isScrollable != null), - assert(dragStartBehavior != null), - assert(indicator != null || (indicatorWeight != null && indicatorWeight > 0.0)), - assert(indicator != null || (indicatorPadding != null)), - super(key: key); - - /// Typically a list of two or more [Tab] widgets. - /// - /// The length of this list must match the [controller]'s [TabController.length] - /// and the length of the [TabBarView.children] list. - final List tabs; - - /// This widget's selection and animation state. - /// - /// If [TabController] is not provided, then the value of [DefaultTabController.of] - /// will be used. - final TabController controller; - - /// Whether this tab bar can be scrolled horizontally. - /// - /// If [isScrollable] is true, then each tab is as wide as needed for its label - /// and the entire [TabBar] is scrollable. Otherwise each tab gets an equal - /// share of the available space. - final bool isScrollable; - - /// The color of the line that appears below the selected tab. - /// - /// If this parameter is null, then the value of the Theme's indicatorColor - /// property is used. - /// - /// If [indicator] is specified, this property is ignored. - final Color indicatorColor; - - /// The thickness of the line that appears below the selected tab. - /// - /// The value of this parameter must be greater than zero and its default - /// value is 2.0. - /// - /// If [indicator] is specified, this property is ignored. - final double indicatorWeight; - - /// The horizontal padding for the line that appears below the selected tab. - /// - /// For [isScrollable] tab bars, specifying [kTabLabelPadding] will align - /// the indicator with the tab's text for [Tab] widgets and all but the - /// shortest [Tab.text] values. - /// - /// The [EdgeInsets.top] and [EdgeInsets.bottom] values of the - /// [indicatorPadding] are ignored. - /// - /// The default value of [indicatorPadding] is [EdgeInsets.zero]. - /// - /// If [indicator] is specified, this property is ignored. - final EdgeInsetsGeometry indicatorPadding; - - /// Defines the appearance of the selected tab indicator. - /// - /// If [indicator] is specified, the [indicatorColor], [indicatorWeight], - /// and [indicatorPadding] properties are ignored. - /// - /// The default, underline-style, selected tab indicator can be defined with - /// [UnderlineTabIndicator]. - /// - /// The indicator's size is based on the tab's bounds. If [indicatorSize] - /// is [TabBarIndicatorSize.tab] the tab's bounds are as wide as the space - /// occupied by the tab in the tab bar. If [indicatorSize] is - /// [TabBarIndicatorSize.label], then the tab's bounds are only as wide as - /// the tab widget itself. - final Decoration indicator; - - /// Defines how the selected tab indicator's size is computed. - /// - /// The size of the selected tab indicator is defined relative to the - /// tab's overall bounds if [indicatorSize] is [TabBarIndicatorSize.tab] - /// (the default) or relative to the bounds of the tab's widget if - /// [indicatorSize] is [TabBarIndicatorSize.label]. - /// - /// The selected tab's location appearance can be refined further with - /// the [indicatorColor], [indicatorWeight], [indicatorPadding], and - /// [indicator] properties. - final TabBarIndicatorSize indicatorSize; - - /// The color of selected tab labels. - /// - /// Unselected tab labels are rendered with the same color rendered at 70% - /// opacity unless [unselectedLabelColor] is non-null. - /// - /// If this parameter is null, then the color of the [ThemeData.primaryTextTheme]'s - /// body2 text color is used. - final Color labelColor; - - /// The color of unselected tab labels. - /// - /// If this property is null, unselected tab labels are rendered with the - /// [labelColor] with 70% opacity. - final Color unselectedLabelColor; - - /// The text style of the selected tab labels. - /// - /// If [unselectedLabelStyle] is null, then this text style will be used for - /// both selected and unselected label styles. - /// - /// If this property is null, then the text style of the - /// [ThemeData.primaryTextTheme]'s body2 definition is used. - final TextStyle labelStyle; - - /// The padding added to each of the tab labels. - /// - /// If this property is null, then kTabLabelPadding is used. - final EdgeInsetsGeometry labelPadding; - - /// The text style of the unselected tab labels - /// - /// If this property is null, then the [labelStyle] value is used. If [labelStyle] - /// is null, then the text style of the [ThemeData.primaryTextTheme]'s - /// body2 definition is used. - final TextStyle unselectedLabelStyle; - - /// {@macro flutter.widgets.scrollable.dragStartBehavior} - final DragStartBehavior dragStartBehavior; - - /// An optional callback that's called when the [TabBar] is tapped. - /// - /// The callback is applied to the index of the tab where the tap occurred. - /// - /// This callback has no effect on the default handling of taps. It's for - /// applications that want to do a little extra work when a tab is tapped, - /// even if the tap doesn't change the TabController's index. TabBar [onTap] - /// callbacks should not make changes to the TabController since that would - /// interfere with the default tap handler. - final ValueChanged onTap; - - /// A size whose height depends on if the tabs have both icons and text. - /// - /// [AppBar] uses this size to compute its own preferred size. - @override - Size get preferredSize { - for (Widget item in tabs) { - if (item is Tab) { - final Tab tab = item; - if (tab.text != null && tab.icon != null) - return Size.fromHeight(_kTextAndIconTabHeight + indicatorWeight); - } - } - return Size.fromHeight(_kTabHeight + indicatorWeight); - } - - @override - _TabBarState createState() => _TabBarState(); -} - -class _TabBarState extends State { - ScrollController _scrollController; - TabController _controller; - _IndicatorPainter _indicatorPainter; - int _currentIndex; - double _tabStripWidth; - List _tabKeys; - - @override - void initState() { - super.initState(); - // If indicatorSize is TabIndicatorSize.label, _tabKeys[i] is used to find - // the width of tab widget i. See _IndicatorPainter.indicatorRect(). - _tabKeys = widget.tabs.map((Widget tab) => GlobalKey()).toList(); - } - - Decoration get _indicator { - if (widget.indicator != null) - return widget.indicator; - final TabBarTheme tabBarTheme = TabBarTheme.of(context); - if (tabBarTheme.indicator != null) - return tabBarTheme.indicator; - - Color color = widget.indicatorColor ?? Theme.of(context).indicatorColor; - // ThemeData tries to avoid this by having indicatorColor avoid being the - // primaryColor. However, it's possible that the tab bar is on a - // Material that isn't the primaryColor. In that case, if the indicator - // color ends up matching the material's color, then this overrides it. - // When that happens, automatic transitions of the theme will likely look - // ugly as the indicator color suddenly snaps to white at one end, but it's - // not clear how to avoid that any further. - // - // The material's color might be null (if it's a transparency). In that case - // there's no good way for us to find out what the color is so we don't. - if (color.value == Material.of(context).color?.value) - color = Colors.white; - - return UnderlineTabIndicator( - insets: widget.indicatorPadding, - borderSide: BorderSide( - width: widget.indicatorWeight, - color: color, - ), - ); - } - - // If the TabBar is rebuilt with a new tab controller, the caller should - // dispose the old one. In that case the old controller's animation will be - // null and should not be accessed. - bool get _controllerIsValid => _controller?.animation != null; - - void _updateTabController() { - final TabController newController = widget.controller ?? DefaultTabController.of(context); - assert(() { - if (newController == null) { - throw FlutterError( - 'No TabController for ${widget.runtimeType}.\n' - 'When creating a ${widget.runtimeType}, you must either provide an explicit ' - 'TabController using the "controller" property, or you must ensure that there ' - 'is a DefaultTabController above the ${widget.runtimeType}.\n' - 'In this case, there was neither an explicit controller nor a default controller.' - ); - } - return true; - }()); - - if (newController == _controller) - return; - - if (_controllerIsValid) { - _controller.animation.removeListener(_handleTabControllerAnimationTick); - _controller.removeListener(_handleTabControllerTick); - } - _controller = newController; - if (_controller != null) { - _controller.animation.addListener(_handleTabControllerAnimationTick); - _controller.addListener(_handleTabControllerTick); - _currentIndex = _controller.index; - } - } - - void _initIndicatorPainter() { - _indicatorPainter = !_controllerIsValid ? null : _IndicatorPainter( - controller: _controller, - indicator: _indicator, - indicatorSize: widget.indicatorSize ?? TabBarTheme.of(context).indicatorSize, - tabKeys: _tabKeys, - old: _indicatorPainter, - ); - } - - @override - void didChangeDependencies() { - super.didChangeDependencies(); - assert(debugCheckHasMaterial(context)); - _updateTabController(); - _initIndicatorPainter(); - } - - @override - void didUpdateWidget(NoShadowTabBar oldWidget) { - super.didUpdateWidget(oldWidget); - if (widget.controller != oldWidget.controller) { - _updateTabController(); - _initIndicatorPainter(); - } else if (widget.indicatorColor != oldWidget.indicatorColor || - widget.indicatorWeight != oldWidget.indicatorWeight || - widget.indicatorSize != oldWidget.indicatorSize || - widget.indicator != oldWidget.indicator) { - _initIndicatorPainter(); - } - - if (widget.tabs.length > oldWidget.tabs.length) { - final int delta = widget.tabs.length - oldWidget.tabs.length; - _tabKeys.addAll(List.generate(delta, (int n) => GlobalKey())); - } else if (widget.tabs.length < oldWidget.tabs.length) { - _tabKeys.removeRange(widget.tabs.length, oldWidget.tabs.length); - } - } - - @override - void dispose() { - _indicatorPainter.dispose(); - if (_controllerIsValid) { - _controller.animation.removeListener(_handleTabControllerAnimationTick); - _controller.removeListener(_handleTabControllerTick); - } - _controller = null; - // We don't own the _controller Animation, so it's not disposed here. - super.dispose(); - } - - int get maxTabIndex => _indicatorPainter.maxTabIndex; - - double _tabScrollOffset(int index, double viewportWidth, double minExtent, double maxExtent) { - if (!widget.isScrollable) - return 0.0; - double tabCenter = _indicatorPainter.centerOf(index); - switch (Directionality.of(context)) { - case TextDirection.rtl: - tabCenter = _tabStripWidth - tabCenter; - break; - case TextDirection.ltr: - break; - } - return (tabCenter - viewportWidth / 2.0).clamp(minExtent, maxExtent); - } - - double _tabCenteredScrollOffset(int index) { - final ScrollPosition position = _scrollController.position; - return _tabScrollOffset(index, position.viewportDimension, position.minScrollExtent, position.maxScrollExtent); - } - - double _initialScrollOffset(double viewportWidth, double minExtent, double maxExtent) { - return _tabScrollOffset(_currentIndex, viewportWidth, minExtent, maxExtent); - } - - void _scrollToCurrentIndex() { - final double offset = _tabCenteredScrollOffset(_currentIndex); - _scrollController.animateTo(offset, duration: kTabScrollDuration, curve: Curves.ease); - } - - void _scrollToControllerValue() { - final double leadingPosition = _currentIndex > 0 ? _tabCenteredScrollOffset(_currentIndex - 1) : null; - final double middlePosition = _tabCenteredScrollOffset(_currentIndex); - final double trailingPosition = _currentIndex < maxTabIndex ? _tabCenteredScrollOffset(_currentIndex + 1) : null; - - final double index = _controller.index.toDouble(); - final double value = _controller.animation.value; - double offset; - if (value == index - 1.0) - offset = leadingPosition ?? middlePosition; - else if (value == index + 1.0) - offset = trailingPosition ?? middlePosition; - else if (value == index) - offset = middlePosition; - else if (value < index) - offset = leadingPosition == null ? middlePosition : lerpDouble(middlePosition, leadingPosition, index - value); - else - offset = trailingPosition == null ? middlePosition : lerpDouble(middlePosition, trailingPosition, value - index); - - _scrollController.jumpTo(offset); - } - - void _handleTabControllerAnimationTick() { - assert(mounted); - if (!_controller.indexIsChanging && widget.isScrollable) { - // Sync the TabBar's scroll position with the TabBarView's PageView. - _currentIndex = _controller.index; - _scrollToControllerValue(); - } - } - - void _handleTabControllerTick() { - if (_controller.index != _currentIndex) { - _currentIndex = _controller.index; - if (widget.isScrollable) - _scrollToCurrentIndex(); - } - setState(() { - // Rebuild the tabs after a (potentially animated) index change - // has completed. - }); - } - - // Called each time layout completes. - void _saveTabOffsets(List tabOffsets, TextDirection textDirection, double width) { - _tabStripWidth = width; - _indicatorPainter?.saveTabOffsets(tabOffsets, textDirection); - } - - void _handleTap(int index) { - assert(index >= 0 && index < widget.tabs.length); - _controller.animateTo(index); - if (widget.onTap != null) { - widget.onTap(index); - } - } - - Widget _buildStyledTab(Widget child, bool selected, Animation animation) { - return _TabStyle( - animation: animation, - selected: selected, - labelColor: widget.labelColor, - unselectedLabelColor: widget.unselectedLabelColor, - labelStyle: widget.labelStyle, - unselectedLabelStyle: widget.unselectedLabelStyle, - child: child, - ); - } - - @override - Widget build(BuildContext context) { - assert(debugCheckHasMaterialLocalizations(context)); - assert(() { - if (_controller.length != widget.tabs.length) { - throw FlutterError( - 'Controller\'s length property (${_controller.length}) does not match the \n' - 'number of tabs (${widget.tabs.length}) present in TabBar\'s tabs property.' - ); - } - return true; - }()); - final MaterialLocalizations localizations = MaterialLocalizations.of(context); - if (_controller.length == 0) { - return Container( - height: _kTabHeight + widget.indicatorWeight, - ); - } - - final TabBarTheme tabBarTheme = TabBarTheme.of(context); - - final List wrappedTabs = List(widget.tabs.length); - for (int i = 0; i < widget.tabs.length; i += 1) { - wrappedTabs[i] = Center( - heightFactor: 1.0, - child: Padding( - padding: widget.labelPadding ?? tabBarTheme.labelPadding ?? kTabLabelPadding, - child: KeyedSubtree( - key: _tabKeys[i], - child: widget.tabs[i], - ), - ), - ); - - } - - // If the controller was provided by DefaultTabController and we're part - // of a Hero (typically the AppBar), then we will not be able to find the - // controller during a Hero transition. See https://github.com/flutter/flutter/issues/213. - if (_controller != null) { - final int previousIndex = _controller.previousIndex; - - if (_controller.indexIsChanging) { - // The user tapped on a tab, the tab controller's animation is running. - assert(_currentIndex != previousIndex); - final Animation animation = _ChangeAnimation(_controller); - wrappedTabs[_currentIndex] = _buildStyledTab(wrappedTabs[_currentIndex], true, animation); - wrappedTabs[previousIndex] = _buildStyledTab(wrappedTabs[previousIndex], false, animation); - } else { - // The user is dragging the TabBarView's PageView left or right. - final int tabIndex = _currentIndex; - final Animation centerAnimation = _DragAnimation(_controller, tabIndex); - wrappedTabs[tabIndex] = _buildStyledTab(wrappedTabs[tabIndex], true, centerAnimation); - if (_currentIndex > 0) { - final int tabIndex = _currentIndex - 1; - final Animation previousAnimation = ReverseAnimation(_DragAnimation(_controller, tabIndex)); - wrappedTabs[tabIndex] = _buildStyledTab(wrappedTabs[tabIndex], false, previousAnimation); - } - if (_currentIndex < widget.tabs.length - 1) { - final int tabIndex = _currentIndex + 1; - final Animation nextAnimation = ReverseAnimation(_DragAnimation(_controller, tabIndex)); - wrappedTabs[tabIndex] = _buildStyledTab(wrappedTabs[tabIndex], false, nextAnimation); - } - } - } - - // Add the tap handler to each tab. If the tab bar is not scrollable, - // then give all of the tabs equal flexibility so that they each occupy - // the same share of the tab bar's overall width. - final int tabCount = widget.tabs.length; - for (int index = 0; index < tabCount; index += 1) { - wrappedTabs[index] = GestureDetector( - onTap: () { _handleTap(index); }, - child: Container( - color: Colors.transparent, - padding: EdgeInsets.only(bottom: widget.indicatorWeight), - child: Stack( - children: [ - wrappedTabs[index], - Semantics( - selected: index == _currentIndex, - label: localizations.tabLabel(tabIndex: index + 1, tabCount: tabCount), - ), - ], - ), - ), - ); - if (!widget.isScrollable) - wrappedTabs[index] = Expanded(child: wrappedTabs[index]); - } - - Widget tabBar = CustomPaint( - painter: _indicatorPainter, - child: _TabStyle( - animation: kAlwaysDismissedAnimation, - selected: false, - labelColor: widget.labelColor, - unselectedLabelColor: widget.unselectedLabelColor, - labelStyle: widget.labelStyle, - unselectedLabelStyle: widget.unselectedLabelStyle, - child: _TabLabelBar( - onPerformLayout: _saveTabOffsets, - children: wrappedTabs, - ), - ), - ); - - if (widget.isScrollable) { - _scrollController ??= _TabBarScrollController(this); - tabBar = SingleChildScrollView( - dragStartBehavior: widget.dragStartBehavior, - scrollDirection: Axis.horizontal, - controller: _scrollController, - child: tabBar, - ); - } - - return tabBar; - } -} - - -final PageScrollPhysics _kTabBarViewPhysics = const PageScrollPhysics().applyTo(const ClampingScrollPhysics()); - -class _TabBarViewState extends State { - TabController _controller; - PageController _pageController; - List _children; - List _childrenWithKey; - int _currentIndex; - int _warpUnderwayCount = 0; - - // If the TabBarView is rebuilt with a new tab controller, the caller should - // dispose the old one. In that case the old controller's animation will be - // null and should not be accessed. - bool get _controllerIsValid => _controller?.animation != null; - - void _updateTabController() { - final TabController newController = widget.controller ?? DefaultTabController.of(context); - assert(() { - if (newController == null) { - throw FlutterError( - 'No TabController for ${widget.runtimeType}.\n' - 'When creating a ${widget.runtimeType}, you must either provide an explicit ' - 'TabController using the "controller" property, or you must ensure that there ' - 'is a DefaultTabController above the ${widget.runtimeType}.\n' - 'In this case, there was neither an explicit controller nor a default controller.' - ); - } - return true; - }()); - - if (newController == _controller) - return; - - if (_controllerIsValid) - _controller.animation.removeListener(_handleTabControllerAnimationTick); - _controller = newController; - if (_controller != null) - _controller.animation.addListener(_handleTabControllerAnimationTick); - } - - @override - void initState() { - super.initState(); - _updateChildren(); - } - - @override - void didChangeDependencies() { - super.didChangeDependencies(); - _updateTabController(); - _currentIndex = _controller?.index; - _pageController = PageController(initialPage: _currentIndex ?? 0); - } - - @override - void didUpdateWidget(TabBarView oldWidget) { - super.didUpdateWidget(oldWidget); - if (widget.controller != oldWidget.controller) - _updateTabController(); - if (widget.children != oldWidget.children && _warpUnderwayCount == 0) - _updateChildren(); - } - - @override - void dispose() { - if (_controllerIsValid) - _controller.animation.removeListener(_handleTabControllerAnimationTick); - _controller = null; - // We don't own the _controller Animation, so it's not disposed here. - super.dispose(); - } - - void _updateChildren() { - _children = widget.children; - _childrenWithKey = KeyedSubtree.ensureUniqueKeysForList(widget.children); - } - - void _handleTabControllerAnimationTick() { - if (_warpUnderwayCount > 0 || !_controller.indexIsChanging) - return; // This widget is driving the controller's animation. - - if (_controller.index != _currentIndex) { - _currentIndex = _controller.index; - _warpToCurrentIndex(); - } - } - - Future _warpToCurrentIndex() async { - if (!mounted) - return Future.value(); - - if (_pageController.page == _currentIndex.toDouble()) - return Future.value(); - - final int previousIndex = _controller.previousIndex; - if ((_currentIndex - previousIndex).abs() == 1) - return _pageController.animateToPage(_currentIndex, duration: kTabScrollDuration, curve: Curves.ease); - - assert((_currentIndex - previousIndex).abs() > 1); - final int initialPage = _currentIndex > previousIndex - ? _currentIndex - 1 - : _currentIndex + 1; - final List originalChildren = _childrenWithKey; - setState(() { - _warpUnderwayCount += 1; - - _childrenWithKey = List.from(_childrenWithKey, growable: false); - final Widget temp = _childrenWithKey[initialPage]; - _childrenWithKey[initialPage] = _childrenWithKey[previousIndex]; - _childrenWithKey[previousIndex] = temp; - }); - _pageController.jumpToPage(initialPage); - - await _pageController.animateToPage(_currentIndex, duration: kTabScrollDuration, curve: Curves.ease); - if (!mounted) - return Future.value(); - setState(() { - _warpUnderwayCount -= 1; - if (widget.children != _children) { - _updateChildren(); - } else { - _childrenWithKey = originalChildren; - } - }); - } - - // Called when the PageView scrolls - bool _handleScrollNotification(ScrollNotification notification) { - if (_warpUnderwayCount > 0) - return false; - - if (notification.depth != 0) - return false; - - _warpUnderwayCount += 1; - if (notification is ScrollUpdateNotification && !_controller.indexIsChanging) { - if ((_pageController.page - _controller.index).abs() > 1.0) { - _controller.index = _pageController.page.floor(); - _currentIndex =_controller.index; - } - _controller.offset = (_pageController.page - _controller.index).clamp(-1.0, 1.0); - } else if (notification is ScrollEndNotification) { - _controller.index = _pageController.page.round(); - _currentIndex = _controller.index; - } - _warpUnderwayCount -= 1; - - return false; - } - - @override - Widget build(BuildContext context) { - assert(() { - if (_controller.length != widget.children.length) { - throw FlutterError( - 'Controller\'s length property (${_controller.length}) does not match the \n' - 'number of tabs (${widget.children.length}) present in TabBar\'s tabs property.' - ); - } - return true; - }()); - return NotificationListener( - onNotification: _handleScrollNotification, - child: PageView( - dragStartBehavior: widget.dragStartBehavior, - controller: _pageController, - physics: widget.physics == null ? _kTabBarViewPhysics : _kTabBarViewPhysics.applyTo(widget.physics), - children: _childrenWithKey, - ), - ); - } -} - -/// Displays a single circle with the specified border and background colors. -/// -/// Used by [TabPageSelector] to indicate the selected page. -class TabPageSelectorIndicator extends StatelessWidget { - /// Creates an indicator used by [TabPageSelector]. - /// - /// The [backgroundColor], [borderColor], and [size] parameters must not be null. - const TabPageSelectorIndicator({ - Key key, - @required this.backgroundColor, - @required this.borderColor, - @required this.size, - }) : assert(backgroundColor != null), - assert(borderColor != null), - assert(size != null), - super(key: key); - - /// The indicator circle's background color. - final Color backgroundColor; - - /// The indicator circle's border color. - final Color borderColor; - - /// The indicator circle's diameter. - final double size; - - @override - Widget build(BuildContext context) { - return Container( - width: size, - height: size, - margin: const EdgeInsets.all(4.0), - decoration: BoxDecoration( - color: backgroundColor, - border: Border.all(color: borderColor), - shape: BoxShape.circle, - ), - ); - } -} - -/// Displays a row of small circular indicators, one per tab. -/// -/// The selected tab's indicator is highlighted. Often used in conjunction with -/// a [TabBarView]. -/// -/// If a [TabController] is not provided, then there must be a -/// [DefaultTabController] ancestor. -class TabPageSelector extends StatelessWidget { - /// Creates a compact widget that indicates which tab has been selected. - const TabPageSelector({ - Key key, - this.controller, - this.indicatorSize = 12.0, - this.color, - this.selectedColor, - }) : assert(indicatorSize != null && indicatorSize > 0.0), - super(key: key); - - /// This widget's selection and animation state. - /// - /// If [TabController] is not provided, then the value of - /// [DefaultTabController.of] will be used. - final TabController controller; - - /// The indicator circle's diameter (the default value is 12.0). - final double indicatorSize; - - /// The indicator circle's fill color for unselected pages. - /// - /// If this parameter is null, then the indicator is filled with [Colors.transparent]. - final Color color; - - /// The indicator circle's fill color for selected pages and border color - /// for all indicator circles. - /// - /// If this parameter is null, then the indicator is filled with the theme's - /// accent color, [ThemeData.accentColor]. - final Color selectedColor; - - Widget _buildTabIndicator( - int tabIndex, - TabController tabController, - ColorTween selectedColorTween, - ColorTween previousColorTween, - ) { - Color background; - if (tabController.indexIsChanging) { - // The selection's animation is animating from previousValue to value. - final double t = 1.0 - _indexChangeProgress(tabController); - if (tabController.index == tabIndex) - background = selectedColorTween.lerp(t); - else if (tabController.previousIndex == tabIndex) - background = previousColorTween.lerp(t); - else - background = selectedColorTween.begin; - } else { - // The selection's offset reflects how far the TabBarView has / been dragged - // to the previous page (-1.0 to 0.0) or the next page (0.0 to 1.0). - final double offset = tabController.offset; - if (tabController.index == tabIndex) { - background = selectedColorTween.lerp(1.0 - offset.abs()); - } else if (tabController.index == tabIndex - 1 && offset > 0.0) { - background = selectedColorTween.lerp(offset); - } else if (tabController.index == tabIndex + 1 && offset < 0.0) { - background = selectedColorTween.lerp(-offset); - } else { - background = selectedColorTween.begin; - } - } - return TabPageSelectorIndicator( - backgroundColor: background, - borderColor: selectedColorTween.end, - size: indicatorSize, - ); - } - - @override - Widget build(BuildContext context) { - final Color fixColor = color ?? Colors.transparent; - final Color fixSelectedColor = selectedColor ?? Theme.of(context).accentColor; - final ColorTween selectedColorTween = ColorTween(begin: fixColor, end: fixSelectedColor); - final ColorTween previousColorTween = ColorTween(begin: fixSelectedColor, end: fixColor); - final TabController tabController = controller ?? DefaultTabController.of(context); - assert(() { - if (tabController == null) { - throw FlutterError( - 'No TabController for $runtimeType.\n' - 'When creating a $runtimeType, you must either provide an explicit TabController ' - 'using the "controller" property, or you must ensure that there is a ' - 'DefaultTabController above the $runtimeType.\n' - 'In this case, there was neither an explicit controller nor a default controller.' - ); - } - return true; - }()); - final Animation animation = CurvedAnimation( - parent: tabController.animation, - curve: Curves.fastOutSlowIn, - ); - return AnimatedBuilder( - animation: animation, - builder: (BuildContext context, Widget child) { - return Semantics( - label: 'Page ${tabController.index + 1} of ${tabController.length}', - child: Row( - mainAxisSize: MainAxisSize.min, - children: List.generate(tabController.length, (int tabIndex) { - return _buildTabIndicator(tabIndex, tabController, selectedColorTween, previousColorTween); - }).toList(), - ), - ); - }, - ); - } -} diff --git a/lib/views/widgets/StatelessWidget/TabBar/node2_noShadow.dart b/lib/views/widgets/StatelessWidget/TabBar/node2_noShadow.dart index 709be82..281c3ea 100644 --- a/lib/views/widgets/StatelessWidget/TabBar/node2_noShadow.dart +++ b/lib/views/widgets/StatelessWidget/TabBar/node2_noShadow.dart @@ -1,17 +1,15 @@ import 'package:flutter/material.dart'; -import 'no_shadow_tab_bar.dart'; - /// create by 张风捷特烈 on 2020/4/27 /// contact me by email 1981462002@qq.com -/// 说明: +/// 说明: // { // "widgetId": 58, -// "name": '通过修改源码可实现无水波纹', +// "name": '通过设置Theme可实现无水波纹', // "priority": 1, // "subtitle": -// "详见:components/flutter/no_shadow_tab_bar.dart", +// "将Theme关于水波纹的颜色设置为透明即可。", // } class NoShadowTabBarDemo extends StatefulWidget { @override @@ -37,20 +35,26 @@ class _NSTabBarState extends State @override Widget build(BuildContext context) { - return NoShadowTabBar( - onTap: (tab) { - print(tab); - }, - labelStyle: TextStyle(fontSize: 16, fontWeight: FontWeight.bold), - unselectedLabelStyle: TextStyle(fontSize: 16), - isScrollable: true, - controller: _tabController, - labelColor: Colors.blue, - indicatorWeight: 3, - indicatorPadding: EdgeInsets.symmetric(horizontal: 10), - unselectedLabelColor: Colors.grey, - indicatorColor: Colors.orangeAccent, - tabs: tabs.map((e) => Tab(text: e)).toList(), + return Theme( + data: Theme.of(context).copyWith( + splashColor: Colors.transparent, + highlightColor: Colors.transparent, + ), + child: TabBar( + onTap: (tab) { + print(tab); + }, + labelStyle: TextStyle(fontSize: 16, fontWeight: FontWeight.bold), + unselectedLabelStyle: TextStyle(fontSize: 16), + isScrollable: true, + controller: _tabController, + labelColor: Colors.blue, + indicatorWeight: 3, + indicatorPadding: EdgeInsets.symmetric(horizontal: 10), + unselectedLabelColor: Colors.grey, + indicatorColor: Colors.orangeAccent, + tabs: tabs.map((e) => Tab(text: e)).toList(), + ), ); } -} \ No newline at end of file +} diff --git a/lib/views/widgets/StatelessWidget/Text/node5_textDirection.dart b/lib/views/widgets/StatelessWidget/Text/node5_textDirection.dart index e7c74f2..b461332 100644 --- a/lib/views/widgets/StatelessWidget/Text/node5_textDirection.dart +++ b/lib/views/widgets/StatelessWidget/Text/node5_textDirection.dart @@ -10,7 +10,7 @@ import 'package:flutter/material.dart'; // "priority": 5, // "name": "文字方向与最大行数", // "subtitle": "【maxLines】 : 最大行数 【int】\n" -// "【【textDirection】 : 文字方向 【TextDirection】\n" +// "【textDirection】 : 文字方向 【TextDirection】\n" // "下面依次是:rtl、ltr ", // } class TextDirectionText extends StatelessWidget { diff --git a/lib/views/widgets/StatelessWidget/Theme/node1_base.dart b/lib/views/widgets/StatelessWidget/Theme/node1_base.dart index 9162886..f90f146 100644 --- a/lib/views/widgets/StatelessWidget/Theme/node1_base.dart +++ b/lib/views/widgets/StatelessWidget/Theme/node1_base.dart @@ -18,12 +18,12 @@ class TextThemeDemo extends StatelessWidget { "headline: ": queryData.headline, "title: ": queryData.title, "subhead: ": queryData.subhead, - "subtitle: ": queryData.body1, + "body1: ": queryData.body1, "body2: ": queryData.body2, "button: ": queryData.button, "overline: ": queryData.overline, "subtitle: ": queryData.subtitle, - "button: ": queryData.caption, + "caption: ": queryData.caption, "display1: ": queryData.display1, "display2: ": queryData.display2, "display3: ": queryData.display3, diff --git a/lib/views/widgets/StatelessWidget/UserAccountsDrawerHeader/node1_base.dart b/lib/views/widgets/StatelessWidget/UserAccountsDrawerHeader/node1_base.dart index 26d3913..3e77baf 100644 --- a/lib/views/widgets/StatelessWidget/UserAccountsDrawerHeader/node1_base.dart +++ b/lib/views/widgets/StatelessWidget/UserAccountsDrawerHeader/node1_base.dart @@ -44,11 +44,11 @@ class CustomUAGHP extends StatelessWidget { currentAccountPicture: Container( padding: const EdgeInsets.all(15.0), child: CircleAvatar( - backgroundImage: AssetImage("assets/images/icon_head.png"), + backgroundImage: AssetImage("assets/images/icon_head.webp"), ), ), decoration: BoxDecoration( - image: DecorationImage(image: AssetImage("assets/images/caver.jpeg")), + image: DecorationImage(image: AssetImage("assets/images/caver.webp")), ), ), ); diff --git a/lib/views/widgets/StatelessWidget/UserAccountsDrawerHeader/node2_pro.dart b/lib/views/widgets/StatelessWidget/UserAccountsDrawerHeader/node2_pro.dart index 2016c58..54669d3 100644 --- a/lib/views/widgets/StatelessWidget/UserAccountsDrawerHeader/node2_pro.dart +++ b/lib/views/widgets/StatelessWidget/UserAccountsDrawerHeader/node2_pro.dart @@ -49,11 +49,11 @@ class ProUAGHP extends StatelessWidget { currentAccountPicture: Container( padding: const EdgeInsets.all(15.0), child: CircleAvatar( - backgroundImage: AssetImage("assets/images/icon_head.png"), + backgroundImage: AssetImage("assets/images/icon_head.webp"), ), ), otherAccountsPictures: [ - FlutterLogo(colors: Colors.green), + FlutterLogo(textColor: Colors.green), ], onDetailsPressed: () { @@ -61,7 +61,7 @@ class ProUAGHP extends StatelessWidget { arrowColor: Colors.white, decoration: BoxDecoration( image: DecorationImage( - image: AssetImage("assets/images/caver.jpeg")), + image: AssetImage("assets/images/caver.webp")), ), ), ); diff --git a/lib/views/widgets/StatelessWidget/zz_no/CupertinoSegmentedControlTest.dart b/lib/views/widgets/StatelessWidget/zz_no/CupertinoSegmentedControlTest.dart deleted file mode 100755 index e1e5607..0000000 --- a/lib/views/widgets/StatelessWidget/zz_no/CupertinoSegmentedControlTest.dart +++ /dev/null @@ -1,60 +0,0 @@ -import 'dart:math'; - -import 'package:flutter/cupertino.dart'; - - -//class CupertinoButtonTest extends StatelessWidget { -// CupertinoButtonTest({Key key}) : super(key: key); -// -// @override -// Widget build(BuildContext context) { -// return CupertinoSegmentedControl( -// onValueChanged: (v) { -// print(object) -// }, -// pressedColor: Color(0xff7c1c25), -// borderColor: Color(0xffac172a), -// selectedColor: Color(0xffac172a), -// groupValue: value, -// children: { -// 'a': Container( -// alignment: Alignment.center, -// width: 130.0, -// child: Text('a') -// ), -// 'c': Text('C'), -// 'b': Text('B'), -// }, -// ); -//} -// -class CupertinoSegmentedControlTest extends StatefulWidget { - _Demo createState() => _Demo(); -} - -class _Demo extends State { - String value = 'Java'; - @override - Widget build(BuildContext context) { - return CupertinoSegmentedControl( - onValueChanged: (v) { - this.setState(() { - value = v; - }); - }, - pressedColor: CupertinoColors.activeGreen,//点击时颜色 - borderColor: CupertinoColors.inactiveGray,//边框颜色 - selectedColor: CupertinoColors.activeBlue,//选中的颜色 - groupValue: value,//当前值 - children: {//对于组件 - 'Java': Container( - alignment: Alignment.center, - width: 100.0, - child: Text('Java') - ), - 'Kotlin': Text('Kotlin'), - 'Dart': Text('Dart'), - }, - ); - } -} diff --git a/lib/views/widgets/exp/other_unit.dart b/lib/views/widgets/exp/other_unit.dart index bcb507c..8309e77 100644 --- a/lib/views/widgets/exp/other_unit.dart +++ b/lib/views/widgets/exp/other_unit.dart @@ -8,4 +8,9 @@ library other_unit.dart; export '../Other/ErrorWidget/node1_base.dart'; export '../Other/Table/node1_base.dart'; export '../Other/RawImage/node1_base.dart'; -export '../Other/PerformanceOverlay/node1_base.dart'; \ No newline at end of file +export '../Other/PerformanceOverlay/node1_base.dart'; +export '../Other/RenderObjectToWidgetAdapter/node1_base.dart'; +export '../Other/ListWheelViewport/node1_base.dart'; +export '../Other/ListWheelViewport/node2_perspective.dart'; +export '../Other/ListWheelViewport/node3_magnifier.dart'; +export '../Other/ListWheelViewport/node4_opacity.dart'; \ No newline at end of file diff --git a/lib/views/widgets/exp/proxy_unit.dart b/lib/views/widgets/exp/proxy_unit.dart index 2042101..3992a74 100644 --- a/lib/views/widgets/exp/proxy_unit.dart +++ b/lib/views/widgets/exp/proxy_unit.dart @@ -25,3 +25,11 @@ export '../ProxyWidget/PopupMenuTheme/node1_base.dart'; export '../ProxyWidget/ToggleButtonsTheme/node1_base.dart'; export '../ProxyWidget/ButtonBarTheme/node1_base.dart'; export '../ProxyWidget/TooltipTheme/node1_base.dart'; +export '../ProxyWidget/Directionality/node1_base.dart'; +export '../ProxyWidget/TableCell/node1_base.dart'; +export '../ProxyWidget/KeepAlive/node1_base.dart'; +export '../ProxyWidget/CupertinoUserInterfaceLevel/node1_base.dart'; +export '../ProxyWidget/InheritedTheme/node1_base.dart'; +export '../ProxyWidget/DefaultAssetBundle/node1_base.dart'; +export '../ProxyWidget/InheritedWidget/node1_base.dart'; +export '../ProxyWidget/ParentDataWidget/node1_base.dart'; diff --git a/lib/views/widgets/exp/render_object_unit.dart b/lib/views/widgets/exp/render_object_unit.dart index b18d292..9ac2154 100644 --- a/lib/views/widgets/exp/render_object_unit.dart +++ b/lib/views/widgets/exp/render_object_unit.dart @@ -24,6 +24,8 @@ export '../MultiChildRenderObjectWidget/Row/node1_base.dart'; export '../MultiChildRenderObjectWidget/CustomMultiChildLayout/node1_base.dart'; export '../MultiChildRenderObjectWidget/Viewport/node1_base.dart'; export '../MultiChildRenderObjectWidget/ListBody/node1_base.dart'; +export '../MultiChildRenderObjectWidget/ShrinkWrappingViewport/node1_base.dart'; +export '../MultiChildRenderObjectWidget/NestedScrollViewViewport/node1_base.dart'; export '../SingleChildRenderObjectWidget/Align/node1_base.dart'; export '../SingleChildRenderObjectWidget/Align/node2_other.dart'; @@ -31,8 +33,16 @@ export '../SingleChildRenderObjectWidget/CustomSingleChildLayout/node1_base.dart export '../SingleChildRenderObjectWidget/CustomSingleChildLayout/node2_offset.dart'; export '../SingleChildRenderObjectWidget/RepaintBoundary/node1_base.dart'; export '../SingleChildRenderObjectWidget/RepaintBoundary/node2_save.dart'; +export '../SingleChildRenderObjectWidget/CompositedTransformTarget/node1_base.dart'; +export '../SingleChildRenderObjectWidget/CompositedTransformFollower/node1_base.dart'; + +export '../SingleChildRenderObjectWidget/AnnotatedRegion/node1_base.dart'; +export '../SingleChildRenderObjectWidget/CupertinoTextSelectionToolbar/node1_base.dart'; +export '../SingleChildRenderObjectWidget/SizeChangedLayoutNotifier/node1_base.dart'; +export '../SingleChildRenderObjectWidget/ColoredBox/node1_base.dart'; export '../SingleChildRenderObjectWidget/ConstrainedBox/node1_base.dart'; +export '../SingleChildRenderObjectWidget/PhysicalModel/node1_base.dart'; export '../SingleChildRenderObjectWidget/FractionalTranslation/node1_base.dart'; export '../SingleChildRenderObjectWidget/ColorFiltered/node1_base.dart'; export '../SingleChildRenderObjectWidget/Baseline/node1_base.dart'; diff --git a/lib/views/widgets/exp/sliver_unit.dart b/lib/views/widgets/exp/sliver_unit.dart index fc7e958..290cb25 100644 --- a/lib/views/widgets/exp/sliver_unit.dart +++ b/lib/views/widgets/exp/sliver_unit.dart @@ -17,3 +17,11 @@ export '../Sliver/SliverPersistentHeader/node1_base.dart'; export '../Sliver/SliverToBoxAdapter/node1_base.dart'; export '../Sliver/SliverOverlapAbsorber/node1_base.dart'; export '../Sliver/SliverOverlapInjector/node1_base.dart'; +export '../Sliver/SliverPrototypeExtentList/node1_base.dart'; +export '../Sliver/CupertinoSliverNavigationBar/node1_base.dart'; +export '../Sliver/CupertinoSliverRefreshControl/node1_base.dart'; +export '../Sliver/SliverFillRemaining/node1_base.dart'; +export '../Sliver/SliverIgnorePointer/node1_base.dart'; +export '../Sliver/SliverAnimatedList/node1_base.dart'; +export '../Sliver/SliverLayoutBuilder/node1_base.dart'; +export '../Sliver/SliverWithKeepAliveWidget/node1_base.dart'; diff --git a/lib/views/widgets/exp/stateful_unit.dart b/lib/views/widgets/exp/stateful_unit.dart index b0ae18e..96ec68e 100644 --- a/lib/views/widgets/exp/stateful_unit.dart +++ b/lib/views/widgets/exp/stateful_unit.dart @@ -41,12 +41,14 @@ export '../StatefulWidget/Image/node3_alignment.dart'; export '../StatefulWidget/Image/node4_colorBlendMode.dart'; export '../StatefulWidget/Image/node5_repeat.dart'; export '../StatefulWidget/Image/node6_centerSlice.dart'; +export '../StatefulWidget/Image/node6_centerSlice.dart'; export '../StatefulWidget/RangeSlider/node1_base.dart'; export '../StatefulWidget/Slider/node1_base.dart'; export '../StatefulWidget/Slider/node2_lable.dart'; export '../StatefulWidget/Switch/node1_base.dart'; export '../StatefulWidget/Switch/node2_image.dart'; +export '../StatefulWidget/StatefulBuilder/node1_base.dart'; export '../StatefulWidget/TextField/node3_decoration.dart'; export '../StatefulWidget/RefreshIndicator/node1_base.dart'; export '../StatefulWidget/SelectableText/node1_base.dart'; @@ -72,8 +74,16 @@ export '../StatefulWidget/DecoratedBoxTransition/node1_base.dart'; export '../StatefulWidget/DefaultTextStyleTransition/node1_base.dart'; export '../StatefulWidget/RelativePositionedTransition/node1_base.dart'; export '../StatefulWidget/CupertinoScrollbar/node1_base.dart'; +export '../StatefulWidget/RawGestureDetector/node1_base.dart'; export '../StatefulWidget/Dismissible/node1_base.dart'; +export '../StatefulWidget/AutomaticKeepAlive/node1_base.dart'; +export '../StatefulWidget/AnimatedModalBarrier/node1_base.dart'; +export '../StatefulWidget/FormField/node1_base.dart'; +export '../StatefulWidget/AnimatedBuilder/node1_base.dart'; +export '../StatefulWidget/TweenAnimationBuilder/node1_base.dart'; +export '../StatefulWidget/PaginatedDataTable/node1_base.dart'; +export '../StatefulWidget/RawKeyboardListener/node1_base.dart'; export '../StatefulWidget/Dismissible/node2_direction.dart'; export '../StatefulWidget/DragTarget/node1_base.dart'; @@ -82,6 +92,8 @@ export '../StatefulWidget/Draggable/node2_data.dart'; export '../StatefulWidget/Draggable/node3_use.dart'; export '../StatefulWidget/Form/node1_base.dart'; +export '../StatefulWidget/StatusTransitionWidget/node1_base.dart'; +export '../StatefulWidget/UniqueWidget/node1_base.dart'; export '../StatefulWidget/FutureBuilder/node1_base.dart'; export '../StatefulWidget/Hero/node1_base.dart'; export '../StatefulWidget/AnimatedAlign/node1_base.dart'; @@ -93,6 +105,7 @@ export '../StatefulWidget/AnimatedPositioned/node1_base.dart'; export '../StatefulWidget/AnimatedPositionedDirectional/node1_base.dart'; export '../StatefulWidget/ExpansionPanelList/node1_base.dart'; +export '../StatefulWidget/DropdownButtonFormField/node1_base.dart'; export '../StatefulWidget/Ink/node1_base.dart'; export '../StatefulWidget/Ink/node2_image.dart'; @@ -140,3 +153,23 @@ export '../StatefulWidget/Scaffold/node1_base.dart'; export '../StatefulWidget/TabBarView/node1_base.dart'; export '../StatefulWidget/InputDecorator/node1_base.dart'; export '../StatefulWidget/EditableText/node1_base.dart'; +export '../StatefulWidget/CupertinoSlidingSegmentedControl/node1_base.dart'; +export '../StatefulWidget/WidgetsApp/node1_base.dart' hide HomePage; +export '../StatefulWidget/WidgetInspector/node1_base.dart' hide HomePage; +export '../StatefulWidget/AnimatedTheme/node1_base.dart'; +export '../StatefulWidget/AnimatedPhysicalModel/node1_base.dart'; +export '../StatefulWidget/DefaultTabController/node1_base.dart'; +export '../StatefulWidget/GlowingOverscrollIndicator/node1_base.dart'; +export '../StatefulWidget/DraggableScrollableSheet/node1_base.dart'; +export '../StatefulWidget/DrawerController/node1_base.dart'; +export '../StatefulWidget/MergeableMaterial/node1_base.dart'; +export '../StatefulWidget/CupertinoTabView/node1_base.dart' hide HomePage; + +export '../StatefulWidget/TextButton/node1_base.dart'; +export '../StatefulWidget/TextButton/node2_style.dart'; + +export '../StatefulWidget/ElevatedButton/node1_base.dart'; +export '../StatefulWidget/ElevatedButton/node2_style.dart'; + +export '../StatefulWidget/OutlinedButton//node1_base.dart'; +export '../StatefulWidget/OutlinedButton/node2_style.dart'; \ No newline at end of file diff --git a/lib/views/widgets/exp/stateless_unit.dart b/lib/views/widgets/exp/stateless_unit.dart index fe813a0..d975f95 100644 --- a/lib/views/widgets/exp/stateless_unit.dart +++ b/lib/views/widgets/exp/stateless_unit.dart @@ -5,6 +5,7 @@ export '../StatelessWidget/AboutListTile/node1_base.dart'; export '../StatelessWidget/ActionChip/node1_base.dart'; export '../StatelessWidget/AlertDialog/node1_base.dart'; export '../StatelessWidget/AnimatedIcon/node1_base.dart'; +export '../StatelessWidget/CheckedModeBanner/node1_base.dart'; export '../StatelessWidget/Card/node1_base.dart'; export '../StatelessWidget/Card/node2_shape.dart'; export '../StatelessWidget/PreferredSize/node1_base.dart'; @@ -12,6 +13,7 @@ export '../StatelessWidget/PreferredSize/node2_adapter.dart'; export '../StatelessWidget/Builder/node1_base.dart'; export '../StatelessWidget/NavigationToolbar/node1_base.dart'; export '../StatelessWidget/CupertinoDialogAction/node1_base.dart'; +export '../StatelessWidget/DraggableScrollableActuator/node1_base.dart'; export '../StatelessWidget/CheckboxListTile/node1_base.dart'; export '../StatelessWidget/CheckboxListTile/node2_select.dart'; @@ -29,6 +31,7 @@ export '../StatelessWidget/Container/node5_transform.dart'; export '../StatelessWidget/Container/node6_constraints.dart'; export '../StatelessWidget/MaterialBanner/node1_one_btn.dart'; export '../StatelessWidget/MaterialBanner/node2_two_btn.dart'; +export '../StatelessWidget/SafeArea/node1_base.dart'; export '../StatelessWidget/DataTable/node1_base.dart'; export '../StatelessWidget/DataTable/node2_operation.dart'; @@ -42,9 +45,13 @@ export '../StatelessWidget/CupertinoNavigationBarBackButton/node1_base.dart'; export '../StatelessWidget/CupertinoTheme/node1_base.dart'; export '../StatelessWidget/CupertinoTheme/node2_use.dart'; +export '../StatelessWidget/CupertinoPopupSurface/node1_base.dart'; export '../StatelessWidget/Divider/node1_base.dart'; export '../StatelessWidget/Divider/node2_height.dart'; +export '../StatelessWidget/ScrollView/node1_base.dart'; +export '../StatelessWidget/ModalBarrier/node1_base.dart'; +export '../StatelessWidget/BoxScrollView/node1_base.dart'; export '../StatelessWidget/FloatingActionButton/node1_base.dart'; export '../StatelessWidget/FloatingActionButton/node2_mini.dart'; export '../StatelessWidget/FloatingActionButton/node3_shape.dart'; @@ -179,4 +186,8 @@ export '../StatelessWidget/SimpleDialogOption/node1_base.dart'; export '../StatelessWidget/SnackBar/node1_base.dart'; export '../StatelessWidget/SnackBarAction/node1_base.dart'; +export '../StatelessWidget/PageStorage/node1_base.dart'; +export '../StatelessWidget/NotificationListener/node1_base.dart'; +export '../StatelessWidget/NotificationListener/node2_update.dart'; + diff --git a/lib/views/widgets/widgets_map.dart b/lib/views/widgets/widgets_map.dart index f480d85..131e279 100644 --- a/lib/views/widgets/widgets_map.dart +++ b/lib/views/widgets/widgets_map.dart @@ -1,15 +1,13 @@ import 'package:flutter/material.dart'; +import 'exp/other_unit.dart'; +import 'exp/proxy_unit.dart'; +import 'exp/render_object_unit.dart'; +import 'exp/sliver_unit.dart'; import 'exp/stateful_unit.dart'; import 'exp/stateless_unit.dart'; -import 'exp/render_object_unit.dart'; -import 'exp/proxy_unit.dart'; -import 'exp/other_unit.dart'; -import 'exp/sliver_unit.dart'; -/// create by 张风捷特烈 on 2020-03-04 -/// contact me by email 1981462002@qq.com -/// 说明: +/// AUTO CREATED BY [张风捷特烈] , DON'T MODIFY! class WidgetsMap { static List map(String name) { @@ -28,6 +26,14 @@ class WidgetsMap { CupertinoSegmentedControlDemo(), CupertinoSegmentedControlColor() ]; + case "CompositedTransformTarget": + return [ + const CompositedTransformTargetDemo(), + ]; + case "CompositedTransformFollower": + return [ + const CompositedTransformFollowerDemo(), + ]; case "Text": return [ CustomText(), @@ -42,6 +48,21 @@ class WidgetsMap { CustomCard(), ShapeCard(), ]; + case "ElevatedButton": + return [ + ElevatedButtonDemo(), + ElevatedButtonStyleDemo(), + ]; + case "TextButton": + return [ + TextButtonDemo(), + TextButtonStyleDemo(), + ]; + case "OutlinedButton": + return [ + OutlinedButtonDemo(), + OutlinedButtonStyleDemo(), + ]; case "FlutterLogo": return [ CustomFlutterLogo(), @@ -51,18 +72,196 @@ class WidgetsMap { return [ CustomBanner(), ]; + case "UniqueWidget": + return [ + UniqueWidgetDemo(), + ]; + case "ShrinkWrappingViewport": + return [ + ShrinkWrappingViewportDemo(), + ]; case "NestedScrollViewViewport": + return [ + NestedScrollViewViewportDemo(), + ]; + case "ParentDataWidget": + return [ + ParentDataWidgetDemo(), + ]; + case "AutomaticKeepAlive": + return [ + AutomaticKeepAliveDemo(), + ]; + case "StatusTransitionWidget": + return [ + StatusTransitionWidgetDemo(), + ]; + case "KeepAlive": + return [ + KeepAliveDemo(), + ]; + case "ListWheelViewport": + return [ + ListWheelViewportDemo(), + ListWheelViewportDemo2(), + ListWheelViewportDemo3(), + ListWheelViewportDemo4(), + ]; + case "InheritedTheme": + return [ + InheritedThemeDemo(), + ]; + case "ModalBarrier": + return [ + ModalBarrierDemo(), + ]; + case "AnimatedModalBarrier": + return [ + AnimatedModalBarrierDemo(), + ]; + case "DefaultAssetBundle": + return [ + DefaultAssetBundleDemo(), + ]; + case "DropdownButtonFormField": + return [ + DropdownButtonFormFieldDemo(), + ]; + case "FormField": + return [ + FormFieldDemo(), + ]; + case "PaginatedDataTable": + return [ + PaginatedDataTableDemo(), + ]; + case "InheritedWidget": + return [ + InheritedWidgetDemo(), + ]; + case "ScrollView": + return [ + ScrollViewDemo(), + ]; + case "SliverWithKeepAliveWidget": + return [ + SliverWithKeepAliveWidgetDemo(), + ]; + case "BoxScrollView": + return [ + BoxScrollViewDemo(), + ]; + case "CupertinoUserInterfaceLevel": + return [ + CupertinoUserInterfaceLevelDemo(), + ]; + case "CupertinoSliverNavigationBar": + return [ + CupertinoSliverNavigationBarDemo(), + ]; + case "CupertinoSliverRefreshControl": + return [ + CupertinoSliverRefreshControlDemo(), + ]; + case "SliverAnimatedList": + return [ + SliverAnimatedListDemo(), + ]; + case "SliverFillRemaining": + return [ + SliverFillRemainingDemo(), + ]; + case "SliverIgnorePointer": + return [ + SliverIgnorePointerDemo(), + ]; case "Viewport": return [ ViewportDemo(), ]; + case "CupertinoPopupSurface": + return [ + CupertinoPopupSurfaceDemo(), + ]; + case "RenderObjectToWidgetAdapter": + return [ + RenderObjectToWidgetAdapterDemo(), + ]; + case "SliverPrototypeExtentList": + return [ + SliverPrototypeExtentListDemo(), + ]; case "InputDecorator": return [ InputDecoratorDemo(), ]; + case "ColoredBox": + return [ + ColoredBoxDemo(), + ]; + case "StatefulBuilder": + return [ + StatefulBuilderDemo(), + ]; + case "RawKeyboardListener": + return [ + RawKeyboardListenerDemo(), + ]; + case "RawGestureDetector": + return [ + RawGestureDetectorDemo(), + ]; + case "SafeArea": + return [ + SafeAreaDemo(), + ]; + case "AnimatedBuilder": + return [ + AnimatedBuilderDemo(), + ]; + case "TweenAnimationBuilder": + return [ + TweenAnimationBuilderDemo(), + ]; + case "WidgetInspector": + return [ + WidgetInspectorDemo(), + ]; + case "PageStorage": + return [ + PageStorageDemo(), + ]; + case "NotificationListener": + return [NotificationListenerDemo(), NotificationListenerUpdate()]; + case "Scrollable": return [ ScrollableDemo(), ]; + case "PhysicalModel": + return [ + PhysicalModelDemo(), + ]; + case "Directionality": + return [ + DirectionalityDemo(), + ]; + case "AnimatedTheme": + return [ + AnimatedThemeDemo(), + ]; + case "CupertinoSlidingSegmentedControl": + return [ + CupertinoSlidingSegmentedControlDemo(), + ]; + case "WidgetsApp": + return [ + WidgetsAppDemo(), + ]; + case "TableCell": + return [ + TableCellDemo(), + ]; + case "EditableText": return [ EditableTextDemo(), @@ -164,6 +363,10 @@ class WidgetsMap { return [ CustomCircleAvatar(), ]; + case "SliverLayoutBuilder": + return [ + SliverLayoutBuilderDemo(), + ]; case "Visibility": return [ CustomVisibility(), @@ -395,6 +598,51 @@ class WidgetsMap { return [ CustomExpansionTile(), ]; + + case "AnnotatedRegion": + return [ + AnnotatedRegionDemo(), + ]; + case "CheckedModeBanner": + return [ + CheckedModeBannerDemo(), + ]; + case "DefaultTabController": + return [ + DefaultTabControllerDemo(), + ]; + case "CupertinoTabView": + return [ + CupertinoTabViewDemo(), + ]; + case "CupertinoTextSelectionToolbar": + return [ + CupertinoTextSelectionToolbarDemo(), + ]; + case "DraggableScrollableActuator": + return [ + DraggableScrollableActuatorDemo(), + ]; + case "GlowingOverscrollIndicator": + return [ + GlowingOverscrollIndicatorDemo(), + ]; + case "DraggableScrollableSheet": + return [ + DraggableScrollableSheetDemo(), + ]; + case "DrawerController": + return [ + DrawerControllerDemo(), + ]; + case "MergeableMaterial": + return [ + MergeableMaterialDemo(), + ]; + case "SizeChangedLayoutNotifier": + return [ + SizeChangedLayoutNotifierDemo(), + ]; case "SelectableText": return [ CustomSelectableText(), @@ -449,7 +697,7 @@ class WidgetsMap { ]; case "MaterialApp": return [ - CustomMaterialApp(), + MaterialAppDemo(), ]; case "ClipOval": return [ @@ -877,8 +1125,8 @@ class WidgetsMap { return [ CustomListView(), HorizontalListView(), - BuilderListView(), SeparatedListView(), + BuilderListView(), ]; case "GridView": return [ @@ -1091,11 +1339,16 @@ class WidgetsMap { return [ CustomBackdropFilter(), ]; + case "AnimatedPhysicalModel": + return [ + AnimatedPhysicalModelDemo(), + ]; case "CustomSingleChildLayout": return [ CustomSingleChildLayoutDemo(), OffSetWidgetDemo(), ]; + default: return []; } } } diff --git a/pubspec.lock b/pubspec.lock index 06b8cc3..7c1f69d 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -7,7 +7,7 @@ packages: name: async url: "https://pub.flutter-io.cn" source: hosted - version: "2.4.2" + version: "2.5.0" bloc: dependency: transitive description: @@ -21,35 +21,35 @@ packages: name: boolean_selector url: "https://pub.flutter-io.cn" source: hosted - version: "2.0.0" + version: "2.1.0" characters: dependency: transitive description: name: characters url: "https://pub.flutter-io.cn" source: hosted - version: "1.0.0" + version: "1.1.0" charcode: dependency: transitive description: name: charcode url: "https://pub.flutter-io.cn" source: hosted - version: "1.1.3" + version: "1.2.0" clock: dependency: transitive description: name: clock url: "https://pub.flutter-io.cn" source: hosted - version: "1.0.1" + version: "1.1.0" collection: dependency: transitive description: name: collection url: "https://pub.flutter-io.cn" source: hosted - version: "1.14.13" + version: "1.15.0" cupertino_icons: dependency: "direct main" description: @@ -70,7 +70,7 @@ packages: name: fake_async url: "https://pub.flutter-io.cn" source: hosted - version: "1.1.0" + version: "1.2.0" file: dependency: transitive description: @@ -114,20 +114,27 @@ packages: url: "https://pub.flutter-io.cn" source: hosted version: "0.16.1" + js: + dependency: transitive + description: + name: js + url: "https://pub.flutter-io.cn" + source: hosted + version: "0.6.3" matcher: dependency: transitive description: name: matcher url: "https://pub.flutter-io.cn" source: hosted - version: "0.12.8" + version: "0.12.10" meta: dependency: transitive description: name: meta url: "https://pub.flutter-io.cn" source: hosted - version: "1.1.8" + version: "1.3.0" nested: dependency: transitive description: @@ -141,7 +148,7 @@ packages: name: path url: "https://pub.flutter-io.cn" source: hosted - version: "1.7.0" + version: "1.8.0" path_provider: dependency: "direct main" description: @@ -251,7 +258,7 @@ packages: name: source_span url: "https://pub.flutter-io.cn" source: hosted - version: "1.7.0" + version: "1.8.0" sqflite: dependency: "direct main" description: @@ -272,21 +279,21 @@ packages: name: stack_trace url: "https://pub.flutter-io.cn" source: hosted - version: "1.9.5" + version: "1.10.0" stream_channel: dependency: transitive description: name: stream_channel url: "https://pub.flutter-io.cn" source: hosted - version: "2.0.0" + version: "2.1.0" string_scanner: dependency: transitive description: name: string_scanner url: "https://pub.flutter-io.cn" source: hosted - version: "1.0.5" + version: "1.1.0" synchronized: dependency: transitive description: @@ -300,14 +307,14 @@ packages: name: term_glyph url: "https://pub.flutter-io.cn" source: hosted - version: "1.1.0" + version: "1.2.0" test_api: dependency: transitive description: name: test_api url: "https://pub.flutter-io.cn" source: hosted - version: "0.2.17" + version: "0.2.19" toggle_rotate: dependency: "direct main" description: @@ -321,7 +328,7 @@ packages: name: typed_data url: "https://pub.flutter-io.cn" source: hosted - version: "1.2.0" + version: "1.3.0" url_launcher: dependency: "direct main" description: @@ -356,7 +363,7 @@ packages: name: vector_math url: "https://pub.flutter-io.cn" source: hosted - version: "2.0.8" + version: "2.1.0" xdg_directories: dependency: transitive description: @@ -365,5 +372,5 @@ packages: source: hosted version: "0.1.0" sdks: - dart: ">=2.9.0-14.0.dev <3.0.0" - flutter: ">=1.12.13+hotfix.5 <2.0.0" + dart: ">=2.12.0-0.0 <3.0.0" + flutter: ">=1.12.13+hotfix.5" diff --git a/pubspec.yaml b/pubspec.yaml index 59cd8ed..0c6b0b1 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,4 +1,4 @@ -name: flutter_unit_mac +name: flutter_unit description: A new Flutter application. # The following defines the version and build number for your application. @@ -73,6 +73,9 @@ flutter: - family: IndieFlower #字体名 fonts: - asset: assets/fonts/IndieFlower-Regular.ttf + - family: SourceHanSans #字体名 + fonts: + - asset: assets/fonts/SourceHanSans.otf - family: BalooBhai2 #字体名 fonts: - asset: assets/fonts/BalooBhai2-Regular.ttf