TF-381 Add logout action in browser new UI
This commit is contained in:
@@ -2,14 +2,18 @@ import 'package:core/presentation/extensions/color_extension.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
typedef OnTapAvatarActionClick = void Function();
|
||||
typedef OnTapAvatarActionWithPositionClick = void Function(RelativeRect? position);
|
||||
|
||||
class AvatarBuilder {
|
||||
|
||||
BuildContext? _context;
|
||||
Key? _key;
|
||||
String? _text;
|
||||
double? _size;
|
||||
Color? _bgColor;
|
||||
Color? _textColor;
|
||||
OnTapAvatarActionClick? _onTapAvatarActionClick;
|
||||
OnTapAvatarActionWithPositionClick? _onTapAvatarActionWithPositionClick;
|
||||
List<Color>? _avatarColors;
|
||||
List<BoxShadow>? _boxShadows;
|
||||
TextStyle? _textStyle;
|
||||
@@ -18,6 +22,10 @@ class AvatarBuilder {
|
||||
_key = key;
|
||||
}
|
||||
|
||||
void context(BuildContext context) {
|
||||
_context = context;
|
||||
}
|
||||
|
||||
void size(double size) {
|
||||
_size = size;
|
||||
}
|
||||
@@ -50,12 +58,26 @@ class AvatarBuilder {
|
||||
_onTapAvatarActionClick = onTapAvatarActionClick;
|
||||
}
|
||||
|
||||
void addOnTapAvatarActionWithPositionClick(OnTapAvatarActionWithPositionClick onTapAvatarActionWithPositionClick) {
|
||||
_onTapAvatarActionWithPositionClick = onTapAvatarActionWithPositionClick;
|
||||
}
|
||||
|
||||
Widget build() {
|
||||
return GestureDetector(
|
||||
onTap: () {
|
||||
if (_onTapAvatarActionClick != null) {
|
||||
_onTapAvatarActionClick!();
|
||||
}},
|
||||
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);
|
||||
}
|
||||
},
|
||||
child: Container(
|
||||
key: _key,
|
||||
width: _size ?? 40,
|
||||
|
||||
Reference in New Issue
Block a user