-
Notifications
You must be signed in to change notification settings - Fork 74
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
TF-2421 Update new UI for app bar email list view
Signed-off-by: dab246 <[email protected]>
- Loading branch information
Showing
19 changed files
with
281 additions
and
336 deletions.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,105 +1,78 @@ | ||
import 'package:core/presentation/extensions/color_extension.dart'; | ||
import 'package:flutter/material.dart'; | ||
|
||
typedef OnTapAvatarActionClick = void Function(); | ||
typedef OnTapAvatarActionWithPositionClick = void Function(RelativeRect? position); | ||
typedef OnTapActionClick = void Function(); | ||
typedef OnTapWithPositionAction = void Function(RelativeRect position); | ||
|
||
class AvatarBuilder { | ||
class AvatarBuilder extends StatelessWidget { | ||
final String? text; | ||
final double? size; | ||
final Color? bgColor; | ||
final Color? textColor; | ||
final OnTapActionClick? onTapAction; | ||
final OnTapWithPositionAction? onTapWithPositionAction; | ||
final List<Color>? avatarColors; | ||
final List<BoxShadow>? boxShadows; | ||
final TextStyle? textStyle; | ||
|
||
BuildContext? _context; | ||
Key? _key; | ||
String? _text; | ||
double? _size; | ||
Color? _bgColor; | ||
Color? _textColor; | ||
OnTapAvatarActionClick? _onTapAvatarActionClick; | ||
OnTapAvatarActionWithPositionClick? _onTapAvatarActionWithPositionClick; | ||
List<Color>? _avatarColors; | ||
List<BoxShadow>? _boxShadows; | ||
TextStyle? _textStyle; | ||
const AvatarBuilder({ | ||
super.key, | ||
this.text, | ||
this.size, | ||
this.bgColor, | ||
this.textColor, | ||
this.onTapAction, | ||
this.onTapWithPositionAction, | ||
this.avatarColors, | ||
this.boxShadows, | ||
this.textStyle | ||
}); | ||
|
||
void key(Key key) { | ||
_key = key; | ||
} | ||
|
||
void context(BuildContext context) { | ||
_context = context; | ||
} | ||
|
||
void size(double size) { | ||
_size = size; | ||
} | ||
|
||
void text(String text) { | ||
_text = text; | ||
} | ||
|
||
void backgroundColor(Color bgColor) { | ||
_bgColor = bgColor; | ||
} | ||
|
||
void textColor(Color textColor) { | ||
_textColor = textColor; | ||
} | ||
|
||
void avatarColor(List<Color>? avatarColors) { | ||
_avatarColors = avatarColors; | ||
} | ||
|
||
void addBoxShadows(List<BoxShadow>? boxShadows) { | ||
_boxShadows = boxShadows; | ||
} | ||
|
||
void addTextStyle(TextStyle? textStyle) { | ||
_textStyle = textStyle; | ||
} | ||
|
||
void addOnTapActionClick(OnTapAvatarActionClick onTapAvatarActionClick) { | ||
_onTapAvatarActionClick = onTapAvatarActionClick; | ||
} | ||
|
||
void addOnTapAvatarActionWithPositionClick(OnTapAvatarActionWithPositionClick onTapAvatarActionWithPositionClick) { | ||
_onTapAvatarActionWithPositionClick = onTapAvatarActionWithPositionClick; | ||
} | ||
|
||
Widget build() { | ||
return InkWell( | ||
onTap: () => _onTapAvatarActionClick != null ? _onTapAvatarActionClick!.call() : null, | ||
onTapDown: (detail) { | ||
if (_onTapAvatarActionWithPositionClick != null && _context != null) { | ||
final screenSize = MediaQuery.of(_context!).size; | ||
final offset = detail.globalPosition; | ||
final position = RelativeRect.fromLTRB( | ||
offset.dx, | ||
offset.dy, | ||
screenSize.width - offset.dx, | ||
screenSize.height - offset.dy, | ||
); | ||
_onTapAvatarActionWithPositionClick?.call(position); | ||
} | ||
}, | ||
borderRadius: BorderRadius.circular((_size ?? 40) / 2), | ||
child: Container( | ||
key: _key, | ||
width: _size ?? 40, | ||
height: _size ?? 40, | ||
padding: EdgeInsets.zero, | ||
margin: EdgeInsets.zero, | ||
@override | ||
Widget build(BuildContext context) { | ||
return Material( | ||
type: MaterialType.transparency, | ||
child: InkWell( | ||
onTap: onTapAction, | ||
onTapDown: (detail) { | ||
if (onTapWithPositionAction != null) { | ||
final screenSize = MediaQuery.of(context).size; | ||
final offset = detail.globalPosition; | ||
final position = RelativeRect.fromLTRB( | ||
offset.dx, | ||
offset.dy, | ||
screenSize.width - offset.dx, | ||
screenSize.height - offset.dy, | ||
); | ||
onTapWithPositionAction!(position); | ||
} | ||
}, | ||
customBorder: const CircleBorder(), | ||
child: Container( | ||
width: size ?? 40, | ||
height: size ?? 40, | ||
alignment: Alignment.center, | ||
decoration: BoxDecoration( | ||
borderRadius: BorderRadius.circular((_size ?? 40) * 0.5), | ||
border: Border.all(color: Colors.transparent), | ||
boxShadow: _boxShadows ?? [], | ||
gradient: _avatarColors?.isNotEmpty == true | ||
? LinearGradient(begin: Alignment.topCenter, end: Alignment.bottomCenter, tileMode: TileMode.decal, colors: _avatarColors ?? []) | ||
: null, | ||
color: _bgColor ?? AppColor.avatarColor | ||
decoration: ShapeDecoration( | ||
shape: const CircleBorder(), | ||
shadows: boxShadows ?? [], | ||
gradient: avatarColors?.isNotEmpty == true | ||
? LinearGradient( | ||
begin: Alignment.topCenter, | ||
end: Alignment.bottomCenter, | ||
tileMode: TileMode.decal, | ||
colors: avatarColors ?? []) | ||
: null, | ||
color: bgColor ?? AppColor.avatarColor | ||
), | ||
child: Text( | ||
_text ?? '', | ||
style: _textStyle ?? TextStyle(fontSize: 20, color: _textColor ?? AppColor.avatarTextColor, fontWeight: FontWeight.w500) | ||
text ?? '', | ||
style: textStyle ?? Theme.of(context).textTheme.bodyMedium?.copyWith( | ||
fontSize: 20, | ||
color: textColor ?? AppColor.avatarTextColor | ||
) | ||
) | ||
), | ||
), | ||
); | ||
} | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.