Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

migrate picker to null safety #91

Merged
merged 39 commits into from
Jan 26, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
d2a37e0
Theme: 优化单例实现,初步优化 BrnAllThemeConfig 属性获取不为 null
zhoujuanjuan Dec 27, 2021
75a2be3
refactor:优化theme,暴露非null引用
zhoujuanjuan Dec 27, 2021
f97bf07
theme:去除无用信息及优化部分代码
zhoujuanjuan Dec 28, 2021
44ba17a
theme:增加属性类型
zhoujuanjuan Dec 28, 2021
cad7451
Merge branch 'LianjiaTech:null-safe' into null-safe
zhoujuanjuan Dec 31, 2021
c19203f
优化修复 EventBus
zhoujuanjuan Dec 31, 2021
c96cdd3
Merge branch 'LianjiaTech:null-safe' into null-safe
zhoujuanjuan Jan 4, 2022
2c99d35
Merge branch 'LianjiaTech:null-safe' into null-safe
zhoujuanjuan Jan 4, 2022
c7ae392
Merge branch 'LianjiaTech:null-safe' into null-safe
zhoujuanjuan Jan 5, 2022
6e0834b
迁移example ,优化常量命名,增加export
zhoujuanjuan Jan 4, 2022
5db665d
migrate brn_empty_status.dart
zhoujuanjuan Jan 5, 2022
7c12fc8
删除 BrnThemeImg
zhoujuanjuan Jan 6, 2022
0b75394
Merge remote-tracking branch 'upstream/null-safe' into null-safe
zhoujuanjuan Jan 6, 2022
c00cfd5
fix:tagConfig merge方法增加判空处理
zhoujuanjuan Jan 6, 2022
ada5216
fix:revert tagConfig
zhoujuanjuan Jan 7, 2022
beec378
fix:BrnAbnormalStateWidget空处理
zhoujuanjuan Jan 7, 2022
b852eb6
Merge branch 'LianjiaTech:null-safe' into null-safe
zhoujuanjuan Jan 7, 2022
e69a944
Merge branch 'LianjiaTech:null-safe' into null-safe
zhoujuanjuan Jan 10, 2022
e31532f
Merge branch 'LianjiaTech:null-safe' into null-safe
zhoujuanjuan Jan 11, 2022
162fcfe
Migrated tabbar to null-safety
zhoujuanjuan Jan 11, 2022
2bd473f
Merge branch 'LianjiaTech:null-safe' into null-safe
zhoujuanjuan Jan 12, 2022
103ab13
Migrated scroll_anchor to null-safety
zhoujuanjuan Jan 11, 2022
2b141fd
Merge branch 'LianjiaTech:null-safe' into null-safe
zhoujuanjuan Jan 13, 2022
04b7a3e
Merge branch 'LianjiaTech:null-safe' into null-safe
zhoujuanjuan Jan 17, 2022
5748da7
fix:修复迁移tabar问题
zhoujuanjuan Jan 17, 2022
8c25d72
Merge branch 'LianjiaTech:null-safe' into null-safe
zhoujuanjuan Jan 18, 2022
1c33fd9
migrate form to null safety
zhoujuanjuan Jan 18, 2022
07c308a
fix:修复tabbar报错及selection警告信息
zhoujuanjuan Jan 18, 2022
fdf45af
Merge branch 'LianjiaTech:null-safe' into null-safe
zhoujuanjuan Jan 19, 2022
e1749fe
Merge remote-tracking branch 'upstream/null-safe' into null-safe
zhoujuanjuan Jan 24, 2022
0b4c168
fix:修复迁移问题
zhoujuanjuan Jan 24, 2022
3f3b4d3
fix:优化迁移部分问题key和style非空问题
zhoujuanjuan Jan 24, 2022
1b89f72
Merge branch 'LianjiaTech:null-safe' into null-safe
zhoujuanjuan Jan 24, 2022
8b9e3ab
migrate picker to null safety
zhoujuanjuan Jan 24, 2022
fbe085a
Merge branch 'LianjiaTech:null-safe' into null-safe
zhoujuanjuan Jan 25, 2022
2d7fcc1
fix:修复picker空安全迁移问题
zhoujuanjuan Jan 25, 2022
a23e201
fix:修复list没指定泛型及if判断错误问题
zhoujuanjuan Jan 26, 2022
4fa42f7
Merge branch 'LianjiaTech:null-safe' into null-safe
zhoujuanjuan Jan 26, 2022
33ed04a
fix:migrate dashed line to null safty
zhoujuanjuan Jan 26, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions example/lib/sample/components/line/dashed_line_example.dart
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class _DashedLineExampleState extends State<DashedLineExample> {
axis: Axis.vertical,
color: Colors.red,
dashedOffset: 20,
position: BrnDashedLinePosition.DashedLineLeading,
position: BrnDashedLinePosition.leading,
contentWidget: Container(
margin: EdgeInsets.only(left: 60, right: 20, top: 10, bottom: 10),
child:
Expand All @@ -56,7 +56,7 @@ class _DashedLineExampleState extends State<DashedLineExample> {
axis: Axis.horizontal,
color: Colors.green,
dashedOffset: 20,
position: BrnDashedLinePosition.DashedLineLeading,
position: BrnDashedLinePosition.leading,
contentWidget: Container(
width: 200,
height: 100,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ class DatePickerExamplePage extends StatelessWidget {
format = 'HH时:mm分';
BrnPickerTitleConfig timePickerTheme = BrnPickerTitleConfig(
title: BrnPickerTitleConfig.Default.title,
showTitle: PICKER_SHOW_TITLE_DEFAULT,
showTitle: pickerShowTitleDefault,
titleContent: "选择时间范围");
BrnDateRangePicker.showDatePicker(context,
minDateTime: DateTime.parse(MIN_DATETIME),
Expand Down
12 changes: 6 additions & 6 deletions example/lib/sample/components/picker/picker_entry_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ class PickerEntryPage extends StatelessWidget {
describe: "底部级联选择框",
onPressed: () {
rootBundle.loadString('assets/list_picker.json').then((data) {
List<BrnPickerEntity> _selectionData = List()
List<BrnPickerEntity> _selectionData = []
..addAll((JsonDecoder().convert(data)["data"]['list'] as List ?? [])
.map((o) => BrnPickerEntity.fromMap(o)));
if (_selectionData != null && _selectionData.length > 0) {
Expand All @@ -100,7 +100,7 @@ class PickerEntryPage extends StatelessWidget {
describe: "底部级联选择框(Title 动态改变)",
onPressed: () {
rootBundle.loadString('assets/list_picker.json').then((data) {
List<BrnPickerEntity> _selectionData = List()
List<BrnPickerEntity> _selectionData = []
..addAll((JsonDecoder().convert(data)["data"]['list'] as List ?? [])
.map((o) => BrnPickerEntity.fromMap(o)));
if (_selectionData != null && _selectionData.length > 0) {
Expand Down Expand Up @@ -131,7 +131,7 @@ class PickerEntryPage extends StatelessWidget {

///多选弹框
void _showBottomMultiSelectPicker(BuildContext context) {
List<BrnMultiSelectBottomPickerItem> items = new List();
List<BrnMultiSelectBottomPickerItem> items = [];
items.add(new BrnMultiSelectBottomPickerItem("100", "这里是标题1"));
items.add(new BrnMultiSelectBottomPickerItem("101", "这里是标题2"));
items.add(new BrnMultiSelectBottomPickerItem("102", "这里是标题3", isChecked: true));
Expand Down Expand Up @@ -353,7 +353,7 @@ class PickerEntryPage extends StatelessWidget {
List<BrnTagInputItemBean> items = List();
for (int i = 0; i < tags.length; i++) {
String it = tags[i];
BrnTagInputItemBean item = BrnTagInputItemBean(name: it, index: i, needExplane: (i % 2 == 0));
BrnTagInputItemBean item = BrnTagInputItemBean(name: it, index: i, needExpend: (i % 2 == 0));
items.add(item);
}

Expand All @@ -371,8 +371,8 @@ class PickerEntryPage extends StatelessWidget {
tagItemSource: items,
tagTitleFontSize: 12,
tagTitleColor: Color(0xff222222),
tagBackgroudColor: Color(0xffF8F8F8),
selectedTagBackgroudColor: Color(0x140984F9),
tagBackgroundColor: Color(0xffF8F8F8),
selectedTagBackgroundColor: Color(0x140984F9),
selectedTagTitleColor: Color(0xFF0984F9),
),
onTagValueGetter: (choice) {
Expand Down
98 changes: 46 additions & 52 deletions lib/src/components/line/brn_dashed_line.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
// @dart=2.9

import 'package:bruno/src/theme/brn_theme_configurator.dart';
import 'package:flutter/material.dart';

Expand All @@ -13,33 +11,29 @@ import 'package:flutter/material.dart';
/// 分割线所在位置
enum BrnDashedLinePosition {
/// 头部
DashedLineTrailing,
trailing,

/// 尾部
DashedLineLeading,
leading,
}

/// 虚线分割线
class BrnDashedLine extends StatelessWidget {
/// 默认虚线方向
static const Axis _normalAxis = Axis.horizontal;
/// 默认虚线方向
const Axis _normalAxis = Axis.horizontal;

/// 默认虚线长度
static const double _normalDashedLength = 8;
/// 默认虚线长度
const double _normalDashedLength = 8;

/// 默认虚线厚度
static const double _normalDashedThickness = 1;
/// 默认虚线厚度
const double _normalDashedThickness = 1;

/// 默认间距
static const double _normalDashedSpacing = 4;
/// 默认间距
const double _normalDashedSpacing = 4;

/// 默认颜色
static Color _normalColor =
BrnThemeConfigurator.instance.getConfig().commonConfig.dividerColorBase;
/// 默认位置,头部
const BrnDashedLinePosition _normalPosition = BrnDashedLinePosition.leading;

/// 默认位置,头部
static const BrnDashedLinePosition _normalPosition =
BrnDashedLinePosition.DashedLineLeading;
/// 虚线分割线
class BrnDashedLine extends StatelessWidget {

/// 虚线方向,默认值[_normalAxis]
final Axis axis;
Expand All @@ -54,7 +48,7 @@ class BrnDashedLine extends StatelessWidget {
final double dashedSpacing;

/// 颜色,默认值[_normalColor]
final Color color;
final Color? color;

/// 虚线的Widget
final Widget contentWidget;
Expand All @@ -66,28 +60,28 @@ class BrnDashedLine extends StatelessWidget {
final BrnDashedLinePosition position;

BrnDashedLine({
Key key,
@required this.contentWidget,
this.axis,
this.dashedLength,
this.dashedThickness,
this.dashedSpacing,
Key? key,
required this.contentWidget,
this.axis = _normalAxis,
this.dashedLength = _normalDashedLength,
this.dashedThickness = _normalDashedThickness,
this.dashedSpacing = _normalDashedSpacing,
this.color,
this.dashedOffset,
this.position,
this.dashedOffset = 0.0,
this.position = _normalPosition,
});

@override
Widget build(BuildContext context) {
return CustomPaint(
painter: BrnDashedPainter(
axis: this.axis ?? _normalAxis,
dashedLength: this.dashedLength ?? _normalDashedLength,
dashedThickness: this.dashedThickness ?? _normalDashedThickness,
dashedSpacing: this.dashedSpacing ?? _normalDashedSpacing,
color: this.color ?? _normalColor,
dashedOffset: this.dashedOffset ?? 0,
position: this.position ?? _normalPosition),
axis: this.axis,
dashedLength: this.dashedLength ,
dashedThickness: this.dashedThickness,
dashedSpacing: this.dashedSpacing ,
color: this.color ,
dashedOffset: this.dashedOffset,
position: this.position),
child: this.contentWidget,
);
}
Expand All @@ -107,30 +101,30 @@ class BrnDashedPainter extends CustomPainter {
final double dashedSpacing;

/// 颜色
final Color color;
final Color? color;

/// 距离边缘的位置
final double dashedOffset;
final double? dashedOffset;

/// 分割线所在位置
final BrnDashedLinePosition position;
final BrnDashedLinePosition? position;

BrnDashedPainter({
this.axis,
this.dashedLength,
this.dashedThickness,
this.dashedSpacing,
this.axis = _normalAxis,
this.dashedLength = _normalDashedLength,
this.dashedThickness = _normalDashedThickness,
this.dashedSpacing = _normalDashedSpacing,
this.color,
this.dashedOffset,
this.position,
this.dashedOffset = 0.0,
this.position = _normalPosition,
});

@override
void paint(Canvas canvas, Size size) {
var paint = Paint() // 创建一个画笔并配置其属性
..strokeWidth = this.dashedThickness // 画笔的宽度
..isAntiAlias = true // 是否抗锯齿
..color = this.color; // 画笔颜色
..color = this.color?? BrnThemeConfigurator.instance.getConfig().commonConfig.dividerColorBase; // 画笔颜色

var maxWidth = size.width; // size获取到宽度
var maxHeight = size.height; // size获取到宽度
Expand All @@ -139,12 +133,12 @@ class BrnDashedPainter extends CustomPainter {
double startX = 0;
final space = (this.dashedSpacing + this.dashedLength);
double height = 0;
if (this.position == BrnDashedLinePosition.DashedLineLeading) {
if (this.position == BrnDashedLinePosition.leading) {
// 头部
height = dashedOffset + this.dashedThickness / 2;
height = dashedOffset! + this.dashedThickness / 2;
} else {
// 尾部
height = size.height - dashedOffset - this.dashedThickness / 2;
height = size.height - dashedOffset! - this.dashedThickness / 2;
}
while (startX < maxWidth) {
if ((maxWidth - startX) < this.dashedLength) {
Expand All @@ -161,12 +155,12 @@ class BrnDashedPainter extends CustomPainter {
double startY = 0;
final space = (this.dashedSpacing + this.dashedLength);
double width = 0;
if (this.position == BrnDashedLinePosition.DashedLineLeading) {
if (this.position == BrnDashedLinePosition.leading) {
// 头部
width = dashedOffset + this.dashedThickness / 2;
width = dashedOffset! + this.dashedThickness / 2;
} else {
// 尾部
width = size.width - dashedOffset - this.dashedThickness / 2;
width = size.width - dashedOffset! - this.dashedThickness / 2;
}
while (startY < maxHeight) {
if ((maxHeight - startY) < this.dashedLength) {
Expand Down
Loading