Set default DividerTheme

(cherry picked from commit 9be02961277e990f8ded19106532f9c788eb1d7e)
This commit is contained in:
dab246
2023-12-19 18:55:07 +07:00
committed by Dat H. Pham
parent bd4fb500f6
commit ba83b319b8
23 changed files with 494 additions and 591 deletions
@@ -1,10 +1,9 @@
import 'package:core/core.dart';
import 'package:core/presentation/extensions/color_extension.dart';
import 'package:flutter/material.dart';
import 'package:flutter_svg/flutter_svg.dart';
typedef IconWebCallback = void Function();
typedef IconWebHasPositionCallback = void Function(RelativeRect);
typedef OnTapIconButtonCallbackAction = void Function();
typedef OnTapDownIconButtonCallbackAction = void Function(TapDownDetails tapDetails);
@@ -51,7 +50,7 @@ Widget buildSVGIconButton({
width: iconSize,
height: iconSize,
fit: BoxFit.fill,
colorFilter: iconColor.asFilter(),
colorFilter: iconColor?.asFilter(),
),
);
@@ -76,46 +75,6 @@ Widget buildSVGIconButton({
);
}
Widget buildIconWebHasPosition(BuildContext context, {
required Widget icon,
String? tooltip,
IconWebHasPositionCallback? onTapDown,
IconWebCallback? onTap,
}) {
return Material(
color: Colors.transparent,
shape: const CircleBorder(),
child: InkWell(
onTapDown: (detail) {
onTapDown?.call(detail.getPosition(context));
},
onTap: () => onTap?.call(),
borderRadius: const BorderRadius.all(Radius.circular(12)),
child: Tooltip(
message: tooltip ?? '',
child: icon,
)
),
);
}
Widget buildTextIcon(String text, {
TextStyle? textStyle,
EdgeInsetsGeometry? padding,
IconWebCallback? onTap,
}) {
return Material(
shape: const CircleBorder(),
color: Colors.transparent,
child: InkWell(
child: Padding(
padding: padding ?? const EdgeInsets.all(10),
child: Text(text, style: textStyle ?? const TextStyle(fontWeight: FontWeight.normal, fontSize: 15, color: AppColor.lineItemListColor))),
onTap: () => onTap?.call()
)
);
}
Widget buildTextButton(String text, {
TextStyle? textStyle,
double? width,
@@ -188,72 +147,4 @@ Widget buildButtonWrapText(String name, {
color: Colors.white)),
),
);
}
Widget buildIconWithLowerMenu(
Widget icon,
BuildContext context,
List<PopupMenuEntry> popupMenuItems,
Function(BuildContext context, RelativeRect? position,
List<PopupMenuEntry> popupMenuItems)
openPopUpMenuAction,
) {
return Builder(
builder: (iconContext) {
final screenSize = MediaQuery.of(context).size;
return buildIconWeb(
icon: icon,
onTap: () {
// get size and position of the icon
RenderBox box = iconContext.findRenderObject() as RenderBox;
Offset iconTopLeft = box.localToGlobal(Offset.zero);
final iconSize = box.size;
// calculate the popup position for popup menu action
final popupLeft = iconTopLeft.dx + iconSize.width * 3 / 4;
final popupTop = iconTopLeft.dy + iconSize.height * 4 / 5;
final popupRight = screenSize.width - popupLeft;
final popupBottom = screenSize.height - popupRight;
final position = RelativeRect.fromLTRB(
popupLeft, popupTop, popupRight, popupBottom);
openPopUpMenuAction(context, position, popupMenuItems);
});
},
);
}
Widget buildIconWithUpperMenu(
Widget icon,
BuildContext context,
List<PopupMenuEntry> popupMenuItems,
Function(BuildContext context, RelativeRect? position,
List<PopupMenuEntry> popupMenuItems)
openPopUpMenuAction,
) {
return Builder(
builder: (iconContext) {
final screenSize = MediaQuery.of(context).size;
return buildIconWeb(
icon: icon,
onTap: () {
// get size and position of the icon
RenderBox box = iconContext.findRenderObject() as RenderBox;
Offset iconTopLeft = box.localToGlobal(Offset.zero);
final iconSize = box.size;
// calculate the popup position for popup menu action
final popupLeft = iconTopLeft.dx + iconSize.width * 3 / 4;
final popupTop = iconTopLeft.dy - iconSize.height * 9 / 5;
final popupRight = screenSize.width - popupLeft;
final popupBottom = screenSize.height - popupRight;
final position = RelativeRect.fromLTRB(
popupLeft, popupTop, popupRight, popupBottom);
openPopUpMenuAction(context, position, popupMenuItems);
});
},
);
}
@@ -1,77 +1,68 @@
import 'package:core/core.dart';
import 'package:flutter/foundation.dart';
import 'package:core/presentation/extensions/color_extension.dart';
import 'package:core/presentation/resources/image_paths.dart';
import 'package:core/presentation/utils/style_utils.dart';
import 'package:core/presentation/views/button/tmail_button_widget.dart';
import 'package:flutter/material.dart';
import 'package:flutter_svg/flutter_svg.dart';
typedef OnOpenSearchViewAction = Function();
class SearchBarView extends StatelessWidget {
final OnOpenSearchViewAction? onOpenSearchViewAction;
final ImagePaths _imagePaths;
final double? heightSearchBar;
final EdgeInsets? padding;
final EdgeInsets? margin;
final ImagePaths imagePaths;
final EdgeInsetsGeometry? margin;
final String? hintTextSearch;
final double? maxSizeWidth;
final Widget? rightButton;
final double? radius;
const SearchBarView(this._imagePaths, {Key? key,
this.heightSearchBar,
this.padding,
this.margin,
this.hintTextSearch,
this.maxSizeWidth,
this.rightButton,
this.onOpenSearchViewAction,
this.radius,
const SearchBarView({
Key? key,
required this.imagePaths,
this.margin,
this.hintTextSearch,
this.onOpenSearchViewAction,
}) : super(key: key);
@override
Widget build(BuildContext context) {
return Container(
key: const Key('search_bar_widget'),
alignment: Alignment.center,
height: heightSearchBar ?? 40,
width: maxSizeWidth ?? double.infinity,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(radius ?? 10),
color: AppColor.colorBgSearchBar),
padding: padding ?? EdgeInsets.zero,
margin: margin ?? EdgeInsets.zero,
child: InkWell(
onTap: onOpenSearchViewAction,
mouseCursor: SystemMouseCursors.text,
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
const SizedBox(width: 8),
buildIconWeb(
minSize: 40,
iconPadding: EdgeInsets.zero,
icon: SvgPicture.asset(
_imagePaths.icSearchBar,
fit: BoxFit.fill
return Padding(
padding: margin ?? EdgeInsets.zero,
child: InkWell(
onTap: onOpenSearchViewAction,
mouseCursor: SystemMouseCursors.text,
splashColor: Colors.transparent,
borderRadius: const BorderRadius.all(Radius.circular(12)),
child: Container(
alignment: Alignment.center,
height: 40,
width: double.infinity,
decoration: const BoxDecoration(
borderRadius: BorderRadius.all(Radius.circular(12)),
color: AppColor.colorBgSearchBar
),
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
TMailButtonWidget.fromIcon(
icon: imagePaths.icSearchBar,
backgroundColor: Colors.transparent,
onTapActionCallback: onOpenSearchViewAction
),
onTap: onOpenSearchViewAction
),
Expanded(
child: Text(
Expanded(
child: Text(
hintTextSearch ?? '',
maxLines: 1,
overflow: CommonTextStyle.defaultTextOverFlow,
softWrap: CommonTextStyle.defaultSoftWrap,
style: const TextStyle(
fontSize: kIsWeb ? 15 : 17,
color: AppColor.colorHintSearchBar)),
),
if(rightButton != null)
rightButton!
]
),
fontSize: 17,
color: AppColor.colorHintSearchBar
)
),
)
]
),
),
),
);
}
}