复用官方 OpenIMLive 信令与房间,换票改走账号服务 /api/rtc_token;入口仅音频,占线/超时/重复回调与销毁释放由公司层防护。 Co-authored-by: Cursor <cursoragent@cursor.com> Co-authored-by: multica-agent <github@multica.ai>
119 lines
3.1 KiB
Dart
119 lines
3.1 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:flutter_screenutil/flutter_screenutil.dart';
|
|
import 'package:openim_common/openim_common.dart';
|
|
|
|
class ChatToolBox extends StatelessWidget {
|
|
const ChatToolBox({
|
|
super.key,
|
|
this.onTapAlbum,
|
|
this.onTapCall,
|
|
this.onTapCamera,
|
|
this.onTapCard,
|
|
this.onTapFile,
|
|
this.onTapLocation,
|
|
this.onTapDirectionalMessage,
|
|
});
|
|
final Function()? onTapAlbum;
|
|
final Function()? onTapCamera;
|
|
final Function()? onTapCall;
|
|
final Function()? onTapFile;
|
|
final Function()? onTapCard;
|
|
final Function()? onTapLocation;
|
|
final VoidCallback? onTapDirectionalMessage;
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
final items = [
|
|
ToolboxItemInfo(
|
|
text: StrRes.toolboxAlbum,
|
|
icon: ImageRes.toolboxAlbum,
|
|
onTap: () => Permissions.photos(onTapAlbum),
|
|
),
|
|
ToolboxItemInfo(
|
|
text: StrRes.toolboxCamera,
|
|
icon: ImageRes.toolboxCamera,
|
|
onTap: () => Permissions.cameraAndMicrophone(onTapCamera),
|
|
),
|
|
if (onTapCall != null)
|
|
ToolboxItemInfo(
|
|
text: StrRes.toolboxCall,
|
|
icon: ImageRes.toolboxCall,
|
|
onTap: () => Permissions.microphone(onTapCall),
|
|
),
|
|
ToolboxItemInfo(
|
|
text: StrRes.toolboxFile,
|
|
icon: ImageRes.toolboxFile,
|
|
onTap: () => Permissions.storage(onTapFile),
|
|
),
|
|
ToolboxItemInfo(
|
|
text: StrRes.toolboxCard,
|
|
icon: ImageRes.toolboxCard,
|
|
onTap: onTapCard,
|
|
),
|
|
ToolboxItemInfo(
|
|
text: StrRes.toolboxLocation,
|
|
icon: ImageRes.toolboxLocation,
|
|
onTap: () => Permissions.location(onTapLocation),
|
|
),
|
|
if (onTapDirectionalMessage != null)
|
|
ToolboxItemInfo(
|
|
text: StrRes.toolboxDirectionalMessage,
|
|
icon: ImageRes.toolboxDirectionalMessage,
|
|
onTap: onTapDirectionalMessage,
|
|
),
|
|
];
|
|
|
|
return Container(
|
|
color: Styles.c_F0F2F6,
|
|
height: 224.h,
|
|
child: GridView.builder(
|
|
itemCount: items.length,
|
|
padding: EdgeInsets.only(
|
|
left: 16.w,
|
|
right: 16.w,
|
|
top: 6.h,
|
|
bottom: 6.h,
|
|
),
|
|
gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
|
|
crossAxisCount: 4,
|
|
childAspectRatio: 78.w / 105.h,
|
|
crossAxisSpacing: 10.w,
|
|
mainAxisSpacing: 2.h,
|
|
),
|
|
itemBuilder: (_, index) {
|
|
final item = items.elementAt(index);
|
|
return _buildItemView(
|
|
icon: item.icon,
|
|
text: item.text,
|
|
onTap: item.onTap,
|
|
);
|
|
},
|
|
),
|
|
);
|
|
}
|
|
|
|
Widget _buildItemView({
|
|
required String text,
|
|
required String icon,
|
|
Function()? onTap,
|
|
}) =>
|
|
Column(
|
|
children: [
|
|
icon.toImage
|
|
..width = 58.w
|
|
..height = 58.h
|
|
..onTap = onTap,
|
|
10.verticalSpace,
|
|
text.toText..style = Styles.ts_0C1C33_12sp,
|
|
],
|
|
);
|
|
}
|
|
|
|
class ToolboxItemInfo {
|
|
String text;
|
|
String icon;
|
|
Function()? onTap;
|
|
|
|
ToolboxItemInfo({required this.text, required this.icon, this.onTap});
|
|
}
|