Skip to content

Commit

Permalink
fix: fix code style
Browse files Browse the repository at this point in the history
  • Loading branch information
broadli committed Feb 17, 2023
1 parent 8b63e0d commit 47ff1dc
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 55 deletions.
86 changes: 37 additions & 49 deletions example/lib/page/td_switch_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,9 @@ class TDSwitchPageState extends State<TDSwitchPage> {
children: [
ExampleItem(builder: (_) => _title('基础开关')),
ExampleItem(
builder: (_) => Container(
child: Column(
mainAxisSize: MainAxisSize.min,
children: [demoRow(context, '基础开关', on: true)],
),
builder: (_) => Column(
mainAxisSize: MainAxisSize.min,
children: [demoRow(context, '基础开关', on: true)],
)),
ExampleItem(builder: (_) => _title('带描述开关')),
ExampleItem(
Expand All @@ -52,64 +50,54 @@ class TDSwitchPageState extends State<TDSwitchPage> {
ExampleModule(title: '组件状态', children: [
ExampleItem(builder: (_) => _title('加载状态')),
ExampleItem(
builder: (_) => Container(
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
demoRow(
context,
'加载状态',
on: true,
enable: false,
type: TDSwitchType.loading,
),
demoRow(
context,
'加载状态',
on: false,
enable: false,
type: TDSwitchType.loading,
),
],
),
builder: (_) => Column(
mainAxisSize: MainAxisSize.min,
children: [
demoRow(
context,
'加载状态',
on: true,
enable: false,
type: TDSwitchType.loading,
),
demoRow(
context,
'加载状态',
on: false,
enable: false,
type: TDSwitchType.loading,
),
],
)),
ExampleItem(builder: (_) => _title('禁用状态')),
ExampleItem(
builder: (_) => Container(
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
demoRow(context, '禁用状态', on: false, enable: false),
demoRow(context, '禁用状态', on: true, enable: false),
],
),
builder: (_) => Column(
mainAxisSize: MainAxisSize.min,
children: [
demoRow(context, '禁用状态', on: false, enable: false),
demoRow(context, '禁用状态', on: true, enable: false),
],
)),
]),
ExampleModule(title: '组件样式', children: [
ExampleItem(builder: (_) => _title('开关尺寸')),
ExampleItem(
builder: (_) => Container(
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
demoRow(context, '大尺寸32',
on: true, size: TDSwitchSize.large),
demoRow(context, '中尺寸28',
on: true, size: TDSwitchSize.medium),
demoRow(context, '小尺寸24',
on: true, size: TDSwitchSize.small),
],
),
builder: (_) => Column(
mainAxisSize: MainAxisSize.min,
children: [
demoRow(context, '大尺寸32',
on: true, size: TDSwitchSize.large),
demoRow(context, '中尺寸28',
on: true, size: TDSwitchSize.medium),
demoRow(context, '小尺寸24',
on: true, size: TDSwitchSize.small),
],
)),
]),
]);
return current;
}

Widget _divider() {
return Container(height: 0.5, color: const Color(0x33999999));
}

Widget _title(String title) {
return Container(
height: 40,
Expand Down
4 changes: 1 addition & 3 deletions lib/src/components/switch/td_cupertino_switch.dart
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import 'package:flutter/gestures.dart';
import 'package:flutter/material.dart';
import 'package:flutter/rendering.dart';
import 'package:flutter/services.dart';
import 'package:flutter/widgets.dart';

// Examples can assume:
// bool _lights = false;
Expand Down Expand Up @@ -380,6 +379,7 @@ class _TDCupertinoSwitchRenderObjectWidget
/// The widget below this widget in the tree.
///
/// {@macro flutter.widgets.ProxyWidget.child}
@override
final Widget? child;

@override
Expand Down Expand Up @@ -475,7 +475,6 @@ class _RenderTDCupertinoSwitch extends RenderConstrainedBox {
Color _trackColor;

set trackColor(Color value) {
assert(value != null);
if (value == _trackColor) {
return;
}
Expand Down Expand Up @@ -513,7 +512,6 @@ class _RenderTDCupertinoSwitch extends RenderConstrainedBox {
TextDirection _textDirection;

set textDirection(TextDirection value) {
assert(value != null);
if (_textDirection == value) {
return;
}
Expand Down
8 changes: 5 additions & 3 deletions lib/src/components/switch/td_switch.dart
Original file line number Diff line number Diff line change
Expand Up @@ -104,8 +104,9 @@ class TDSwitchState extends State<TDSwitch> {
return 45;
case TDSwitchSize.small:
return 39;
default:
return 45;
}
return 45;
}

double _getHeight() {
Expand All @@ -116,8 +117,9 @@ class TDSwitchState extends State<TDSwitch> {
return 28;
case TDSwitchSize.small:
return 24;
default:
return 28;
}
return 28;
}

Widget? _getThumbView(Color onColor, Color offColor) {
Expand Down Expand Up @@ -147,8 +149,8 @@ class TDSwitchState extends State<TDSwitch> {
size: 16, color: isOn ? onColor : offColor),
);
case TDSwitchType.fill:
default:
return null;
}
return null;
}
}

0 comments on commit 47ff1dc

Please sign in to comment.