together_mobile/lib/screens/chat/components/add_menu.dart

94 lines
3.0 KiB
Dart
Raw Normal View History

import 'package:flutter/material.dart';
import 'package:custom_pop_up_menu/custom_pop_up_menu.dart';
import 'package:go_router/go_router.dart';
import 'package:together_mobile/common/constants.dart';
2023-09-09 16:48:47 +08:00
import 'package:together_mobile/models/init_get_it.dart';
import 'package:together_mobile/models/route_state_model.dart';
class AddMenu extends StatefulWidget {
const AddMenu({super.key});
@override
State<AddMenu> createState() => _AddMenuState();
}
class _AddMenuState extends State<AddMenu> {
final CustomPopupMenuController _controller = CustomPopupMenuController();
@override
Widget build(BuildContext context) {
return CustomPopupMenu(
menuBuilder: () {
return Container(
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(5.0),
color: Theme.of(context).brightness == Brightness.light
? Colors.white
: kUnActivatedColor,
),
width: 170,
child: Column(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: [
const SizedBox(
height: 15,
),
GestureDetector(
onTap: () {
_controller.hideMenu();
2023-09-09 16:48:47 +08:00
getIt.get<RouteState>().changeRoute('CreateGroupChat');
context.pushNamed('CreateGroupChat');
},
behavior: HitTestBehavior.translucent,
child: const Padding(
padding: EdgeInsets.fromLTRB(20, 0, 10, 15),
child: Row(
children: [
Icon(
Icons.group_add,
color: Color.fromARGB(255, 117, 117, 117),
),
SizedBox(width: 10),
Text('创建群聊'),
],
),
),
),
GestureDetector(
onTap: () {
_controller.hideMenu();
},
behavior: HitTestBehavior.translucent,
child: const Padding(
padding: EdgeInsets.fromLTRB(20, 0, 10, 15),
child: Row(
children: [
Icon(
Icons.person_add_alt_1,
color: Color.fromARGB(255, 117, 117, 117),
),
SizedBox(width: 10),
2023-09-09 16:48:47 +08:00
Text('添加好友/群聊'),
],
),
),
),
],
),
);
},
arrowSize: 12,
arrowColor: Theme.of(context).brightness == Brightness.light
? Colors.white
: kUnActivatedColor,
verticalMargin: 5,
controller: _controller,
pressType: PressType.singleClick,
child: const Padding(
padding: EdgeInsets.symmetric(horizontal: 8),
child: Icon(Icons.add_circle_outline),
),
);
}
}