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

Add dartdoc #481

Merged
merged 7 commits into from
Aug 14, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
7 changes: 5 additions & 2 deletions lib/src/components/actionsheet/brn_common_action_sheet.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,10 @@ import 'package:bruno/src/theme/brn_theme_configurator.dart';
import 'package:bruno/src/theme/configs/brn_action_sheet_config.dart';
import 'package:flutter/material.dart';

/// Action Item 的点击事件回调
typedef BrnCommonActionSheetItemClickCallBack = void Function(
int index, BrnCommonActionSheetItem actionItem);
/// Action Item 点击事件拦截回调
typedef BrnCommonActionSheetItemClickInterceptor = bool Function(
int index, BrnCommonActionSheetItem actionItem);

Expand All @@ -20,6 +22,7 @@ enum BrnCommonActionSheetItemStyle {
alert,
}

/// create BrnCommonActionSheetItem
class BrnCommonActionSheetItem {
/// 标题文字
String title;
Expand Down Expand Up @@ -227,8 +230,8 @@ class BrnCommonActionSheet extends StatelessWidget {
);
}

// 配置每个选项内部信息
// action 每个item配置项 [BrnCommonActionSheetItem]
/// 配置每个选项内部信息
/// action 每个item配置项 [BrnCommonActionSheetItem]
Widget _configTile(BrnCommonActionSheetItem action) {
List<Widget> tileElements = [];
// 添加标题
Expand Down
28 changes: 19 additions & 9 deletions lib/src/components/actionsheet/brn_selected_list_action_sheet.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,13 @@ import 'package:bruno/src/l10n/brn_intl.dart';
import 'package:bruno/src/utils/brn_tools.dart';
import 'package:flutter/material.dart';

/// 获取对应 index 行内容的回调。类型必须为 String 或者自定义的 widget.自定义 widget 时,左边的 icon 会自动隐藏,自定义widget填充整行。
typedef BrnItemTitleBuilder<T> = dynamic Function(int index, T entity);

/// 每一行删除按钮的点击回调。返回值:是否要删除该 entity,如果该 handler 没有实现或者返回 true,则删除
typedef BrnItemDeleteCallback<T> = bool Function(int deleteIdx, T deleteEntity);

/// 视图隐藏时的回调,会把是否是清空按钮触发的销毁视图回传
typedef BrnListDismissCallback = void Function(bool isClosedByClearButton);


Expand All @@ -20,7 +25,7 @@ class BrnSelectedListActionSheetController extends ChangeNotifier {
/// 是否关闭列表
bool isSelectedListDismissed = false;

// 视图是否隐藏
/// 视图是否隐藏
bool _isHidden = true;

/// 刷新整个列表数据
Expand All @@ -38,6 +43,7 @@ class BrnSelectedListActionSheetController extends ChangeNotifier {
notifyListeners();
}

/// 视图是否隐藏
bool get isHidden {
return _isHidden;
}
Expand All @@ -50,6 +56,8 @@ class BrnSelectedListActionSheetController extends ChangeNotifier {
/// 自动与 globalKey 绑定的组件左右对齐,并从其顶部弹出。clear
/// 2. 外界需要自己监听 Android 上的系统返回事件,并且调用组件的 [dismiss] 方法!否则,组件不能正常关闭。
class BrnSelectedListActionSheet<T> {

/// 用来获取 Overlay
final BuildContext context;

/// 数据源列表
Expand Down Expand Up @@ -114,6 +122,7 @@ class BrnSelectedListActionSheet<T> {
double _bottomKeyOffset = 0;
double? _maxWidth;

/// create BrnSelectedListActionSheet
BrnSelectedListActionSheet(
{required this.context,
this.maxHeight = 290,
Expand Down Expand Up @@ -157,7 +166,7 @@ class BrnSelectedListActionSheet<T> {
_bottomKeyOffset = MediaQuery.of(context).size.height - (offset?.dy ?? 0);
this._innerShow(true);
}

/// 展示弹层
void show() {
this._innerShow(false);
}
Expand Down Expand Up @@ -296,7 +305,7 @@ class _BrnActionSheetSelectedItemListState<T>
duration: const Duration(milliseconds: 200), vsync: this);
widget._alphaAnimationController = alphaAnimationController;
Animation<double> yAnimation =
Tween(begin: 65.0, end: this.getContentHeight())
Tween(begin: 65.0, end: this._getContentHeight())
.animate(yAnimationController)
..addListener(() {
setState(() => {});
Expand All @@ -315,16 +324,17 @@ class _BrnActionSheetSelectedItemListState<T>
alphaAnimationController.forward();
}

/// 关闭弹窗
void dismissContent(bool isClear) {
_isClosedByClear = isClear;
widget.dismissWithAnimation();
}

double getContentHeight() {
double _getContentHeight() {
return widget.itemWidget.maxHeight;
}

void onClearAction() {
void _onClearAction() {
if (widget.itemWidget.onClear == null) {
// 如果没有实现 onClear,执行默认弹窗并删除的逻辑
this.dismissContent(true);
Expand All @@ -344,7 +354,7 @@ class _BrnActionSheetSelectedItemListState<T>
}
}

void onDeleteItemAction(int idx) {
void _onDeleteItemAction(int idx) {
if (idx >= widget.itemWidget.items.length) {
debugPrint(
'idx:$idx out of range of selectedModelList:${widget.itemWidget.items.length}!!!');
Expand Down Expand Up @@ -388,7 +398,7 @@ class _BrnActionSheetSelectedItemListState<T>
if (!widget.itemWidget.isClearButtonHidden) {
Widget clearWidget = GestureDetector(
onTap: () {
this.onClearAction();
this._onClearAction();
},
child: Padding(
padding: const EdgeInsets.fromLTRB(0, 20, 20, 15),
Expand Down Expand Up @@ -417,7 +427,7 @@ class _BrnActionSheetSelectedItemListState<T>
}

// 视图的高度
double contentHeight = this.getContentHeight();
double contentHeight = this._getContentHeight();

return GestureDetector(
onTap: () {
Expand Down Expand Up @@ -498,7 +508,7 @@ class _BrnActionSheetSelectedItemListState<T>
.itemWidget.isDeleteButtonHidden,
child: GestureDetector(
onTap: () {
this.onDeleteItemAction(index);
this._onDeleteItemAction(index);
},
child: Container(
color: Colors.white,
Expand Down
2 changes: 2 additions & 0 deletions lib/src/components/actionsheet/brn_share_action_sheet.dart
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ class BrnShareItem extends Object {
});
}

/// 分享弹窗
// ignore: must_be_immutable
class BrnShareActionSheet extends StatelessWidget {
/// 第一行渠道列表
Expand Down Expand Up @@ -88,6 +89,7 @@ class BrnShareActionSheet extends StatelessWidget {
child: SafeArea(child: _configActionWidgets(context)));
}

/// 显示弹窗
show(BuildContext context) {
showModalBottomSheet(
context: context,
Expand Down
13 changes: 6 additions & 7 deletions lib/src/components/appraise/brn_appraise.dart
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@ import 'package:bruno/src/components/appraise/brn_appraise_interface.dart';
/// 4. 可以用在页面里面也可以使用在弹窗里面,使用在底部弹窗的参考[BrnAppraiseBottomPicker]
/// /// /// /// /// /// /// /// /// /

const BrnAppraiseConfig cConfig = const BrnAppraiseConfig();

class BrnAppraise extends StatefulWidget {
/// 标题
final String title;
Expand Down Expand Up @@ -53,6 +51,7 @@ class BrnAppraise extends StatefulWidget {
/// 评价组件的配置项
final BrnAppraiseConfig config;

/// create BrnAppraise
BrnAppraise(
{Key? key,
this.title = '',
Expand All @@ -62,7 +61,7 @@ class BrnAppraise extends StatefulWidget {
this.tags,
this.inputHintText = '',
this.onConfirm,
this.config = cConfig})
this.config = const BrnAppraiseConfig()})
: super(key: key);

@override
Expand Down Expand Up @@ -178,7 +177,7 @@ class _BrnAppraiseState extends State<BrnAppraise> {
padding: EdgeInsets.all(0),
physics: NeverScrollableScrollPhysics(),
tagPickerBean: BrnTagsPickerConfig(
tagItemSource: string2Tag(widget.tags),
tagItemSource: _string2Tag(widget.tags),
),
tagText: (choice) {
return choice.name;
Expand All @@ -187,7 +186,7 @@ class _BrnAppraiseState extends State<BrnAppraise> {
multiSelect: widget.config.multiSelect,
brnCrossAxisCount: widget.config.tagCountEachRow,
selectedTagsCallback: (list) {
_selectedTag = tag2String(list);
_selectedTag = _tag2String(list);
if (widget.config.tagSelectCallback != null) {
widget.config.tagSelectCallback!(_selectedTag);
}
Expand Down Expand Up @@ -245,7 +244,7 @@ class _BrnAppraiseState extends State<BrnAppraise> {
return const SizedBox.shrink();
}

List<BrnTagItemBean> string2Tag(List<String>? tags) {
List<BrnTagItemBean> _string2Tag(List<String>? tags) {
List<BrnTagItemBean> items = [];
if (tags?.isNotEmpty ?? false) {
for (int i = 0; i < tags!.length; i++) {
Expand All @@ -255,7 +254,7 @@ class _BrnAppraiseState extends State<BrnAppraise> {
return items;
}

List<String> tag2String(List<BrnTagItemBean> tags) {
List<String> _tag2String(List<BrnTagItemBean> tags) {
List<String> result = [];
tags.forEach((item) {
result.add(item.name);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ class BrnAppraiseBottomPicker extends StatefulWidget {
/// 评价组件的配置项
final BrnAppraiseConfig config;

/// create BrnAppraiseBottomPicker
BrnAppraiseBottomPicker({
Key? key,
this.title = '',
Expand Down
1 change: 1 addition & 0 deletions lib/src/components/appraise/brn_appraise_config.dart
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ class BrnAppraiseConfig {
/// 选择标签的回调
final BrnAppraiseTagClick? tagSelectCallback;

/// create BrnAppraiseConfig
const BrnAppraiseConfig({
this.showHeader = true,
this.headerPadding,
Expand Down
1 change: 1 addition & 0 deletions lib/src/components/appraise/brn_appraise_emoji_item.dart
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ class BrnAppraiseEmojiItem extends StatefulWidget {
/// item的padding,默认 EdgeInsets.only(horizontal: 7)
final EdgeInsets padding;

/// create BrnAppraiseEmojiItem
BrnAppraiseEmojiItem(
{Key? key,
required this.selectedName,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ class BrnAppraiseEmojiListView extends StatefulWidget {
/// 点击回调
final BrnAppraiseIconClick? onTap;

/// create BrnAppraiseEmojiListView
BrnAppraiseEmojiListView(
{Key? key,
this.indexes = const [0, 1, 2, 3, 4],
Expand Down
3 changes: 2 additions & 1 deletion lib/src/components/appraise/brn_flutter_gif_image.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ import 'package:flutter/widgets.dart';
/// 描述: 用于加载gif图,
/// 参考来自github:https://github.com/peng8350/flutter_gifimage
/// 感谢 Jpeng

class GifImage extends StatefulWidget {
///
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这里是?

final VoidCallback? onFetchCompleted;
final AnimationController controller;
final ImageProvider image;
Expand All @@ -26,6 +26,7 @@ class GifImage extends StatefulWidget {
final bool excludeFromSemantics;
final Widget? defaultImage;

/// create GifImage
GifImage({
required this.image,
required this.controller,
Expand Down
1 change: 1 addition & 0 deletions lib/src/components/appraise/brn_mulit_select_tags.dart
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ class BrnMultiSelectTags extends StatefulWidget {
/// 最小宽度,默认 75
final double minWidth;

/// create BrnMultiSelectTags
BrnMultiSelectTags({
Key? key,
required this.tagPickerBean,
Expand Down
13 changes: 8 additions & 5 deletions lib/src/components/button/brn_big_ghost_button.dart
Original file line number Diff line number Diff line change
Expand Up @@ -21,22 +21,25 @@ import 'package:flutter/material.dart';
/// * [BrnBigOutlineButton], 大边框按钮

class BrnBigGhostButton extends StatelessWidget {
///按钮文案,默认'确认'
/// 按钮文案,默认'确认'
final String? title;

///文案颜色
/// 文案颜色
final Color? titleColor;

///按钮背景颜色
/// 按钮背景颜色
final Color? bgColor;

///点击回调
/// 点击回调
final VoidCallback? onTap;

///默认父布局可用空间
/// 默认父布局可用空间
final double? width;

/// button theme config
final BrnButtonConfig? themeData;

/// create BrnBigGhostButton
const BrnBigGhostButton({
Key? key,
this.title,
Expand Down
3 changes: 2 additions & 1 deletion lib/src/components/button/brn_big_main_button.dart
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ import 'brn_normal_button.dart';
/// 其他按钮如下:
/// * [BrnBigGhostButton], 大主色调的幽灵按钮
/// * [BrnBigOutlineButton], 大边框按钮

class BrnBigMainButton extends StatelessWidget {
///按钮显示文案,默认'确认'
final String? title;
Expand All @@ -44,8 +43,10 @@ class BrnBigMainButton extends StatelessWidget {
///背景颜色
final Color? bgColor;

/// button theme config
final BrnButtonConfig? themeData;

/// create BrnBigMainButton
const BrnBigMainButton({
Key? key,
this.title,
Expand Down
2 changes: 1 addition & 1 deletion lib/src/components/button/brn_icon_button.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import 'package:flutter/material.dart';
/// 为了解决icon和文字组合的问题
/// 图文的方向 bottom、文字在下 icon在上 top、文字在上 icon在下
/// Left、文字在左 icon在右 right、文字在右 icon在左

enum Direction {
/// 文字在左边
left,
Expand Down Expand Up @@ -54,6 +53,7 @@ class BrnIconButton extends StatefulWidget {
/// 图文对齐方式,默认 MainAxisAlignment.center
final MainAxisAlignment mainAxisAlignment;

/// create BrnIconButton
const BrnIconButton({
Key? key,
required this.name,
Expand Down
1 change: 1 addition & 0 deletions lib/src/components/button/brn_normal_button.dart
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ class BrnNormalButton extends StatelessWidget {
/// 按钮圆角大小
final BorderRadiusGeometry borderRadius;

/// create BrnNormalButton
BrnNormalButton({
Key? key,
required this.text,
Expand Down
Loading
Loading