开启性能浮层、CupertinoSegmentedControl组件

This commit is contained in:
toly
2020-06-30 18:31:39 +08:00
parent eed1773cee
commit f9d679dd10
8 changed files with 48 additions and 10 deletions

Binary file not shown.

View File

@@ -48,6 +48,9 @@ class GlobalBloc extends Bloc<GlobalEvent, GlobalState> {
..setBool(SP.showBackground, event.show); //固化数据
yield state.copyWith(showBackGround: event.show);
}
if (event is EventSwitchShowOver) {
yield state.copyWith(showPerformanceOverlay: event.show);
}
if (event is EventSwitchCoderTheme) {
await sp

View File

@@ -50,6 +50,15 @@ class EventSwitchShowBg extends GlobalEvent {
List<Object> get props => [show];
}
class EventSwitchShowOver extends GlobalEvent {
final bool show;
const EventSwitchShowOver(this.show);
@override
List<Object> get props => [show];
}
class EventChangeItemStyle extends GlobalEvent {
final int index;

View File

@@ -7,6 +7,7 @@ class GlobalState extends Equatable {
final bool showBackGround;
final int codeStyleIndex;
final int itemStyleIndex;
final bool showPerformanceOverlay;
const GlobalState({
this.fontFamily = 'ComicNeue',
@@ -14,11 +15,12 @@ class GlobalState extends Equatable {
this.showBackGround = true,
this.codeStyleIndex,
this.itemStyleIndex,
this.showPerformanceOverlay=false,
});
@override
List<Object> get props =>
[ fontFamily, themeColor, showBackGround, codeStyleIndex,itemStyleIndex];
[ fontFamily, themeColor, showBackGround, codeStyleIndex,itemStyleIndex,showPerformanceOverlay];
GlobalState copyWith({
double height,
@@ -27,6 +29,7 @@ class GlobalState extends Equatable {
bool showBackGround,
int codeStyleIndex,
int itemStyleIndex,
bool showPerformanceOverlay,
}) =>
GlobalState(
fontFamily: fontFamily ?? this.fontFamily,
@@ -34,12 +37,11 @@ class GlobalState extends Equatable {
showBackGround: showBackGround ?? this.showBackGround,
codeStyleIndex: codeStyleIndex ?? this.codeStyleIndex,
itemStyleIndex: itemStyleIndex ?? this.itemStyleIndex,
showPerformanceOverlay: showPerformanceOverlay ?? this.showPerformanceOverlay,
);
@override
String toString() {
return 'GlobalState{ fontFamily: $fontFamily, themeColor: $themeColor, showBackGround: $showBackGround, codeStyleIndex: $codeStyleIndex, itemStyleIndex: $itemStyleIndex}';
return 'GlobalState{fontFamily: $fontFamily, themeColor: $themeColor, showBackGround: $showBackGround, codeStyleIndex: $codeStyleIndex, itemStyleIndex: $itemStyleIndex, showPerformanceOverlay: $showPerformanceOverlay}';
}
}

View File

@@ -17,7 +17,7 @@ class FlutterApp extends StatelessWidget {
categoryBloc: BlocProvider.of<CategoryBloc>(context)),
child: MaterialApp(
// debugShowMaterialGrid: true,
// showPerformanceOverlay: true,
showPerformanceOverlay: state.showPerformanceOverlay,
// showSemanticsDebugger: true,
// checkerboardOffscreenLayers:true,
// checkerboardRasterCacheImages:true,

View File

@@ -59,6 +59,9 @@ class SettingPage extends StatelessWidget {
),
Divider(),
_buildShowBg(context),
Divider(),
_buildShowOver(context),
Divider(),
ListTile(
leading: Icon(
Icons.info,
@@ -88,6 +91,21 @@ class SettingPage extends StatelessWidget {
},
));
Widget _buildShowOver(BuildContext context) =>
BlocBuilder<GlobalBloc, GlobalState>(
builder: (_, state) => SwitchListTile(
value: state.showPerformanceOverlay,
secondary: Icon(
TolyIcon.icon_show,
color: Theme.of(context).primaryColor,
),
title: Text('显示性能浮层'),
onChanged: (show) {
BlocProvider.of<GlobalBloc>(context)
.add(EventSwitchShowOver(show));
},
));
Widget _nextIcon(BuildContext context) =>
Icon(Icons.chevron_right, color: Theme.of(context).primaryColor);
}

View File

@@ -28,6 +28,8 @@ export '../StatefulWidget/CircularProgressIndicator/node1_base.dart';
export '../StatefulWidget/CupertinoActivityIndicator/node1_base.dart';
export '../StatefulWidget/CupertinoSlider/node1_base.dart';
export '../StatefulWidget/CupertinoSwitch/node1_base.dart';
export '../StatefulWidget/CupertinoSegmentedControl/node1_base.dart';
export '../StatefulWidget/CupertinoSegmentedControl/node2_color.dart';
export '../StatefulWidget/Image/node1_base.dart';
export '../StatefulWidget/Image/node2_fit.dart';

View File

@@ -7,8 +7,6 @@ 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
/// 说明:
@@ -25,6 +23,11 @@ class WidgetsMap {
ContainerTransform(),
ContainerConstraints()
];
case "CupertinoSegmentedControl":
return [
CupertinoSegmentedControlDemo(),
CupertinoSegmentedControlColor()
];
case "Text":
return [
CustomText(),
@@ -172,7 +175,7 @@ class WidgetsMap {
return [
NestedScrollViewDemo(),
];
case "SliverOverlapAbsorber":
case "SliverOverlapAbsorber":
return [
SliverOverlapAbsorberDemo(),
];
@@ -674,7 +677,8 @@ class WidgetsMap {
case "LicensePage":
return [
CustomLicensePage(),
]; case "Builder":
];
case "Builder":
return [
BuilderDemo(),
];
@@ -692,7 +696,7 @@ class WidgetsMap {
return [
CustomTab(),
];
case "PreferredSize":
case "PreferredSize":
return [
CustomPreferredSize(),
AdapterPreferredSize(),