Browse Source

马甲包优化

ios
ChenNyan 1 month ago
parent
commit
9f8182a15a
5 changed files with 129 additions and 93 deletions
  1. 12
      ios/Podfile.lock
  2. 4
      lib/pages/home/timeline_page.dart
  3. 5
      lib/pages/home/user_information_page.dart
  4. 196
      lib/widget/message/chat_input_bar.dart
  5. 5
      pubspec.yaml

12
ios/Podfile.lock

@ -103,10 +103,10 @@ PODS:
- FlutterMacOS - FlutterMacOS
- permission_handler_apple (9.3.0): - permission_handler_apple (9.3.0):
- Flutter - Flutter
- photo_manager (3.8.3):
- photo_manager (3.9.0):
- Flutter - Flutter
- FlutterMacOS - FlutterMacOS
- record_ios (1.1.0):
- record_ios (1.2.0):
- Flutter - Flutter
- sensors_plus (0.0.1): - sensors_plus (0.0.1):
- Flutter - Flutter
@ -233,8 +233,8 @@ SPEC CHECKSUMS:
AgoraRtcEngine_iOS: 5092a058c7b2842db39d8ca614d451af6f84969a AgoraRtcEngine_iOS: 5092a058c7b2842db39d8ca614d451af6f84969a
AgoraRtm: d92cdfca825f3e6817c315d7dd6403742494f7ca AgoraRtm: d92cdfca825f3e6817c315d7dd6403742494f7ca
app_settings: 5127ae0678de1dcc19f2293271c51d37c89428b2 app_settings: 5127ae0678de1dcc19f2293271c51d37c89428b2
audioplayers_darwin: 4f9ca89d92d3d21cec7ec580e78ca888e5fb68bd
camera_avfoundation: 5675ca25298b6f81fa0a325188e7df62cc217741
audioplayers_darwin: 835ced6edd4c9fc8ebb0a7cc9e294a91d99917d5
camera_avfoundation: 968a9a5323c79a99c166ad9d7866bfd2047b5a9b
emoji_picker_flutter: ece213fc274bdddefb77d502d33080dc54e616cc emoji_picker_flutter: ece213fc274bdddefb77d502d33080dc54e616cc
Flutter: cabc95a1d2626b1b06e7179b784ebcf0c0cde467 Flutter: cabc95a1d2626b1b06e7179b784ebcf0c0cde467
flutter_native_splash: c32d145d68aeda5502d5f543ee38c192065986cf flutter_native_splash: c32d145d68aeda5502d5f543ee38c192065986cf
@ -248,8 +248,8 @@ SPEC CHECKSUMS:
package_info_plus: af8e2ca6888548050f16fa2f1938db7b5a5df499 package_info_plus: af8e2ca6888548050f16fa2f1938db7b5a5df499
path_provider_foundation: bb55f6dbba17d0dccd6737fe6f7f34fbd0376880 path_provider_foundation: bb55f6dbba17d0dccd6737fe6f7f34fbd0376880
permission_handler_apple: 4ed2196e43d0651e8ff7ca3483a069d469701f2d permission_handler_apple: 4ed2196e43d0651e8ff7ca3483a069d469701f2d
photo_manager: fe4cbb0808b96f8be4af7ce6ae18dcd9c9b983c6
record_ios: f75fa1d57f840012775c0e93a38a7f3ceea1a374
photo_manager: 25fd77df14f4f0ba5ef99e2c61814dde77e2bceb
record_ios: 412daca2350b228e698fffcd08f1f94ceb1e3844
sensors_plus: 6a11ed0c2e1d0bd0b20b4029d3bad27d96e0c65b sensors_plus: 6a11ed0c2e1d0bd0b20b4029d3bad27d96e0c65b
shared_preferences_foundation: 7036424c3d8ec98dfe75ff1667cb0cd531ec82bb shared_preferences_foundation: 7036424c3d8ec98dfe75ff1667cb0cd531ec82bb
sqflite_darwin: 20b2a3a3b70e43edae938624ce550a3cbf66a3d0 sqflite_darwin: 20b2a3a3b70e43edae938624ce550a3cbf66a3d0

4
lib/pages/home/timeline_page.dart

@ -120,8 +120,8 @@ class _TimelinePageState extends State<TimelinePage>
size: 19, size: 19,
), ),
).onTap((){ ).onTap((){
widget.goMessage();
// Get.to(() => TimelineTrend());
// widget.goMessage();
Get.to(() => TimelineTrend());
}) })
], ],
); );

5
lib/pages/home/user_information_page.dart

