forked from lxm_flutter/FlutterUnit
web
This commit is contained in:
1
assets/data/node.json
Normal file
1
assets/data/node.json
Normal file
File diff suppressed because one or more lines are too long
Binary file not shown.
2543
lib/app/data/flutter_unit_data.dart
Normal file
2543
lib/app/data/flutter_unit_data.dart
Normal file
File diff suppressed because it is too large
Load Diff
@@ -28,8 +28,7 @@ class DetailBloc extends Bloc<DetailEvent, DetailState> {
|
||||
}
|
||||
}
|
||||
|
||||
Stream<DetailState> _mapLoadWidgetToState(
|
||||
WidgetModel widgetModel) async* {
|
||||
Stream<DetailState> _mapLoadWidgetToState(WidgetModel widgetModel) async* {
|
||||
yield DetailLoading();
|
||||
try {
|
||||
final nodes = await this.repository.loadNode(widgetModel);
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import 'package:equatable/equatable.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_unit_mac/storage/po/node_po.dart';
|
||||
|
||||
class GlobalState extends Equatable {
|
||||
final String fontFamily;
|
||||
|
||||
@@ -5,6 +5,5 @@ import 'package:flutter_unit_mac/views/app/bloc_wrapper.dart';
|
||||
import 'views/app/flutter_app.dart';
|
||||
|
||||
void main() {
|
||||
print(Directory.current.path);
|
||||
runApp(BlocWrapper(child: FlutterApp()));
|
||||
}
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
import 'package:equatable/equatable.dart';
|
||||
import 'package:flutter_unit_mac/storage/po/node_po.dart';
|
||||
|
||||
/// create by 张风捷特烈 on 2020-03-04
|
||||
/// contact me by email 1981462002@qq.com
|
||||
/// 说明: 详情页节点-展示-数据模型
|
||||
|
||||
|
||||
class NodeModel extends Equatable {
|
||||
final String name;
|
||||
final String subtitle;
|
||||
@@ -17,13 +17,19 @@ class NodeModel extends Equatable {
|
||||
|
||||
factory NodeModel.fromJson(Map<String, dynamic> map) {
|
||||
return NodeModel(
|
||||
name: map['name'],
|
||||
subtitle: map["subtitle"],
|
||||
code: map["code"]);
|
||||
name: map['name'], subtitle: map["subtitle"], code: map["code"]);
|
||||
}
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'Node{name: $name, subtitle: $subtitle, code: $code}';
|
||||
}
|
||||
}
|
||||
|
||||
static NodeModel fromPo(NodePo po) {
|
||||
return NodeModel(
|
||||
name: po.name,
|
||||
subtitle: po.subtitle,
|
||||
code: po.code,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
81
lib/repositories/impl/widget_innner_repository.dart
Normal file
81
lib/repositories/impl/widget_innner_repository.dart
Normal file
@@ -0,0 +1,81 @@
|
||||
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_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';
|
||||
|
||||
/// create by 张风捷特烈 on 2020-03-03
|
||||
/// contact me by email 1981462002@qq.com
|
||||
/// 说明 : Widget数据仓库
|
||||
|
||||
class WidgetInnerRepository implements WidgetRepository {
|
||||
final AppStorage storage;
|
||||
|
||||
WidgetInnerRepository(this.storage);
|
||||
|
||||
@override
|
||||
Future<List<WidgetModel>> loadWidgets(WidgetFamily family) async {
|
||||
var widgets = widgetData.map((e) => WidgetPo.fromJson(e)).toList();
|
||||
var result = widgets
|
||||
.map(WidgetModel.fromPo)
|
||||
.where((element) => element.family == family)
|
||||
.toList();
|
||||
result.sort((a, b) => b.lever.compareTo(a.lever));
|
||||
return result;
|
||||
}
|
||||
|
||||
@override
|
||||
Future<List<WidgetModel>> loadCollectWidgets() async {
|
||||
// var data = await _widgetDao.queryCollect();
|
||||
// var widgets = data.map((e) => WidgetPo.fromJson(e)).toList();
|
||||
// var list = widgets.map(WidgetModel.fromPo).toList();
|
||||
// return list;
|
||||
}
|
||||
|
||||
@override
|
||||
Future<List<WidgetModel>> searchWidgets(SearchArgs args) async {
|
||||
var widgets = widgetData.map((e) => WidgetPo.fromJson(e)).toList();
|
||||
var result = widgets
|
||||
.map(WidgetModel.fromPo)
|
||||
.where((element) => element.name.toLowerCase().contains(args.name.toLowerCase()) || element.nameCN.toLowerCase().contains(args.name.toLowerCase()))
|
||||
.where((element) => args.stars.contains(element.lever.round()))
|
||||
.toList();
|
||||
result.sort((a, b) => b.lever.compareTo(a.lever));
|
||||
return result;
|
||||
}
|
||||
|
||||
@override
|
||||
Future<List<NodeModel>> loadNode(WidgetModel widgetModel) async {
|
||||
var nodes = AppStorage.nodes
|
||||
.where((element) => element.widgetId == widgetModel.id)
|
||||
.map(NodeModel.fromPo).toList();
|
||||
return nodes;
|
||||
}
|
||||
|
||||
@override
|
||||
Future<List<WidgetModel>> loadWidget(List<int> id) async {
|
||||
var widgetsPool = widgetData.map((e) => WidgetPo.fromJson(e)).toList();
|
||||
var data = widgetsPool.where((element) => id.contains(element.id));
|
||||
return data.map(WidgetModel.fromPo).toList();
|
||||
}
|
||||
|
||||
@override
|
||||
Future<void> toggleCollect(
|
||||
int id,
|
||||
) {
|
||||
// return _widgetDao.toggleCollect(id);
|
||||
}
|
||||
|
||||
@override
|
||||
Future<bool> collected(int id) async {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
|
||||
import 'dart:convert';
|
||||
import 'dart:io';
|
||||
import 'dart:typed_data';
|
||||
|
||||
@@ -6,9 +6,11 @@ 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:shared_preferences/shared_preferences.dart';
|
||||
import 'package:sqflite/sqflite.dart';
|
||||
import 'package:path/path.dart' as path;
|
||||
|
||||
/// create by 张风捷特烈 on 2020-03-04
|
||||
/// contact me by email 1981462002@qq.com
|
||||
/// 说明:
|
||||
@@ -17,6 +19,8 @@ class AppStorage {
|
||||
SharedPreferences _sp;
|
||||
Database _database;
|
||||
|
||||
static List<NodePo> nodes;
|
||||
|
||||
Future<SharedPreferences> get sp async {
|
||||
_sp = _sp ?? await SharedPreferences.getInstance();
|
||||
return _sp;
|
||||
@@ -29,15 +33,18 @@ class AppStorage {
|
||||
|
||||
// 初始化 App 固化的配置数据
|
||||
Future<GlobalState> initApp() async {
|
||||
var prefs = await sp;
|
||||
_database = await initDb();
|
||||
var showBg = prefs.getBool(SP.showBackground) ?? true;
|
||||
var themeIndex = prefs.getInt(SP.themeColorIndex) ?? 4;
|
||||
var fontIndex = prefs.getInt(SP.fontFamily) ?? 1;
|
||||
var codeIndex = prefs.getInt(SP.codeStyleIndex) ?? 0;
|
||||
var itemStyleIndex = prefs.getInt(SP.itemStyleIndex) ?? 0;
|
||||
var str = await rootBundle.loadString('assets/data/node.json');
|
||||
var data = json.decode(str) as List;
|
||||
nodes = data.map((e) => NodePo.fromJson(e)).toList();
|
||||
|
||||
var showBg = true;
|
||||
var themeIndex = 4;
|
||||
var fontIndex = 1;
|
||||
var codeIndex = 0;
|
||||
var itemStyleIndex = 1;
|
||||
|
||||
return GlobalState(
|
||||
|
||||
showBackGround: showBg,
|
||||
themeColor: Cons.themeColorSupport.keys.toList()[themeIndex],
|
||||
fontFamily: Cons.fontFamilySupport[fontIndex],
|
||||
@@ -57,7 +64,7 @@ class AppStorage {
|
||||
} catch (_) {}
|
||||
ByteData data = await rootBundle.load(path.join("assets", "flutter.db"));
|
||||
List<int> bytes =
|
||||
data.buffer.asUint8List(data.offsetInBytes, data.lengthInBytes);
|
||||
data.buffer.asUint8List(data.offsetInBytes, data.lengthInBytes);
|
||||
await File(dbPath).writeAsBytes(bytes, flush: true);
|
||||
} else {
|
||||
print("========= 数据库 ======已存在====");
|
||||
|
||||
@@ -4,6 +4,7 @@ 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
|
||||
@@ -17,7 +18,7 @@ class BlocWrapper extends StatelessWidget {
|
||||
|
||||
BlocWrapper({this.child});
|
||||
|
||||
final repository = WidgetDbRepository(storage);
|
||||
final repository = WidgetInnerRepository(storage);
|
||||
final categoryRepo = CategoryDbRepository(storage);
|
||||
|
||||
@override
|
||||
|
||||
@@ -36,7 +36,7 @@ class _UnitNavigationState extends State<UnitNavigation> {
|
||||
_controller.dispose(); //释放控制器
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
final tempText = Text('这里是一片未知的领域\n等待着勇者的探寻...',style: TextStyle(fontSize: 24,color: Colors.white),);
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return BlocBuilder<HomeBloc, HomeState>(
|
||||
@@ -59,10 +59,15 @@ class _UnitNavigationState extends State<UnitNavigation> {
|
||||
controller: _controller,
|
||||
children: <Widget>[
|
||||
HomePage(),
|
||||
CollectPage(),
|
||||
PaintUnitPage(),
|
||||
LayoutUnitPage(),
|
||||
BugUnitPage(),
|
||||
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(),
|
||||
],
|
||||
),
|
||||
),
|
||||
|
||||
@@ -23,7 +23,7 @@ class UnitSplash extends StatefulWidget {
|
||||
class _UnitSplashState extends State<UnitSplash> with TickerProviderStateMixin {
|
||||
AnimationController _controller;
|
||||
AnimationController _secondController;
|
||||
double _factor;
|
||||
double _factor=0.0;
|
||||
Animation _curveAnim;
|
||||
|
||||
bool _animEnd = false;
|
||||
@@ -69,9 +69,10 @@ class _UnitSplashState extends State<UnitSplash> with TickerProviderStateMixin {
|
||||
Container(
|
||||
width: winW,
|
||||
height: winH,
|
||||
child: CustomPaint(
|
||||
painter: UnitPainter(factor: _factor),
|
||||
),
|
||||
child: Container()
|
||||
// CustomPaint(
|
||||
// painter: UnitPainter(factor: _factor),
|
||||
// ),
|
||||
),
|
||||
buildText(winH, winW),
|
||||
buildHead(),
|
||||
@@ -138,8 +139,8 @@ class _UnitSplashState extends State<UnitSplash> with TickerProviderStateMixin {
|
||||
begin: const Offset(0, -5),
|
||||
).animate(_controller),
|
||||
child: Container(
|
||||
height: 45,
|
||||
width: 45,
|
||||
height: 150*_factor,
|
||||
width: 150*_factor,
|
||||
child: Image.asset('assets/images/icon_head.png'),
|
||||
));
|
||||
|
||||
|
||||
@@ -62,7 +62,7 @@ class _WidgetDetailPageState extends State<WidgetDetailPage> {
|
||||
actions: <Widget>[
|
||||
Builder(builder: (ctx)=>GestureDetector(
|
||||
onLongPress: (){
|
||||
Scaffold.of(ctx).openEndDrawer();
|
||||
// Scaffold.of(ctx).openEndDrawer();
|
||||
},
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(15.0),
|
||||
@@ -71,7 +71,7 @@ class _WidgetDetailPageState extends State<WidgetDetailPage> {
|
||||
onTap: () {
|
||||
Navigator.of(ctx).pop();
|
||||
})),
|
||||
_buildCollectButton(_models.last, context),
|
||||
// _buildCollectButton(_models.last, context),
|
||||
],
|
||||
),
|
||||
body: SingleChildScrollView(
|
||||
|
||||
@@ -101,7 +101,7 @@ class HomeDrawer extends StatelessWidget {
|
||||
title: Text('属性集录'),
|
||||
trailing: _nextIcon(context),
|
||||
onTap: () {
|
||||
Navigator.of(context).pushNamed(Router.attr);
|
||||
// Navigator.of(context).pushNamed(Router.attr);
|
||||
},
|
||||
),
|
||||
ListTile(
|
||||
@@ -111,7 +111,7 @@ class HomeDrawer extends StatelessWidget {
|
||||
),
|
||||
title: Text('绘画集录'),
|
||||
trailing: _nextIcon(context),
|
||||
onTap: () => Navigator.of(context).pushNamed(Router.paint),
|
||||
// onTap: () => Navigator.of(context).pushNamed(Router.paint),
|
||||
),
|
||||
ListTile(
|
||||
leading: Icon(
|
||||
@@ -121,7 +121,7 @@ class HomeDrawer extends StatelessWidget {
|
||||
title: Text('布局集录'),
|
||||
trailing: _nextIcon(context),
|
||||
onTap: () {
|
||||
Navigator.of(context).pushNamed(Router.layout);
|
||||
// Navigator.of(context).pushNamed(Router.layout);
|
||||
},
|
||||
),
|
||||
ListTile(
|
||||
@@ -132,7 +132,7 @@ class HomeDrawer extends StatelessWidget {
|
||||
trailing: _nextIcon(context),
|
||||
title: Text('bug/feature 集录'),
|
||||
onTap: () {
|
||||
Navigator.of(context).pushNamed(Router.bug);
|
||||
// Navigator.of(context).pushNamed(Router.bug);
|
||||
},
|
||||
),
|
||||
],
|
||||
|
||||
@@ -27,7 +27,6 @@ class _HomePageState extends State<HomePage> {
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
print(Directory.current.path);
|
||||
_ctrl = ScrollController()..addListener(_updateAppBarHeight);
|
||||
super.initState();
|
||||
}
|
||||
@@ -56,10 +55,10 @@ class _HomePageState extends State<HomePage> {
|
||||
}
|
||||
|
||||
final gridDelegate = const SliverGridDelegateWithFixedCrossAxisCount(
|
||||
crossAxisCount: 2,
|
||||
crossAxisCount: 3,
|
||||
mainAxisSpacing: 10,
|
||||
crossAxisSpacing: 20,
|
||||
childAspectRatio: 3.0,
|
||||
childAspectRatio: 4,
|
||||
);
|
||||
|
||||
Widget _buildContent(BuildContext context, HomeState state) {
|
||||
|
||||
@@ -6,6 +6,7 @@ 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';
|
||||
@@ -111,10 +112,10 @@ class _SearchPageState extends State<SearchPage> {
|
||||
Widget _buildSliverList(List<WidgetModel> models) => SliverPadding(
|
||||
padding: EdgeInsets.all(20),
|
||||
sliver: SliverGrid.count(
|
||||
crossAxisCount: 2,
|
||||
crossAxisCount: 3,
|
||||
mainAxisSpacing: 10,
|
||||
crossAxisSpacing: 20,
|
||||
childAspectRatio: 3.5,
|
||||
childAspectRatio: 4,
|
||||
children: models
|
||||
.asMap()
|
||||
.keys
|
||||
@@ -122,9 +123,7 @@ class _SearchPageState extends State<SearchPage> {
|
||||
// margin: EdgeInsets.symmetric(horizontal: 15, vertical: 5),
|
||||
child: InkWell(
|
||||
onTap: () => _toDetailPage(models[index]),
|
||||
child: TechnoWidgetListItem(
|
||||
data: models[index],
|
||||
)),
|
||||
child: HomeItemSupport.get(models[index], 1)),
|
||||
))
|
||||
.toList(),
|
||||
// delegate: SliverChildBuilderDelegate(
|
||||
@@ -147,8 +146,7 @@ class _SearchPageState extends State<SearchPage> {
|
||||
if (temp.length < 5) {
|
||||
temp.addAll(List.generate(5 - temp.length, (e) => -1));
|
||||
}
|
||||
BlocProvider.of<SearchBloc>(context)
|
||||
.add(EventTextChanged(args: SearchArgs(name: '', stars: temp)));
|
||||
BlocProvider.of<SearchBloc>(context).add(EventTextChanged(args: SearchArgs(name: '', stars: temp)));
|
||||
}
|
||||
|
||||
_toDetailPage(WidgetModel model) {
|
||||
|
||||
@@ -34,7 +34,7 @@ class Hello {
|
||||
crossAxisCount: 2,
|
||||
mainAxisSpacing: 10,
|
||||
crossAxisSpacing: 20,
|
||||
childAspectRatio: 1.5,
|
||||
childAspectRatio: 2.5,
|
||||
);
|
||||
|
||||
@override
|
||||
|
||||
@@ -35,16 +35,16 @@ class SettingPage extends StatelessWidget {
|
||||
trailing: _nextIcon(context),
|
||||
onTap: () => Navigator.of(context).pushNamed(Router.font_setting),
|
||||
),
|
||||
Divider(),
|
||||
ListTile(
|
||||
leading: Icon(
|
||||
TolyIcon.icon_item,
|
||||
color: Theme.of(context).primaryColor,
|
||||
),
|
||||
title: Text('item样式设置'),
|
||||
trailing: _nextIcon(context),
|
||||
onTap: () => Navigator.of(context).pushNamed(Router.item_style_setting),
|
||||
),
|
||||
// Divider(),
|
||||
// ListTile(
|
||||
// leading: Icon(
|
||||
// TolyIcon.icon_item,
|
||||
// color: Theme.of(context).primaryColor,
|
||||
// ),
|
||||
// title: Text('item样式设置'),
|
||||
// trailing: _nextIcon(context),
|
||||
// onTap: () => Navigator.of(context).pushNamed(Router.item_style_setting),
|
||||
// ),
|
||||
Divider(),
|
||||
ListTile(
|
||||
leading: Icon(
|
||||
|
||||
Binary file not shown.
@@ -12,45 +12,51 @@ import 'package:flutter/material.dart';
|
||||
class RichTextWithWidget extends StatelessWidget {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return RichText(
|
||||
text: TextSpan(
|
||||
text: 'hello ',
|
||||
style: TextStyle(color: Colors.black, fontSize: 18),
|
||||
children: <InlineSpan>[
|
||||
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 Container(
|
||||
width: 300,
|
||||
height: 60,
|
||||
alignment: Alignment.center,
|
||||
child: Text('暂不支持Web')
|
||||
// RichText(
|
||||
// text: TextSpan(
|
||||
// text: 'hello ',
|
||||
// style: TextStyle(color: Colors.black, fontSize: 18),
|
||||
// children: <InlineSpan>[
|
||||
// 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',
|
||||
// ),
|
||||
// ],
|
||||
// ),
|
||||
// ),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
22
lib/views/widgets/Other/PerformanceOverlay/node1_base.dart
Normal file
22
lib/views/widgets/Other/PerformanceOverlay/node1_base.dart
Normal file
@@ -0,0 +1,22 @@
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
/// create by 张风捷特烈 on 2020/7/22
|
||||
/// contact me by email 1981462002@qq.com
|
||||
/// 说明: 312 PerformanceOverlay 性能浮层 6 可以非常方便地开启性能监测的两个柱图,方便查看刷新界面时帧率的变化情况。
|
||||
// {
|
||||
// "widgetId": 312,
|
||||
// "name": "PerformanceOverlay基本使用",
|
||||
// "priority": 1,
|
||||
// "subtitle": "使用PerformanceOverlay.allEnabled可以开始所有的监测项。",
|
||||
// }
|
||||
|
||||
class PerformanceOverlayDemo extends StatelessWidget {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return PerformanceOverlay.allEnabled(
|
||||
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
100
lib/views/widgets/Other/RawImage/node1_base.dart
Normal file
100
lib/views/widgets/Other/RawImage/node1_base.dart
Normal file
@@ -0,0 +1,100 @@
|
||||
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
|
||||
/// 说明: 313 RawImage 6 是实现Image组件的核心组件,可以显示ui的Image,基本属性同Image,一般很少单独使用。
|
||||
// {
|
||||
// "widgetId": 313,
|
||||
// "name": "RawImage基本使用",
|
||||
// "priority": 1,
|
||||
// "subtitle": "【image】 : 图片 【ui.Image】\n"
|
||||
// "【width】 : 宽 【int】\n"
|
||||
// "【height】: 高 【int】\n"
|
||||
// "【isAntiAlias】: 是否抗锯齿 【bool】\n"
|
||||
// "【filterQuality】: 过滤质量 【FilterQuality】\n"
|
||||
// "很多属性同Image,详见之.",
|
||||
// }
|
||||
class RawImageDemo extends StatefulWidget {
|
||||
@override
|
||||
_RawImageDemoState createState() => _RawImageDemoState();
|
||||
}
|
||||
|
||||
class _RawImageDemoState extends State<RawImageDemo> {
|
||||
ui.Image _image;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
_loadImageFromAssets('assets/images/icon_head.png');
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
if (_image == null)
|
||||
return Container(
|
||||
width: 80,
|
||||
height: 80,
|
||||
);
|
||||
|
||||
return Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
|
||||
children: [
|
||||
Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
RawImage(
|
||||
image: _image,
|
||||
width: 150,
|
||||
height: 150,
|
||||
isAntiAlias: true,
|
||||
filterQuality: FilterQuality.high,
|
||||
),
|
||||
Text('isAntiAlias: true'),
|
||||
Text('FilterQuality.high')
|
||||
],
|
||||
),
|
||||
Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
RawImage(
|
||||
image: _image,
|
||||
width: 150,
|
||||
height: 150,
|
||||
isAntiAlias: false,
|
||||
),
|
||||
Text('isAntiAlias: false'),
|
||||
Text('FilterQuality.low')
|
||||
],
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
void _loadImageFromAssets(String name) async {
|
||||
_image = await loadImageByProvider(AssetImage(name));
|
||||
|
||||
setState(() {});
|
||||
}
|
||||
|
||||
//通过ImageProvider读取Image
|
||||
Future<ui.Image> loadImageByProvider(
|
||||
ImageProvider provider, {
|
||||
ImageConfiguration config = ImageConfiguration.empty,
|
||||
}) async {
|
||||
Completer<ui.Image> completer = Completer<ui.Image>(); //完成的回调
|
||||
ImageStreamListener listener;
|
||||
ImageStream stream = provider.resolve(config); //获取图片流
|
||||
listener = ImageStreamListener((ImageInfo frame, bool sync) {
|
||||
//监听
|
||||
final ui.Image image = frame.image;
|
||||
completer.complete(image); //完成
|
||||
stream.removeListener(listener); //移除监听
|
||||
});
|
||||
stream.addListener(listener); //添加监听
|
||||
return completer.future; //返回
|
||||
}
|
||||
}
|
||||
46
lib/views/widgets/ProxyWidget/ButtonBarTheme/node1_base.dart
Normal file
46
lib/views/widgets/ProxyWidget/ButtonBarTheme/node1_base.dart
Normal file
@@ -0,0 +1,46 @@
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
/// create by 张风捷特烈 on 2020/7/22
|
||||
/// contact me by email 1981462002@qq.com
|
||||
/// 说明: 338 ButtonBarTheme 5 主要用于为后代的ButtonBar组件统一设置默认属性,也可以通过该组件获取默认ButtonBarTheme的属性。
|
||||
// {
|
||||
// "widgetId": 338,
|
||||
// "name": "ButtonBarTheme基本使用",
|
||||
// "priority": 1,
|
||||
// "subtitle": "可指定ButtonBarThemeData数据属性为【后代】的ButtonBar组件设置默认样式,如对齐方式、样式、边距等。也可以用ButtonBarTheme.of获取ButtonBar的主题属性。",
|
||||
// }
|
||||
|
||||
class ButtonBarThemeDemo extends StatelessWidget {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return ButtonBarTheme(
|
||||
child: TempButtonBar(),
|
||||
data: ButtonBarTheme.of(context).copyWith(
|
||||
alignment: MainAxisAlignment.center,
|
||||
buttonPadding: EdgeInsets.symmetric(horizontal: 6),
|
||||
overflowDirection: VerticalDirection.up,
|
||||
buttonMinWidth: 150,
|
||||
buttonHeight: 30,
|
||||
buttonTextTheme: ButtonTextTheme.primary));
|
||||
}
|
||||
}
|
||||
|
||||
class TempButtonBar extends StatelessWidget {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return ButtonBar(
|
||||
alignment: MainAxisAlignment.center,
|
||||
children: <Widget>[
|
||||
RaisedButton(
|
||||
color: Colors.blue, child: Text("1.Raised"), onPressed: () {}),
|
||||
OutlineButton(child: Text("2.Outline"), onPressed: () {}),
|
||||
FlatButton(
|
||||
color: Colors.blue,
|
||||
onPressed: () {},
|
||||
child: Text("3.Flat"),
|
||||
)
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
||||
51
lib/views/widgets/ProxyWidget/TooltipTheme/node1_base.dart
Normal file
51
lib/views/widgets/ProxyWidget/TooltipTheme/node1_base.dart
Normal file
@@ -0,0 +1,51 @@
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
/// create by 张风捷特烈 on 2020/7/22
|
||||
/// contact me by email 1981462002@qq.com
|
||||
/// 说明: 333 TooltipTheme 5 主要用于为后代的Tooltip组件统一设置默认属性,也可以通过该组件获取默认TooltipTheme的属性。
|
||||
// {
|
||||
// "widgetId": 333,
|
||||
// "name": "TooltipTheme基本使用",
|
||||
// "priority": 1,
|
||||
// "subtitle": "可指定TooltipThemeData数据属性为【后代】的Tooltip组件设置默认样式,如装饰、文字样式、显示时长、边距等。也可以用TooltipTheme.of获取Tooltip的主题属性。",
|
||||
// }
|
||||
|
||||
class TooltipThemeDemo extends StatelessWidget {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return TooltipTheme(
|
||||
child: TempTooltip(),
|
||||
data: TooltipTheme.of(context).copyWith(
|
||||
preferBelow: false,
|
||||
padding: EdgeInsets.all(5),
|
||||
verticalOffset: 20,
|
||||
margin: EdgeInsets.all(2),
|
||||
textStyle: TextStyle(
|
||||
color: Colors.red,
|
||||
shadows: [Shadow(color: Colors.white, offset: Offset(1, 1))]),
|
||||
decoration: BoxDecoration(boxShadow: [
|
||||
BoxShadow(
|
||||
color: Colors.orangeAccent,
|
||||
offset: Offset(1, 1),
|
||||
blurRadius: 8)
|
||||
])));
|
||||
}
|
||||
}
|
||||
|
||||
class TempTooltip extends StatelessWidget {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
|
||||
children: [
|
||||
Tooltip(
|
||||
message: "天王盖地虎",
|
||||
child: Icon(Icons.info_outline)),
|
||||
Tooltip(
|
||||
message: "宝塔镇河妖",
|
||||
child: Icon(Icons.info_outline)),
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
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
|
||||
/// 说明: 352 CupertinoDialogAction 0 一个简单的按钮,通常用于CupertinoAlertDialog中,一般不单独使用。
|
||||
// {
|
||||
// "widgetId": 352,
|
||||
// "name": "CupertinoDialogAction基本使用",
|
||||
// "priority": 1,
|
||||
// "subtitle": "【isDefaultAction】 : 是否是默认性操作 【bool】\n"
|
||||
// "【isDestructiveAction】 : 是否是毁灭性操作 【bool】\n"
|
||||
// "【textStyle】: 文字样式 【TextStyle】\n"
|
||||
// "【onPressed】: 点击事件 【VoidCallback】\n"
|
||||
// "【child】: 子组件 【Widget】",
|
||||
// }
|
||||
class CupertinoDialogActionDemo extends StatelessWidget {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Column(
|
||||
children: [
|
||||
CupertinoDialogAction(
|
||||
isDestructiveAction: false,
|
||||
onPressed: ()=>_toast(context),
|
||||
child: Text('CupertinoDialogAction'),
|
||||
),
|
||||
CupertinoDialogAction(
|
||||
isDestructiveAction: true,
|
||||
onPressed: ()=>_toast(context),
|
||||
child: Text('CupertinoDialogAction'),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
_toast(BuildContext context){
|
||||
Scaffold.of(context).showSnackBar(SnackBar(
|
||||
backgroundColor: Theme.of(context).primaryColor,
|
||||
content: Text('CupertinoDialogAction'),));
|
||||
}
|
||||
}
|
||||
60
lib/views/widgets/StatelessWidget/zz_no/CupertinoSegmentedControlTest.dart
Executable file
60
lib/views/widgets/StatelessWidget/zz_no/CupertinoSegmentedControlTest.dart
Executable file
@@ -0,0 +1,60 @@
|
||||
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<CupertinoSegmentedControlTest> {
|
||||
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'),
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -6,4 +6,6 @@ library other_unit.dart;
|
||||
|
||||
|
||||
export '../Other/ErrorWidget/node1_base.dart';
|
||||
export '../Other/Table/node1_base.dart';
|
||||
export '../Other/Table/node1_base.dart';
|
||||
export '../Other/RawImage/node1_base.dart';
|
||||
export '../Other/PerformanceOverlay/node1_base.dart';
|
||||
@@ -22,4 +22,6 @@ export '../ProxyWidget/ChipTheme/node1_base.dart' hide CustomFilterChip;
|
||||
export '../ProxyWidget/ListTileTheme/node1_base.dart';
|
||||
export '../ProxyWidget/MaterialBannerTheme/node1_base.dart';
|
||||
export '../ProxyWidget/PopupMenuTheme/node1_base.dart';
|
||||
export '../ProxyWidget/ToggleButtonsTheme/node1_base.dart';
|
||||
export '../ProxyWidget/ToggleButtonsTheme/node1_base.dart';
|
||||
export '../ProxyWidget/ButtonBarTheme/node1_base.dart';
|
||||
export '../ProxyWidget/TooltipTheme/node1_base.dart';
|
||||
|
||||
@@ -11,6 +11,7 @@ export '../StatelessWidget/PreferredSize/node1_base.dart';
|
||||
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/CheckboxListTile/node1_base.dart';
|
||||
export '../StatelessWidget/CheckboxListTile/node2_select.dart';
|
||||
|
||||
@@ -103,10 +103,30 @@ class WidgetsMap {
|
||||
return [
|
||||
ToggleButtonsThemeDemo(),
|
||||
];
|
||||
case "PerformanceOverlay":
|
||||
return [
|
||||
PerformanceOverlayDemo(),
|
||||
];
|
||||
case "NavigationToolbar":
|
||||
return [
|
||||
NavigationToolbarDemo(),
|
||||
];
|
||||
case "CupertinoDialogAction":
|
||||
return [
|
||||
CupertinoDialogActionDemo(),
|
||||
];
|
||||
case "ButtonBarTheme":
|
||||
return [
|
||||
ButtonBarThemeDemo(),
|
||||
];
|
||||
case "RawImage":
|
||||
return [
|
||||
RawImageDemo(),
|
||||
];
|
||||
case "TooltipTheme":
|
||||
return [
|
||||
TooltipThemeDemo(),
|
||||
];
|
||||
case "CupertinoTextField":
|
||||
return [
|
||||
CupertinoTextFieldDemo(),
|
||||
@@ -134,7 +154,7 @@ class WidgetsMap {
|
||||
return [
|
||||
CustomFadeInImage(),
|
||||
];
|
||||
case "InteractiveViewer":
|
||||
case "InteractiveViewer":
|
||||
return [
|
||||
InteractiveViewerDemo(),
|
||||
InteractiveViewerDemo2(),
|
||||
@@ -149,7 +169,7 @@ class WidgetsMap {
|
||||
CustomVisibility(),
|
||||
ReplacementVisibility(),
|
||||
];
|
||||
case "RepaintBoundary":
|
||||
case "RepaintBoundary":
|
||||
return [
|
||||
RepaintBoundaryDemo(),
|
||||
RepaintBoundarySave(),
|
||||
|
||||
@@ -52,7 +52,7 @@ flutter:
|
||||
- assets/images/head_icon/
|
||||
- assets/images/widgets/
|
||||
# - assets/data/widget.json
|
||||
- assets/flutter.db
|
||||
- assets/data/node.json
|
||||
# To add assets to your application, add an assets section, like this:
|
||||
# assets:
|
||||
# - images/a_dot_burr.jpeg
|
||||
|
||||
Reference in New Issue
Block a user