TF-733 Apply change font to body composer on web

This commit is contained in:
dab246
2022-07-21 15:41:59 +07:00
committed by Dat H. Pham
parent a98c646f53
commit ea64fe82e0
10 changed files with 213 additions and 133 deletions
@@ -7,6 +7,8 @@ import 'package:flutter/material.dart';
import 'package:flutter_svg/flutter_svg.dart';
import 'package:get/get.dart';
import 'package:jmap_dart_client/jmap/identities/identity.dart';
import 'package:pointer_interceptor/pointer_interceptor.dart';
import 'package:tmail_ui_user/features/composer/presentation/model/font_name_type.dart';
import 'package:tmail_ui_user/features/manage_account/presentation/language_and_region/extensions/locale_extension.dart';
class DropDownButtonWidget<T> extends StatelessWidget {
@@ -16,6 +18,9 @@ class DropDownButtonWidget<T> extends StatelessWidget {
final Function(T?)? onChanged;
final bool supportHint;
final bool supportSelectionIcon;
final double heightItem;
final double sizeIconChecked;
final double radiusButton;
const DropDownButtonWidget({
Key? key,
@@ -23,7 +28,10 @@ class DropDownButtonWidget<T> extends StatelessWidget {
required this.itemSelected,
this.onChanged,
this.supportHint = false,
this.supportSelectionIcon = false
this.supportSelectionIcon = false,
this.heightItem = 44,
this.sizeIconChecked = 20,
this.radiusButton = 10,
}) : super(key: key);
@override
@@ -31,92 +39,99 @@ class DropDownButtonWidget<T> extends StatelessWidget {
final _imagePaths = Get.find<ImagePaths>();
return DropdownButtonHideUnderline(
child: DropdownButton2<T>(
isExpanded: true,
hint: supportHint
? Row(children: [
Expanded(child: Text(
_getTextItemDropdown(context, item: itemSelected),
style: const TextStyle(fontSize: 16,
fontWeight: FontWeight.normal,
color: Colors.black),
maxLines: 1,
overflow: CommonTextStyle.defaultTextOverFlow,
)),
])
: null,
items: items
.map((item) => DropdownMenuItem<T>(
value: item,
child: Row(children: [
Expanded(child: Text(_getTextItemDropdown(context, item: item),
style: const TextStyle(
fontSize: 16,
fontWeight: FontWeight.normal,
color: Colors.black),
maxLines: 1,
overflow: CommonTextStyle.defaultTextOverFlow,
)),
if (supportSelectionIcon && item == itemSelected)
SvgPicture.asset(_imagePaths.icChecked,
width: 20,
height: 20,
fit: BoxFit.fill)
]),
))
.toList(),
value: itemSelected,
customButton: supportSelectionIcon
? Container(
height: 44,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(10),
border: Border.all(
color: AppColor.colorInputBorderCreateMailbox,
width: 0.5,
child: PointerInterceptor(
child: DropdownButton2<T>(
isExpanded: true,
hint: supportHint
? Row(children: [
Expanded(child: Text(
_getTextItemDropdown(context, item: itemSelected),
style: const TextStyle(fontSize: 16,
fontWeight: FontWeight.normal,
color: Colors.black),
maxLines: 1,
overflow: CommonTextStyle.defaultTextOverFlow,
)),
])
: null,
items: items
.map((item) => DropdownMenuItem<T>(
value: item,
child: PointerInterceptor(
child: SizedBox(
height: heightItem,
child: Row(children: [
Expanded(child: Text(_getTextItemDropdown(context, item: item),
style: const TextStyle(
fontSize: 16,
fontWeight: FontWeight.normal,
color: Colors.black),
maxLines: 1,
overflow: CommonTextStyle.defaultTextOverFlow,
)),
if (supportSelectionIcon && item == itemSelected)
SvgPicture.asset(_imagePaths.icChecked,
width: sizeIconChecked,
height: sizeIconChecked,
fit: BoxFit.fill)
]),
),
),
))
.toList(),
value: itemSelected,
customButton: supportSelectionIcon
? Container(
height: heightItem,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(radiusButton),
border: Border.all(
color: AppColor.colorInputBorderCreateMailbox,
width: 0.5,
),
color: AppColor.colorInputBackgroundCreateMailbox,
),
color: AppColor.colorInputBackgroundCreateMailbox,
),
padding: const EdgeInsets.only(left: 12, right: 10),
child: Row(children: [
Expanded(child: Text(
_getTextItemDropdown(context, item: itemSelected),
style: const TextStyle(fontSize: 16,
fontWeight: FontWeight.normal,
color: Colors.black),
maxLines: 1,
overflow: CommonTextStyle.defaultTextOverFlow,
)),
SvgPicture.asset(_imagePaths.icDropDown)
]),
)
: null,
onChanged: onChanged,
icon: SvgPicture.asset(_imagePaths.icDropDown),
buttonPadding: const EdgeInsets.symmetric(horizontal: 12),
buttonDecoration: BoxDecoration(
borderRadius: BorderRadius.circular(10),
border: Border.all(
color: AppColor.colorInputBorderCreateMailbox,
width: 0.5,
padding: const EdgeInsets.only(left: 12, right: 10),
child: Row(children: [
Expanded(child: Text(
_getTextItemDropdown(context, item: itemSelected),
style: const TextStyle(fontSize: 16,
fontWeight: FontWeight.normal,
color: Colors.black),
maxLines: 1,
overflow: CommonTextStyle.defaultTextOverFlow,
)),
SvgPicture.asset(_imagePaths.icDropDown)
]),
)
: null,
onChanged: onChanged,
icon: SvgPicture.asset(_imagePaths.icDropDown),
buttonPadding: const EdgeInsets.symmetric(horizontal: 12),
buttonDecoration: BoxDecoration(
borderRadius: BorderRadius.circular(radiusButton),
border: Border.all(
color: AppColor.colorInputBorderCreateMailbox,
width: 0.5,
),
color: AppColor.colorInputBackgroundCreateMailbox,
),
color: AppColor.colorInputBackgroundCreateMailbox,
itemHeight: heightItem,
buttonHeight: heightItem,
selectedItemHighlightColor: supportSelectionIcon
? Colors.white
: Colors.black12,
itemPadding: const EdgeInsets.symmetric(horizontal: 12),
dropdownMaxHeight: 200,
dropdownDecoration: BoxDecoration(
borderRadius: BorderRadius.circular(radiusButton),
color: Colors.white,
),
offset: const Offset(0.0, -8.0),
dropdownElevation: 4,
scrollbarRadius: const Radius.circular(40),
scrollbarThickness: 6,
),
itemHeight: 44,
buttonHeight: 44,
selectedItemHighlightColor: supportSelectionIcon
? Colors.white
: Colors.black12,
itemPadding: const EdgeInsets.symmetric(horizontal: 12),
dropdownMaxHeight: 200,
dropdownDecoration: BoxDecoration(
borderRadius: BorderRadius.circular(10),
color: Colors.white,
),
offset: const Offset(0.0, -8.0),
dropdownElevation: 4,
scrollbarRadius: const Radius.circular(40),
scrollbarThickness: 6,
),
);
}
@@ -128,6 +143,9 @@ class DropDownButtonWidget<T> extends StatelessWidget {
if (item is Locale) {
return item.getLanguageName(context);
}
if (item is FontNameType) {
return item.fontFamily;
}
return '';
}
}