@ -817,8 +817,9 @@ class UserInformationPage extends StatelessWidget {
], ],
), ),
bottomNavigationBar: miId != GlobalData().userData!.id ? SafeArea( bottomNavigationBar: miId != GlobalData().userData!.id ? SafeArea(
child: SizedBox(
height: 48.h,
child: Container(
height: 58.h,
padding: EdgeInsets.symmetric(vertical: 5.w),
child: Row( child: Row(
crossAxisAlignment: CrossAxisAlignment.center, crossAxisAlignment: CrossAxisAlignment.center,
mainAxisAlignment: MainAxisAlignment.center, mainAxisAlignment: MainAxisAlignment.center,

196
lib/widget/message/chat_input_bar.dart

@ -1,5 +1,8 @@
import 'package:dating_touchme_app/extension/ex_widget.dart'; import 'package:dating_touchme_app/extension/ex_widget.dart';
import 'package:extended_text/extended_text.dart';
import 'package:extended_text_field/extended_text_field.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart';
import '../../generated/assets.dart'; import '../../generated/assets.dart';
@ -13,7 +16,7 @@ class ChatInputBar extends StatefulWidget {
final ValueChanged<List<String>>? onImageSelected; final ValueChanged<List<String>>? onImageSelected;
final Function(String filePath, int seconds)? onVoiceRecorded; final Function(String filePath, int seconds)? onVoiceRecorded;
final VoidCallback? onVoiceCall; // final VoidCallback? onVoiceCall; //
final VoidCallback? onVideoCall; //
final Future<void> Function()? onVideoCall; //
final VoidCallback? onGiftTap; // final VoidCallback? onGiftTap; //
const ChatInputBar({ const ChatInputBar({
@ -28,6 +31,14 @@ class ChatInputBar extends StatefulWidget {
@override @override
State<ChatInputBar> createState() => _ChatInputBarState(); State<ChatInputBar> createState() => _ChatInputBarState();
// key
static void closePanels(GlobalKey? key) {
final state = key?.currentState;
if (state != null && state is _ChatInputBarState) {
state.closeAllPanels();
}
}
} }
class _ChatInputBarState extends State<ChatInputBar> { class _ChatInputBarState extends State<ChatInputBar> {
@ -106,6 +117,11 @@ class _ChatInputBarState extends State<ChatInputBar> {
} }
} }
//
void closeAllPanels() {
_closeAllPanels();
}
@override @override
void initState() { void initState() {
super.initState(); super.initState();
@ -137,63 +153,6 @@ class _ChatInputBarState extends State<ChatInputBar> {
setState(() {}); // setState(() {}); //
} }
/// +
List<Widget> _buildInputContentWidgets() {
final List<Widget> widgets = [];
final text = _textController.text;
final RegExp emojiRegex = RegExp(r'\[emoji:(\d+)\]');
int lastMatchEnd = 0;
final matches = emojiRegex.allMatches(text);
for (final match in matches) {
//
if (match.start > lastMatchEnd) {
final textPart = text.substring(lastMatchEnd, match.start);
widgets.add(
Text(
textPart,
style: TextStyle(fontSize: 14.sp, color: Colors.black),
),
);
}
//
final emojiId = match.group(1);
if (emojiId != null) {
final emoji = EmojiConfig.getEmojiById(emojiId);
if (emoji != null) {
widgets.add(
Padding(
padding: EdgeInsets.symmetric(horizontal: 2.w),
child: Image.asset(
emoji.path,
width: 24.w,
height: 24.w,
fit: BoxFit.contain,
),
),
);
}
}
lastMatchEnd = match.end;
}
//
if (lastMatchEnd < text.length) {
final textPart = text.substring(lastMatchEnd);
widgets.add(
Text(
textPart,
style: TextStyle(fontSize: 14.sp, color: Colors.black),
),
);
}
return widgets;
}
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return Column( return Column(
@ -218,7 +177,7 @@ class _ChatInputBarState extends State<ChatInputBar> {
child: Stack( child: Stack(
children: [ children: [
// //
TextField(
ExtendedTextField(
controller: _textController, controller: _textController,
focusNode: _focusNode, focusNode: _focusNode,
decoration: InputDecoration( decoration: InputDecoration(
@ -228,32 +187,23 @@ class _ChatInputBarState extends State<ChatInputBar> {
fontSize: 14.sp, fontSize: 14.sp,
color: Colors.grey, color: Colors.grey,
), ),
contentPadding: EdgeInsets.only(
bottom: 10
),
), ),
inputFormatters: [
// Unicode的规则
FilteringTextInputFormatter.deny(RegExp(r'[\u200B]')), //
],
specialTextSpanBuilder: MySpecialTextSpanBuilder(),
style: TextStyle( style: TextStyle(
fontSize: 14.sp, fontSize: 14.sp,
color: _textController.text.contains('[emoji:')
? Colors.transparent
: Colors.black,
color: Colors.black, // specialTextSpanBuilder
), ),
onChanged: (value) { onChanged: (value) {
setState(() {}); // setState(() {}); //
}, },
), ),
//
if (_textController.text.contains('[emoji:'))
Positioned.fill(
child: IgnorePointer(
child: Align(
alignment: Alignment.centerLeft,
child: SingleChildScrollView(
scrollDirection: Axis.horizontal,
child: Row(
children: _buildInputContentWidgets(),
),
),
),
),
),
], ],
), ),
), ),
@ -291,7 +241,7 @@ class _ChatInputBarState extends State<ChatInputBar> {
width: 24.w, width: 24.w,
height: 24.w, height: 24.w,
).onTap(_toggleVoiceOptions), ).onTap(_toggleVoiceOptions),
//
//
// Image.asset( // Image.asset(
// Assets.imagesSendCall, // Assets.imagesSendCall,
// width: 24.w, // width: 24.w,
@ -299,13 +249,13 @@ class _ChatInputBarState extends State<ChatInputBar> {
// ).onTap(() { // ).onTap(() {
// widget.onVoiceCall?.call(); // widget.onVoiceCall?.call();
// }), // }),
//
//
// Image.asset( // Image.asset(
// Assets.imagesSendVideoCall,
// Assets.imagesVideoCall,
// width: 24.w, // width: 24.w,
// height: 24.w, // height: 24.w,
// ).onTap(() {
// widget.onVideoCall?.call();
// ).onTap(() async {
// await widget.onVideoCall?.call();
// }), // }),
// //
// Image.asset(Assets.imagesGift, width: 24.w, height: 24.w).onTap(() { // Image.asset(Assets.imagesGift, width: 24.w, height: 24.w).onTap(() {
@ -344,3 +294,85 @@ class _ChatInputBarState extends State<ChatInputBar> {
); );
} }
} }
/// - TIMUIKitTextField
class MySpecialTextSpanBuilder extends SpecialTextSpanBuilder {
@override
SpecialText? createSpecialText(
String flag, {
TextStyle? textStyle,
SpecialTextGestureTapCallback? onTap,
required int index,
}) {
if (flag.isEmpty) {
return null;
}
// index start flag index - (flag.length - 1)
// 使 '[' startFlag EmojiText.flag = '['
if (isStart(flag, MyEmojiText.flag)) {
return MyEmojiText(
textStyle,
start: index - (MyEmojiText.flag.length - 1),
);
}
return null;
}
}
/// - TIMUIKitTextField EmojiText
class MyEmojiText extends SpecialText {
static const String flag = '[';
final int start;
MyEmojiText(
TextStyle? textStyle, {
required this.start,
}) : super(MyEmojiText.flag, ']', textStyle);
@override
InlineSpan finishText() {
// toString() "[emoji:11]"
final String key = toString();
// [emoji:]
final RegExp emojiPattern = RegExp(r'^\[emoji:(\d+)\]$');
final match = emojiPattern.firstMatch(key);
if (match != null && match.groupCount > 0) {
final emojiId = match.group(1);
if (emojiId != null && emojiId.isNotEmpty) {
final emoji = EmojiConfig.getEmojiById(emojiId);
if (emoji != null && emoji.path.isNotEmpty) {
// 使 ImageSpan TIMUIKitTextField
double size = 16;
final TextStyle ts = textStyle!;
if (ts.fontSize != null) {
// TIMUIKitTextField: size = ts.fontSize! * 1.44
// 使 flutter_screenutil
// fontSize 14.sp
size = ts.fontSize! * 1.44;
// sp ImageSpan
// flutter_screenutil .sp 使
} else {
// fontSize使 14.sp * 1.44
size = 14.w * 1.44;
}
return ImageSpan(
AssetImage(emoji.path),
actualText: key,
imageWidth: size,
imageHeight: size,
start: start,
margin: const EdgeInsets.all(0), //
);
}
}
}
//
return TextSpan(text: key, style: textStyle);
}
}

5
pubspec.yaml

@ -16,7 +16,7 @@ publish_to: 'none' # Remove this line if you wish to publish to pub.dev
# https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html # https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html
# In Windows, build-name is used as the major, minor, and patch parts # In Windows, build-name is used as the major, minor, and patch parts
# of the product and file versions while build-number is used as the build suffix. # of the product and file versions while build-number is used as the build suffix.
version: 1.0.0+1
version: 1.2.0+1
environment: environment:
sdk: ^3.9.0 sdk: ^3.9.0
@ -79,6 +79,9 @@ dependencies:
im_flutter_sdk: 4.15.2 im_flutter_sdk: 4.15.2
webview_flutter: ^4.13.0 webview_flutter: ^4.13.0
emoji_picker_flutter: ^4.3.0 emoji_picker_flutter: ^4.3.0
extended_text: ^15.0.2
extended_text_field: ^16.0.2
emoji_text_field: ^1.0.0
dev_dependencies: dev_dependencies:
flutter_test: flutter_test:

Loading…
Cancel
Save