Commit 0f4ec721 authored by 关振斌's avatar 关振斌

update

parent 24ec97a4
...@@ -109,6 +109,8 @@ PODS: ...@@ -109,6 +109,8 @@ PODS:
- GTMSessionFetcher/Core (3.1.0) - GTMSessionFetcher/Core (3.1.0)
- image_picker_ios (0.0.1): - image_picker_ios (0.0.1):
- Flutter - Flutter
- keyboard_utils (0.0.1):
- Flutter
- open_filex (0.0.2): - open_filex (0.0.2):
- Flutter - Flutter
- OrderedSet (5.0.0) - OrderedSet (5.0.0)
...@@ -131,11 +133,15 @@ PODS: ...@@ -131,11 +133,15 @@ PODS:
- Flutter - Flutter
- smart_auth (0.0.1): - smart_auth (0.0.1):
- Flutter - Flutter
- speech_to_text (0.0.1):
- Flutter
- Try
- sqflite (0.0.2): - sqflite (0.0.2):
- Flutter - Flutter
- FMDB (>= 2.7.5) - FMDB (>= 2.7.5)
- SwiftyGif (5.4.4) - SwiftyGif (5.4.4)
- Toast (4.0.0) - Toast (4.0.0)
- Try (2.1.1)
- url_launcher_ios (0.0.1): - url_launcher_ios (0.0.1):
- Flutter - Flutter
- vibration (1.7.5): - vibration (1.7.5):
...@@ -163,6 +169,7 @@ DEPENDENCIES: ...@@ -163,6 +169,7 @@ DEPENDENCIES:
- fluttercontactpicker (from `.symlinks/plugins/fluttercontactpicker/ios`) - fluttercontactpicker (from `.symlinks/plugins/fluttercontactpicker/ios`)
- fluttertoast (from `.symlinks/plugins/fluttertoast/ios`) - fluttertoast (from `.symlinks/plugins/fluttertoast/ios`)
- image_picker_ios (from `.symlinks/plugins/image_picker_ios/ios`) - image_picker_ios (from `.symlinks/plugins/image_picker_ios/ios`)
- keyboard_utils (from `.symlinks/plugins/keyboard_utils/ios`)
- open_filex (from `.symlinks/plugins/open_filex/ios`) - open_filex (from `.symlinks/plugins/open_filex/ios`)
- package_info (from `.symlinks/plugins/package_info/ios`) - package_info (from `.symlinks/plugins/package_info/ios`)
- path_provider_foundation (from `.symlinks/plugins/path_provider_foundation/ios`) - path_provider_foundation (from `.symlinks/plugins/path_provider_foundation/ios`)
...@@ -170,6 +177,7 @@ DEPENDENCIES: ...@@ -170,6 +177,7 @@ DEPENDENCIES:
- shared_preferences_foundation (from `.symlinks/plugins/shared_preferences_foundation/ios`) - shared_preferences_foundation (from `.symlinks/plugins/shared_preferences_foundation/ios`)
- sign_in_with_apple (from `.symlinks/plugins/sign_in_with_apple/ios`) - sign_in_with_apple (from `.symlinks/plugins/sign_in_with_apple/ios`)
- smart_auth (from `.symlinks/plugins/smart_auth/ios`) - smart_auth (from `.symlinks/plugins/smart_auth/ios`)
- speech_to_text (from `.symlinks/plugins/speech_to_text/ios`)
- sqflite (from `.symlinks/plugins/sqflite/ios`) - sqflite (from `.symlinks/plugins/sqflite/ios`)
- url_launcher_ios (from `.symlinks/plugins/url_launcher_ios/ios`) - url_launcher_ios (from `.symlinks/plugins/url_launcher_ios/ios`)
- vibration (from `.symlinks/plugins/vibration/ios`) - vibration (from `.symlinks/plugins/vibration/ios`)
...@@ -193,6 +201,7 @@ SPEC REPOS: ...@@ -193,6 +201,7 @@ SPEC REPOS:
- SDWebImage - SDWebImage
- SwiftyGif - SwiftyGif
- Toast - Toast
- Try
EXTERNAL SOURCES: EXTERNAL SOURCES:
app_settings: app_settings:
...@@ -229,6 +238,8 @@ EXTERNAL SOURCES: ...@@ -229,6 +238,8 @@ EXTERNAL SOURCES:
:path: ".symlinks/plugins/fluttertoast/ios" :path: ".symlinks/plugins/fluttertoast/ios"
image_picker_ios: image_picker_ios:
:path: ".symlinks/plugins/image_picker_ios/ios" :path: ".symlinks/plugins/image_picker_ios/ios"
keyboard_utils:
:path: ".symlinks/plugins/keyboard_utils/ios"
open_filex: open_filex:
:path: ".symlinks/plugins/open_filex/ios" :path: ".symlinks/plugins/open_filex/ios"
package_info: package_info:
...@@ -243,6 +254,8 @@ EXTERNAL SOURCES: ...@@ -243,6 +254,8 @@ EXTERNAL SOURCES:
:path: ".symlinks/plugins/sign_in_with_apple/ios" :path: ".symlinks/plugins/sign_in_with_apple/ios"
smart_auth: smart_auth:
:path: ".symlinks/plugins/smart_auth/ios" :path: ".symlinks/plugins/smart_auth/ios"
speech_to_text:
:path: ".symlinks/plugins/speech_to_text/ios"
sqflite: sqflite:
:path: ".symlinks/plugins/sqflite/ios" :path: ".symlinks/plugins/sqflite/ios"
url_launcher_ios: url_launcher_ios:
...@@ -281,6 +294,7 @@ SPEC CHECKSUMS: ...@@ -281,6 +294,7 @@ SPEC CHECKSUMS:
GoogleUtilities: 9aa0ad5a7bc171f8bae016300bfcfa3fb8425749 GoogleUtilities: 9aa0ad5a7bc171f8bae016300bfcfa3fb8425749
GTMSessionFetcher: c9e714f7eec91a55641e2bab9f45fd83a219b882 GTMSessionFetcher: c9e714f7eec91a55641e2bab9f45fd83a219b882
image_picker_ios: 4a8aadfbb6dc30ad5141a2ce3832af9214a705b5 image_picker_ios: 4a8aadfbb6dc30ad5141a2ce3832af9214a705b5
keyboard_utils: ab24bc711be9e91a5937c20489056b8dd650fecc
open_filex: 6e26e659846ec990262224a12ef1c528bb4edbe4 open_filex: 6e26e659846ec990262224a12ef1c528bb4edbe4
OrderedSet: aaeb196f7fef5a9edf55d89760da9176ad40b93c OrderedSet: aaeb196f7fef5a9edf55d89760da9176ad40b93c
package_info: 873975fc26034f0b863a300ad47e7f1ac6c7ec62 package_info: 873975fc26034f0b863a300ad47e7f1ac6c7ec62
...@@ -292,13 +306,15 @@ SPEC CHECKSUMS: ...@@ -292,13 +306,15 @@ SPEC CHECKSUMS:
shared_preferences_foundation: 986fc17f3d3251412d18b0265f9c64113a8c2472 shared_preferences_foundation: 986fc17f3d3251412d18b0265f9c64113a8c2472
sign_in_with_apple: f3bf75217ea4c2c8b91823f225d70230119b8440 sign_in_with_apple: f3bf75217ea4c2c8b91823f225d70230119b8440
smart_auth: 4bedbc118723912d0e45a07e8ab34039c19e04f2 smart_auth: 4bedbc118723912d0e45a07e8ab34039c19e04f2
speech_to_text: b43a7d99aef037bd758ed8e45d79bbac035d2dfe
sqflite: 6d358c025f5b867b29ed92fc697fd34924e11904 sqflite: 6d358c025f5b867b29ed92fc697fd34924e11904
SwiftyGif: 93a1cc87bf3a51916001cf8f3d63835fb64c819f SwiftyGif: 93a1cc87bf3a51916001cf8f3d63835fb64c819f
Toast: 91b396c56ee72a5790816f40d3a94dd357abc196 Toast: 91b396c56ee72a5790816f40d3a94dd357abc196
Try: 5ef669ae832617b3cee58cb2c6f99fb767a4ff96
url_launcher_ios: 08a3dfac5fb39e8759aeb0abbd5d9480f30fc8b4 url_launcher_ios: 08a3dfac5fb39e8759aeb0abbd5d9480f30fc8b4
vibration: 7d883d141656a1c1a6d8d238616b2042a51a1241 vibration: 7d883d141656a1c1a6d8d238616b2042a51a1241
video_player_avfoundation: 81e49bb3d9fb63dccf9fa0f6d877dc3ddbeac126 video_player_avfoundation: 81e49bb3d9fb63dccf9fa0f6d877dc3ddbeac126
webview_flutter_wkwebview: b7e70ef1ddded7e69c796c7390ee74180182971f webview_flutter_wkwebview: 2e2d318f21a5e036e2c3f26171342e95908bd60a
PODFILE CHECKSUM: ef19549a9bc3046e7bb7d2fab4d021637c0c58a3 PODFILE CHECKSUM: ef19549a9bc3046e7bb7d2fab4d021637c0c58a3
......
...@@ -66,7 +66,11 @@ ...@@ -66,7 +66,11 @@
<string>UIInterfaceOrientationLandscapeLeft</string> <string>UIInterfaceOrientationLandscapeLeft</string>
<string>UIInterfaceOrientationLandscapeRight</string> <string>UIInterfaceOrientationLandscapeRight</string>
</array> </array>
<key>NSMicrophoneUsageDescription</key>
<string>只有您‘允许使用麦克风’AI写作大师才能听您说话</string>
<key>UIViewControllerBasedStatusBarAppearance</key> <key>UIViewControllerBasedStatusBarAppearance</key>
<false/> <false/>
<key>NSSpeechRecognitionUsageDescription</key>
<string>只有您‘允许使用麦克风’AI写作大师才能听您说话</string>
</dict> </dict>
</plist> </plist>
...@@ -10,6 +10,7 @@ import 'package:chart/common/values/values.dart'; ...@@ -10,6 +10,7 @@ import 'package:chart/common/values/values.dart';
import 'package:chart/entity/login_entity.dart'; import 'package:chart/entity/login_entity.dart';
import 'package:chart/pages/application/index.dart'; import 'package:chart/pages/application/index.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter_easyloading/flutter_easyloading.dart';
import 'package:get/get.dart'; import 'package:get/get.dart';
// import 'package:connectivity_plus/connectivity_plus.dart'; // import 'package:connectivity_plus/connectivity_plus.dart';
// import 'package:highlight/languages/rust.dart'; // import 'package:highlight/languages/rust.dart';
...@@ -44,13 +45,22 @@ class UserStore extends GetxController { ...@@ -44,13 +45,22 @@ class UserStore extends GetxController {
super.onInit(); super.onInit();
subscription = Connectivity() subscription = Connectivity()
.onConnectivityChanged .onConnectivityChanged
.listen((ConnectivityResult result) { .listen((ConnectivityResult result) async {
print("resultresultresultresult$result"); print("resultresultresultresult$result");
if (result == ConnectivityResult.none || if (result == ConnectivityResult.none ||
result == ConnectivityResult.other) { result == ConnectivityResult.other) {
EasyLoading.show(status: '网络连接异常,正在尝试重新连接!');
ApplicationController.to.state.isNetWorkErr = true;
// Get.
// Get.offAndToNamed(AppRoutes.WILL_COME);
} else { } else {
refreshInfo(); ApplicationController.to.state.isNetWorkErr = false;
EasyLoading.dismiss();
await refreshInfo();
// Get.offAndToNamed(AppRoutes.Application);
// AppRoutes.WILL_COME
// asyncLoadBannerData(); // asyncLoadBannerData();
// Get.back(); // Get.back();
} }
...@@ -116,7 +126,7 @@ class UserStore extends GetxController { ...@@ -116,7 +126,7 @@ class UserStore extends GetxController {
_isLogin.value = true; _isLogin.value = true;
} }
await MainController.to.asyncLoadBannerData(); // await MainController.to.asyncLoadBannerData();
} }
} }
......
...@@ -13,7 +13,7 @@ AppBar transparentAppBar({ ...@@ -13,7 +13,7 @@ AppBar transparentAppBar({
// elevation: 2, // elevation: 2,
title: title, title: title,
elevation: 0, elevation: 0,
leadingWidth: 90, leadingWidth: 110,
leading: leading ?? null, leading: leading ?? null,
actions: actions, actions: actions,
centerTitle: true, centerTitle: true,
......
...@@ -8,16 +8,18 @@ import 'package:flutter_easyloading/flutter_easyloading.dart'; ...@@ -8,16 +8,18 @@ import 'package:flutter_easyloading/flutter_easyloading.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:flutter_tts/flutter_tts.dart'; import 'package:flutter_tts/flutter_tts.dart';
import 'package:flutter_vibrate/flutter_vibrate.dart'; import 'package:flutter_vibrate/flutter_vibrate.dart';
import 'package:gradient_widgets/gradient_widgets.dart';
import 'package:highlight/highlight.dart' show highlight, Node; import 'package:highlight/highlight.dart' show highlight, Node;
import 'package:animated_text_kit/animated_text_kit.dart'; import 'package:animated_text_kit/animated_text_kit.dart';
import 'package:chart/package/markdown/flutter_markdown.dart'; import 'package:chart/package/markdown/flutter_markdown.dart';
import 'package:flutter/gestures.dart'; import 'package:flutter/gestures.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
// import 'package:get/get.dart';
import 'package:flutter_parsed_text/flutter_parsed_text.dart'; import 'package:flutter_parsed_text/flutter_parsed_text.dart';
import 'package:get/get_connect/http/src/utils/utils.dart'; import 'package:get/get_connect/http/src/utils/utils.dart';
import 'package:gradient_borders/input_borders/gradient_outline_input_border.dart'; import 'package:gradient_borders/input_borders/gradient_outline_input_border.dart';
import 'package:highlight/highlight.dart'; // import 'package:highlight/highlight.dart';
import 'package:intl/intl.dart' as intl; import 'package:intl/intl.dart' as intl;
import 'package:loading_animation_widget/loading_animation_widget.dart'; import 'package:loading_animation_widget/loading_animation_widget.dart';
import 'package:share_plus/share_plus.dart'; import 'package:share_plus/share_plus.dart';
......
...@@ -10,6 +10,7 @@ class InputOptions { ...@@ -10,6 +10,7 @@ class InputOptions {
this.onMentionTriggers = const <String>['@'], this.onMentionTriggers = const <String>['@'],
this.onTextChange, this.onTextChange,
this.inputDisabled = false, this.inputDisabled = false,
this.isTextInput = true,
this.inputDecoration, this.inputDecoration,
this.textCapitalization = TextCapitalization.none, this.textCapitalization = TextCapitalization.none,
this.alwaysShowSend = false, this.alwaysShowSend = false,
...@@ -27,8 +28,13 @@ class InputOptions { ...@@ -27,8 +28,13 @@ class InputOptions {
this.inputToolbarMargin = const EdgeInsets.only(top: 8.0), this.inputToolbarMargin = const EdgeInsets.only(top: 8.0),
this.cursorStyle = const CursorStyle(), this.cursorStyle = const CursorStyle(),
this.autocorrect = true, this.autocorrect = true,
this.onLongPressStart,
this.onLongPressEnd,
}); });
final void Function(LongPressStartDetails)? onLongPressStart;
final void Function(LongPressEndDetails)? onLongPressEnd;
/// Function to call when a mention is triggered in the input, /// Function to call when a mention is triggered in the input,
/// ie: typing ' @' /// ie: typing ' @'
/// You need to return a list of widget that will be shown inside the selection overlay, /// You need to return a list of widget that will be shown inside the selection overlay,
...@@ -65,6 +71,9 @@ class InputOptions { ...@@ -65,6 +71,9 @@ class InputOptions {
/// To make the input disabled /// To make the input disabled
final bool inputDisabled; final bool inputDisabled;
///语音模式
final bool isTextInput;
/// Input decoration to customize the design of the input /// Input decoration to customize the design of the input
/// You can use defaultInputDecoration to only orride some variables /// You can use defaultInputDecoration to only orride some variables
final InputDecoration? inputDecoration; final InputDecoration? inputDecoration;
......
...@@ -2,36 +2,41 @@ part of dash_chat_2; ...@@ -2,36 +2,41 @@ part of dash_chat_2;
/// {@category Customization} /// {@category Customization}
class MessageOptions { class MessageOptions {
const MessageOptions({ const MessageOptions(
this.showCurrentUserAvatar = false, {this.showCurrentUserAvatar = false,
this.showOtherUsersAvatar = true, this.showOtherUsersAvatar = true,
this.showOtherUsersName = true, this.showOtherUsersName = true,
this.userNameBuilder, this.userNameBuilder,
this.avatarBuilder, this.avatarBuilder,
this.onPressAvatar, this.onPressAvatar,
this.onLongPressAvatar, this.onLongPressAvatar,
this.onLongPressMessage, this.onLongPressMessage,
this.onPressMessage, this.onPressMessage,
this.onPressMention, this.onPressMention,
this.currentUserContainerColor, this.currentUserContainerColor,
this.currentUserTextColor, this.currentUserTextColor,
this.containerColor, this.containerColor,
this.textColor, this.textColor,
this.messagePadding, this.messagePadding,
this.maxWidth, this.maxWidth,
this.messageDecorationBuilder, this.messageDecorationBuilder,
this.top, this.top,
this.bottom, this.bottom,
this.messageRowBuilder, this.messageRowBuilder,
this.messageTextBuilder, this.messageTextBuilder,
this.parsePatterns, this.parsePatterns,
this.textBeforeMedia = true, this.textBeforeMedia = true,
this.onTapMedia, this.onTapMedia,
this.showTime = false, this.showTime = false,
this.timeFormat, this.timeFormat,
this.messageTimeBuilder, this.messageTimeBuilder,
this.messageMediaBuilder, this.messageMediaBuilder,
}); this.onLongPressStart,
this.onLongPressEnd});
//长按
// onLongPressEnd
/// Format of the time if [showTime] is true /// Format of the time if [showTime] is true
/// Default to: DateFormat('HH:mm') /// Default to: DateFormat('HH:mm')
...@@ -75,6 +80,9 @@ class MessageOptions { ...@@ -75,6 +80,9 @@ class MessageOptions {
/// Function to call when the user press on a message mention /// Function to call when the user press on a message mention
final Function(Mention)? onPressMention; final Function(Mention)? onPressMention;
final Function(LongPressStartDetails details)? onLongPressStart;
final Function(LongPressStartDetails details)? onLongPressEnd;
/// Color of the current user chat bubbles /// Color of the current user chat bubbles
/// Default to primary color /// Default to primary color
final Color? currentUserContainerColor; final Color? currentUserContainerColor;
......
...@@ -91,52 +91,89 @@ class _InputToolbarState extends State<InputToolbar> ...@@ -91,52 +91,89 @@ class _InputToolbarState extends State<InputToolbar>
if (widget.inputOptions.leading != null) if (widget.inputOptions.leading != null)
...widget.inputOptions.leading!, ...widget.inputOptions.leading!,
Expanded( Expanded(
child: Directionality( child: widget.inputOptions.isTextInput
textDirection: widget.inputOptions.inputTextDirection, ? Directionality(
child: TextField( textDirection: widget.inputOptions.inputTextDirection,
focusNode: focusNode, child: TextField(
controller: textController, focusNode: focusNode,
enabled: !widget.inputOptions.inputDisabled, controller: textController,
textCapitalization: widget.inputOptions.textCapitalization, enabled: !widget.inputOptions.inputDisabled,
textInputAction: widget.inputOptions.textInputAction, textCapitalization:
decoration: widget.inputOptions.inputDecoration ?? widget.inputOptions.textCapitalization,
defaultInputDecoration( textInputAction: widget.inputOptions.textInputAction,
_sendMessage, decoration: widget.inputOptions.inputDecoration ??
hintText: widget.inputOptions.inputDisabled defaultInputDecoration(
? 'AI正在输入中...' _sendMessage,
: '请输入问题...', hintText: widget.inputOptions.inputDisabled
!widget.inputOptions.inputDisabled, ? 'AI正在输入中...'
), : '请输入问题...',
maxLength: widget.inputOptions.maxInputLength, !widget.inputOptions.inputDisabled,
minLines: 1, ),
maxLines: 1, maxLength: widget.inputOptions.maxInputLength,
// maxLines: widget.inputOptions.sendOnEnter minLines: 1,
// ? 1 maxLines: 1,
// : widget.inputOptions.inputMaxLines, // maxLines: widget.inputOptions.sendOnEnter
cursorColor: widget.inputOptions.cursorStyle.color, // ? 1
cursorWidth: widget.inputOptions.cursorStyle.width, // : widget.inputOptions.inputMaxLines,
showCursor: !widget.inputOptions.cursorStyle.hide, cursorColor: widget.inputOptions.cursorStyle.color,
style: widget.inputOptions.inputTextStyle, cursorWidth: widget.inputOptions.cursorStyle.width,
onSubmitted: (String value) { showCursor: !widget.inputOptions.cursorStyle.hide,
if (widget.inputOptions.sendOnEnter) { style: widget.inputOptions.inputTextStyle,
_sendMessage(); onSubmitted: (String value) {
} if (widget.inputOptions.sendOnEnter) {
}, _sendMessage();
onChanged: (String value) async { }
setState(() {}); },
if (widget.inputOptions.onTextChange != null) { onChanged: (String value) async {
widget.inputOptions.onTextChange!(value); setState(() {});
} if (widget.inputOptions.onTextChange != null) {
WidgetsBinding.instance.addPostFrameCallback((_) async { widget.inputOptions.onTextChange!(value);
if (widget.inputOptions.onMention != null) { }
await _checkMentions(value); WidgetsBinding.instance
} .addPostFrameCallback((_) async {
}); if (widget.inputOptions.onMention != null) {
}, await _checkMentions(value);
autocorrect: widget.inputOptions.autocorrect, }
), });
), },
), autocorrect: widget.inputOptions.autocorrect,
))
: GestureDetector(
onLongPressStart: !widget.inputOptions.inputDisabled
? widget.inputOptions.onLongPressStart
: null,
// widget.inputOptions.onLongPressStart,
onLongPressEnd: !widget.inputOptions.inputDisabled
? widget.inputOptions.onLongPressEnd
: null,
// onLongPressCancel: () {
// print("onLongPressCancel");
// },
child: Container(
padding: EdgeInsets.all(16.5),
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(10),
gradient: LinearGradient(
colors: !widget.inputOptions.inputDisabled
? [
Color(0xFFbe6afb),
Color(0xFF9c67f6),
Color(0xFF7965f8)
]
: [
Color(0xFFbe6afb).withOpacity(.7),
Color(0xFF9c67f6).withOpacity(.7),
Color(0xFF7965f8).withOpacity(.7)
],
begin: Alignment.topCenter,
end: Alignment.bottomCenter,
)),
child: const Text(
'按住说话',
textAlign: TextAlign.center,
),
),
)),
if (widget.inputOptions.trailing != null && if (widget.inputOptions.trailing != null &&
widget.inputOptions.showTraillingBeforeSend) widget.inputOptions.showTraillingBeforeSend)
...widget.inputOptions.trailing!, ...widget.inputOptions.trailing!,
......
...@@ -47,40 +47,56 @@ class _DefaultMessageTextState extends State<DefaultMessageText> { ...@@ -47,40 +47,56 @@ class _DefaultMessageTextState extends State<DefaultMessageText> {
@override @override
void dispose() { void dispose() {
super.dispose(); super.dispose();
controller.dispose();
} }
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return Column( // CustomPopupMenu(
crossAxisAlignment: widget.isOwnMessage // // controller: CustomPopupMenuController().hideMenu(),
? CrossAxisAlignment.end // menuBuilder: () => _buildLongPressMenu(message, context),
: CrossAxisAlignment.start, // barrierColor: Colors.transparent,
children: <Widget>[ // position: PreferredPosition.bottom,
Wrap( // pressType: PressType.longPress,
children: getMessage( // child: ,
widget.isOwnMessage, widget.messageLength, widget.index), // ));
), return CustomPopupMenu(
if (widget.messageOptions.showTime) controller: controller,
widget.messageOptions.messageTimeBuilder != null menuBuilder: () => _buildLongPressMenu(widget.message),
? widget.messageOptions.messageTimeBuilder!( barrierColor: Colors.transparent,
widget.message, widget.isOwnMessage) position: PreferredPosition.bottom,
: Padding( pressType: PressType.longPress,
padding: const EdgeInsets.only(top: 5), child: Column(
child: Text( crossAxisAlignment: widget.isOwnMessage
(widget.messageOptions.timeFormat ?? ? CrossAxisAlignment.end
intl.DateFormat('HH:mm')) : CrossAxisAlignment.start,
.format(widget.message.createdAt), children: <Widget>[
style: TextStyle( Wrap(
color: widget.isOwnMessage children: getMessage(
? (widget.messageOptions.currentUserTextColor ?? widget.isOwnMessage, widget.messageLength, widget.index),
Colors.white70) ),
: (widget.messageOptions.textColor ?? Colors.black54), if (widget.messageOptions.showTime)
fontSize: 10, widget.messageOptions.messageTimeBuilder != null
? widget.messageOptions.messageTimeBuilder!(
widget.message, widget.isOwnMessage)
: Padding(
padding: const EdgeInsets.only(top: 5),
child: Text(
(widget.messageOptions.timeFormat ??
intl.DateFormat('HH:mm'))
.format(widget.message.createdAt),
style: TextStyle(
color: widget.isOwnMessage
? (widget.messageOptions.currentUserTextColor ??
Colors.white70)
: (widget.messageOptions.textColor ??
Colors.black54),
fontSize: 10,
),
),
), ),
), ],
), ));
],
);
} }
List<Widget> getMessage( List<Widget> getMessage(
...@@ -151,22 +167,33 @@ class _DefaultMessageTextState extends State<DefaultMessageText> { ...@@ -151,22 +167,33 @@ class _DefaultMessageTextState extends State<DefaultMessageText> {
), ),
], ],
) )
: CustomPopupMenu( : MyMarkdown(
controller: controller, // syntaxHighlighter: SyntaxHighlighter(),
position: PreferredPosition.top, // styleConfig: StyleConfig(),
menuBuilder: () => data: text,
_buildLongPressMenu(message: widget.message.text), styleSheet: MarkdownStyleSheet(
barrierColor: Colors.transparent, p: TextStyle(color: Colors.white),
pressType: PressType.longPress, code: TextStyle(color: Colors.white),
child: MyMarkdown( ),
// syntaxHighlighter: SyntaxHighlighter(), );
// styleConfig: StyleConfig(),
data: text, // CustomPopupMenu(
styleSheet: MarkdownStyleSheet( // controller: controller,
p: TextStyle(color: Colors.white), // position: PreferredPosition.top,
code: TextStyle(color: Colors.white), // menuBuilder: () =>
), // _buildLongPressMenu(message: widget.message.text),
)); // barrierColor: Colors.transparent,
// pressType: PressType.longPress,
// child: MyMarkdown(
// // syntaxHighlighter: SyntaxHighlighter(),
// // styleConfig: StyleConfig(),
// data: text,
// styleSheet: MarkdownStyleSheet(
// p: TextStyle(color: Colors.white),
// code: TextStyle(color: Colors.white),
// ),
// ));
// Column( // Column(
// children: [ // children: [
// Expanded( // Expanded(
...@@ -239,76 +266,161 @@ class _DefaultMessageTextState extends State<DefaultMessageText> { ...@@ -239,76 +266,161 @@ class _DefaultMessageTextState extends State<DefaultMessageText> {
*/ */
Widget _buildLongPressMenu({String message = ""}) { List<ItemModel> menuItems = [
ItemModel(
'复制',
Icons.content_copy,
(ChatMessage message, CustomPopupMenuController controller) {
FlutterClipboard.copy(message.text).then((value) {
EasyLoading.showToast("复制成功", maskType: EasyLoadingMaskType.none);
controller.hideMenu();
// Get.back();
});
// controller.hideMenu();
},
),
ItemModel(
'转发',
Icons.share,
(ChatMessage message, CustomPopupMenuController controller) async {
if (message.text.isNotEmpty) {
await Share.share(
"${message.text}\n\n",
);
controller.hideMenu();
} else {
EasyLoading.showToast("分享内容不能为空", maskType: EasyLoadingMaskType.none);
}
// FlutterClipboard.copy(message.text).then((value) {
// EasyLoading.showToast("复制成功", maskType: EasyLoadingMaskType.none);
// controller.hideMenu();
// // Get.back();
// });
},
),
// ItemModel('收藏', Icons.collections),
// ItemModel('删除', Icons.delete),
// ItemModel('多选', Icons.playlist_add_check),
// ItemModel('引用', Icons.format_quote),
// ItemModel('提醒', Icons.add_alert),
// ItemModel('搜一搜', Icons.search),
];
Widget _buildLongPressMenu(ChatMessage message) {
return ClipRRect( return ClipRRect(
borderRadius: BorderRadius.circular(5), borderRadius: BorderRadius.circular(5),
child: Container( child: Container(
width: 90, width: 220,
padding: EdgeInsets.only(left: 0, top: 5, right: 0, bottom: 5), // padding: EdgeInsets.symmetric(horizontal: 5, vertical: 5),
decoration: BoxDecoration( color: const Color(0xFF4C4C4C),
gradient: LinearGradient( child: GridView.count(
colors: [Color(0xFF3d3f54), Color(0xFF333450), Color(0xFF2b2b4d)], padding: EdgeInsets.symmetric(horizontal: 10, vertical: 10),
begin: Alignment.topCenter, crossAxisCount: 5,
end: Alignment.bottomCenter, crossAxisSpacing: 0,
)), mainAxisSpacing: 10,
child: Row( shrinkWrap: true,
mainAxisAlignment: MainAxisAlignment.spaceAround, physics: NeverScrollableScrollPhysics(),
children: [ children: menuItems
GestureDetector( .map((item) => InkWell(
onTap: () { onTap: () {
FlutterClipboard.copy(message) item.tapEvent(message, controller);
.then((value) => EasyLoading.showToast("复制成功")); },
controller.hideMenu(); child: Column(
}, mainAxisSize: MainAxisSize.min,
child: Column( children: <Widget>[
mainAxisSize: MainAxisSize.min, Icon(
children: <Widget>[ item.icon,
const Icon( size: 20,
Icons.content_copy, color: Colors.white,
size: 12, ),
color: Colors.white, Container(
margin: EdgeInsets.only(top: 2),
child: Text(
item.title,
style: TextStyle(color: Colors.white, fontSize: 12),
),
),
],
), ),
Container( ))
margin: EdgeInsets.only(top: 2), .toList(),
child: Text(
"复制",
style: TextStyle(color: Colors.white, fontSize: 8),
),
),
],
)),
GestureDetector(
onTap: () async {
if (message.isNotEmpty) {
await Share.share(
"${message}\n\n",
);
}
controller.hideMenu();
},
child: Column(
mainAxisSize: MainAxisSize.min,
children: <Widget>[
const Icon(
Icons.share,
size: 12,
color: Colors.white,
),
Container(
margin: EdgeInsets.only(top: 2),
child: const Text(
"分享",
style: TextStyle(color: Colors.white, fontSize: 8),
),
),
],
))
],
), ),
), ),
); );
} }
// Widget _buildLongPressMenu({String message = ""}) {
// return ClipRRect(
// borderRadius: BorderRadius.circular(5),
// child: Container(
// width: 90,
// padding: EdgeInsets.only(left: 0, top: 5, right: 0, bottom: 5),
// decoration: BoxDecoration(
// gradient: LinearGradient(
// colors: [Color(0xFF3d3f54), Color(0xFF333450), Color(0xFF2b2b4d)],
// begin: Alignment.topCenter,
// end: Alignment.bottomCenter,
// )),
// child: Row(
// mainAxisAlignment: MainAxisAlignment.spaceAround,
// children: [
// GestureDetector(
// onTap: () {
// FlutterClipboard.copy(message)
// .then((value) => EasyLoading.showToast("复制成功"));
// // controller.hideMenu();
// },
// child: Column(
// mainAxisSize: MainAxisSize.min,
// children: <Widget>[
// const Icon(
// Icons.content_copy,
// size: 12,
// color: Colors.white,
// ),
// Container(
// margin: EdgeInsets.only(top: 2),
// child: Text(
// "复制",
// style: TextStyle(color: Colors.white, fontSize: 8),
// ),
// ),
// ],
// )),
// GestureDetector(
// onTap: () async {
// if (message.isNotEmpty) {
// await Share.share(
// "${message}\n\n",
// );
// }
// // controller.hideMenu();
// },
// child: Column(
// mainAxisSize: MainAxisSize.min,
// children: <Widget>[
// const Icon(
// Icons.share,
// size: 12,
// color: Colors.white,
// ),
// Container(
// margin: EdgeInsets.only(top: 2),
// child: const Text(
// "分享",
// style: TextStyle(color: Colors.white, fontSize: 8),
// ),
// ),
// ],
// ))
// ],
// ),
// ),
// );
// }
// {buildPostMessage = getPostMessageBuild} // {buildPostMessage = getPostMessageBuild}
Widget getParsePattern( Widget getParsePattern(
String text, String text,
...@@ -355,8 +467,8 @@ class _DefaultMessageTextState extends State<DefaultMessageText> { ...@@ -355,8 +467,8 @@ class _DefaultMessageTextState extends State<DefaultMessageText> {
class ItemModel { class ItemModel {
String title; String title;
IconData icon; IconData icon;
dynamic tapEvent;
ItemModel(this.title, this.icon); ItemModel(this.title, this.icon, this.tapEvent);
} }
class MyStyleSheet extends MarkdownStyleSheet { class MyStyleSheet extends MarkdownStyleSheet {
......
...@@ -57,62 +57,112 @@ class TextContainer extends StatelessWidget { ...@@ -57,62 +57,112 @@ class TextContainer extends StatelessWidget {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return Container( return Container(
margin: EdgeInsets.only(bottom: index == 0 ? 20 : 0), margin: EdgeInsets.only(bottom: index == 0 ? 20 : 0),
// background-image: linear-gradient(180deg, #be6afb, #9c67f6, #7965f8); // background-image: linear-gradient(180deg, #be6afb, #9c67f6, #7965f8);
// background-image: linear-gradient(180deg, #3d3f54, #333450, #2b2b4d); // background-image: linear-gradient(180deg, #3d3f54, #333450, #2b2b4d);
decoration: BoxDecoration( decoration: BoxDecoration(
borderRadius: BorderRadius.only( borderRadius: BorderRadius.only(
topLeft: !isOwnMessage ? Radius.circular(0) : Radius.circular(20), topLeft:
topRight: Radius.circular(20), !isOwnMessage ? Radius.circular(0) : Radius.circular(20),
bottomLeft: Radius.circular(20), topRight: Radius.circular(20),
bottomRight: bottomLeft: Radius.circular(20),
isOwnMessage ? Radius.circular(0) : Radius.circular(20) bottomRight:
// bottomRight: isOwnMessage ? Radius.circular(0) : Radius.circular(20)
// isOwnMessage ? Radius.circular(20) : Radius.circular(0), // bottomRight:
), // isOwnMessage ? Radius.circular(20) : Radius.circular(0),
gradient: LinearGradient( ),
colors: isOwnMessage gradient: LinearGradient(
? [Color(0xFFbe6afb), Color(0xFF9c67f6), Color(0xFF7965f8)] colors: isOwnMessage
: [Color(0xFF3d3f54), Color(0xFF333450), Color(0xFF2b2b4d)], ? [Color(0xFFbe6afb), Color(0xFF9c67f6), Color(0xFF7965f8)]
begin: Alignment.topCenter, : [Color(0xFF3d3f54), Color(0xFF333450), Color(0xFF2b2b4d)],
end: Alignment.bottomCenter, begin: Alignment.topCenter,
)), end: Alignment.bottomCenter,
// decoration: messageOptions.messageDecorationBuilder != null )),
// ? messageOptions.messageDecorationBuilder!( // decoration: messageOptions.messageDecorationBuilder != null
// message, previousMessage, nextMessage) // ? messageOptions.messageDecorationBuilder!(
// : defaultMessageDecoration( // message, previousMessage, nextMessage)
// color: isOwnMessage // : defaultMessageDecoration(
// ? (messageOptions.currentUserContainerColor ?? // color: isOwnMessage
// Theme.of(context).primaryColor) // ? (messageOptions.currentUserContainerColor ??
// : (messageOptions.containerColor ?? Colors.grey[100])!, // Theme.of(context).primaryColor)
// borderTopLeft: // : (messageOptions.containerColor ?? Colors.grey[100])!,
// isPreviousSameAuthor && !isOwnMessage && !isAfterDateSeparator // borderTopLeft:
// ? 0.0 // isPreviousSameAuthor && !isOwnMessage && !isAfterDateSeparator
// : 18.0, // ? 0.0
// borderTopRight: // : 18.0,
// isPreviousSameAuthor && isOwnMessage && !isAfterDateSeparator // borderTopRight:
// ? 0.0 // isPreviousSameAuthor && isOwnMessage && !isAfterDateSeparator
// : 18.0, // ? 0.0
// borderBottomLeft: // : 18.0,
// !isOwnMessage && !isBeforeDateSeparator && isNextSameAuthor // borderBottomLeft:
// ? 0.0 // !isOwnMessage && !isBeforeDateSeparator && isNextSameAuthor
// : 18.0, // ? 0.0
// borderBottomRight: // : 18.0,
// isOwnMessage && !isBeforeDateSeparator && isNextSameAuthor // borderBottomRight:
// ? 0.0 // isOwnMessage && !isBeforeDateSeparator && isNextSameAuthor
// : 18.0, // ? 0.0
// ), // : 18.0,
padding: messageOptions.messagePadding ?? const EdgeInsets.all(16), // ),
child: DefaultMessageText( padding: messageOptions.messagePadding ?? const EdgeInsets.all(16),
index: index, child: DefaultMessageText(
messageLength: messageLength, index: index,
message: message, messageLength: messageLength,
isOwnMessage: isOwnMessage, message: message,
messageOptions: messageOptions, isOwnMessage: isOwnMessage,
), messageOptions: messageOptions,
); ));
// CustomPopupMenu(
// // controller: CustomPopupMenuController().hideMenu(),
// menuBuilder: () => _buildLongPressMenu(message, context),
// barrierColor: Colors.transparent,
// position: PreferredPosition.bottom,
// pressType: PressType.longPress,
// child: ,
// ));
} }
// @override
// State<DefaultMessageText> createState() => _DefaultMessageTextState();
} }
// messageTextBuilder != null // messageTextBuilder != null
// ? messageTextBuilder!(message, previousMessage, nextMessage) // ? messageTextBuilder!(message, previousMessage, nextMessage)
// : // :
\ No newline at end of file
// List<PopupMenuItemBean> topList = List();
// PopupMenuItemBean item = PopupMenuItemBean();
// item.title = "点赞";
// item.id = "点赞value";
// item.icon = "images/business_live_menu_zan.png";
// topList.add(item);
// List<PopupMenuItemBean> bottomList = List();
// List<Map<String, String>> bottomListData = [
// {"title": "复制", "id": "复制id", "icon": "images/business_live_menu_copy.png"},
// {"title": "回复", "id": "回复id", "icon": "images/business_live_menu_reply.png"},
// {"title": "添加表情", "id": "添加表情id", "icon": "images/business_live_menu_emoji.png"},
// {"title": "撤回", "id": "撤回id", "icon": "images/business_live_menu_back.png"},
// {"title": "举报", "id": "举报id", "icon": "images/business_live_menu_report.png"},
// {"title": "屏蔽", "id": "屏蔽id", "icon": "images/business_live_menu_shielding.png"},
// {"title": "封禁", "id": "封禁id", "icon": "images/business_live_menu_forbidden.png"},
// ];
// bottomListData.forEach((Map item) {
// PopupMenuItemBean bottomItem = PopupMenuItemBean();
// bottomItem.title = item["title"];
// bottomItem.id = item["id"];
// bottomItem.icon = item["icon"];
// bottomList.add(bottomItem);
// });
// if (bottomList.length == 0) return;
// PopupMenuUtils.popupPositioned(
// context: context,
// topList: topList,
// bottomList: bottomList,
// tapPos: tapPos,
// onSelected: (PopupMenuItemBean item) {
// print(item.title);
// },
// );
\ No newline at end of file
import 'dart:async'; import 'dart:async';
// import 'package:vibration/vibration.dart'; // import 'package:vibration/vibration.dart';
import 'package:chart/pages/frame/notfound/index.dart'; import 'package:chart/pages/frame/notfound/index.dart';
import 'package:chart/pages/home/controller.dart';
import 'package:flutter_vibrate/flutter_vibrate.dart'; import 'package:flutter_vibrate/flutter_vibrate.dart';
import 'package:flutter/foundation.dart'; import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
...@@ -9,6 +10,9 @@ import 'package:chart/common/routers/routes.dart'; ...@@ -9,6 +10,9 @@ import 'package:chart/common/routers/routes.dart';
import 'package:chart/common/utils/utils.dart'; import 'package:chart/common/utils/utils.dart';
import 'package:chart/common/values/values.dart'; import 'package:chart/common/values/values.dart';
import 'package:get/get.dart'; import 'package:get/get.dart';
import 'package:speech_to_text/speech_recognition_result.dart';
import 'package:speech_to_text/speech_to_text.dart';
import 'package:chart/package/chat_dash/dash_chat_2.dart' as Chat;
// import 'package:vibrate/vibrate.dart'; // import 'package:vibrate/vibrate.dart';
// import 'package:uni_links/uni_links.dart'; // import 'package:uni_links/uni_links.dart';
...@@ -29,6 +33,8 @@ import 'index.dart'; ...@@ -29,6 +33,8 @@ import 'index.dart';
class ApplicationController extends GetxController { class ApplicationController extends GetxController {
ApplicationController(); ApplicationController();
static ApplicationController get to => Get.put(ApplicationController());
/// 响应式成员变量 /// 响应式成员变量
final state = ApplicationState(); final state = ApplicationState();
...@@ -38,12 +44,67 @@ class ApplicationController extends GetxController { ...@@ -38,12 +44,67 @@ class ApplicationController extends GetxController {
// tab 页标题 // tab 页标题
late final List<String> tabTitles; late final List<String> tabTitles;
//键盘
// 页控制器 // 页控制器
late final PageController pageController; late final PageController pageController;
final TextEditingController textController = TextEditingController();
// 底部导航项目 // 底部导航项目
late final List<BottomNavigationBarItem> bottomTabs; late final List<BottomNavigationBarItem> bottomTabs;
SpeechToText _speechToText = SpeechToText();
SpeechToText get speechToText => _speechToText;
void startListening() async {
await _speechToText.listen(onResult: _onSpeechResult);
}
void _onSpeechResult(SpeechRecognitionResult result) {
textController.text = result.recognizedWords;
// textController.text = result.recognizedWords;
// textController()
// speakText = result.recognizedWords;
// print('result---$result.');
}
void stopListening() async {
await _speechToText.stop();
}
// onLongPressStart: controller.onLongPressStart,
// onLongPressEnd: controller.onLongPressEnd,
onLongPressStart(LongPressStartDetails details) async {
Vibrate.feedback(FeedbackType.impact);
state.showVoc = true;
state.isSpeak = true;
startListening();
}
onLongPressEnd(LongPressEndDetails details) {
state.isSpeak = false;
stopListening();
}
sendMessage() {
state.showVoc = false;
Chat.ChatUser _user = Chat.ChatUser(
id: '1',
// firstName: 'Charles',
// lastName: 'Leclerc',
);
HomeController.to.sendMessage(Chat.ChatMessage(
text: textController.text,
user: _user,
createdAt: DateTime.now(),
));
textController.text = '';
// sendMessage
}
/// 事件 /// 事件
// tab栏动画 // tab栏动画
...@@ -119,9 +180,14 @@ class ApplicationController extends GetxController { ...@@ -119,9 +180,14 @@ class ApplicationController extends GetxController {
/// 生命周期 /// 生命周期
@override @override
void onInit() { void onInit() async {
super.onInit(); super.onInit();
//
//
// // isKeyboardOpen.value = Get.focusScope.hasFocus;
// });
// handleInitialUri(); // handleInitialUri();
// handleIncomingLinks(); // handleIncomingLinks();
...@@ -154,15 +220,9 @@ class ApplicationController extends GetxController { ...@@ -154,15 +220,9 @@ class ApplicationController extends GetxController {
label: '私人助理', label: '私人助理',
backgroundColor: AppColors.primaryBackground, backgroundColor: AppColors.primaryBackground,
), ),
// const BottomNavigationBarItem(
// icon: Image(image: AssetImage("assets/images/my.png"), width: 30.0),
// activeIcon: Image(
// image: AssetImage("assets/images/my-selected.png"), width: 30.0),
// label: '我的',
// backgroundColor: AppColors.primaryBackground,
// ),
]; ];
pageController = PageController(initialPage: state.page); pageController = PageController(initialPage: state.page);
// await _speechToText.initialize();
} }
@override @override
...@@ -179,6 +239,8 @@ class ApplicationController extends GetxController { ...@@ -179,6 +239,8 @@ class ApplicationController extends GetxController {
void dispose() { void dispose() {
uriSub?.cancel(); uriSub?.cancel();
pageController.dispose(); pageController.dispose();
_speechToText.cancel();
// await _speechToText.initialize();
super.dispose(); super.dispose();
} }
} }
...@@ -5,4 +5,16 @@ class ApplicationState { ...@@ -5,4 +5,16 @@ class ApplicationState {
final _page = 0.obs; final _page = 0.obs;
set page(value) => this._page.value = value; set page(value) => this._page.value = value;
get page => this._page.value; get page => this._page.value;
final _showVoc = false.obs;
set showVoc(value) => _showVoc.value = value;
get showVoc => _showVoc.value;
final _isSpeak = false.obs;
set isSpeak(value) => _isSpeak.value = value;
get isSpeak => _isSpeak.value;
final _isNetWorkErr = false.obs;
set isNetWorkErr(value) => _isNetWorkErr.value = value;
get isNetWorkErr => _isNetWorkErr.value;
} }
import 'dart:math';
import 'package:chart/pages/assistant/index.dart'; import 'package:chart/pages/assistant/index.dart';
import 'package:chart/pages/creation/index.dart'; import 'package:chart/pages/creation/index.dart';
import 'package:chart/pages/home/index.dart'; import 'package:chart/pages/home/index.dart';
...@@ -8,8 +10,13 @@ import 'package:chart/common/widgets/widgets.dart'; ...@@ -8,8 +10,13 @@ import 'package:chart/common/widgets/widgets.dart';
import 'package:chart/pages/category/index.dart'; import 'package:chart/pages/category/index.dart';
import 'package:chart/pages/main/index.dart'; import 'package:chart/pages/main/index.dart';
import 'package:chart/pages/user/index.dart'; import 'package:chart/pages/user/index.dart';
import 'package:flutter_keyboard_visibility/flutter_keyboard_visibility.dart';
import 'package:flutter_persistent_keyboard_height/flutter_persistent_keyboard_height.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:get/get.dart'; import 'package:get/get.dart';
import 'package:highlight/languages/autoit.dart';
import 'package:loading_animation_widget/loading_animation_widget.dart';
// import 'package:text_editor/text_editor.dart';
// import '../dashboard/dashboard_page.dart'; // import '../dashboard/dashboard_page.dart';
import 'index.dart'; import 'index.dart';
...@@ -102,6 +109,8 @@ class ApplicationPage extends GetView<ApplicationController> { ...@@ -102,6 +109,8 @@ class ApplicationPage extends GetView<ApplicationController> {
// }, // },
// letIndexChange: (index) => true, // letIndexChange: (index) => true,
// ), // ),
final appController = Get.put(ApplicationController());
return Obx(() => BottomNavigationBar( return Obx(() => BottomNavigationBar(
// #363b48 // #363b48
...@@ -112,12 +121,12 @@ class ApplicationPage extends GetView<ApplicationController> { ...@@ -112,12 +121,12 @@ class ApplicationPage extends GetView<ApplicationController> {
fixedColor: Colors.white, fixedColor: Colors.white,
elevation: 0, elevation: 0,
// Color(0x363b48FF), // Color(0x363b48FF),
items: controller.bottomTabs, items: appController.bottomTabs,
currentIndex: controller.state.page, currentIndex: appController.state.page,
// fixedColor: AppColors.primaryElement, // fixedColor: AppColors.primaryElement,
landscapeLayout: BottomNavigationBarLandscapeLayout.spread, landscapeLayout: BottomNavigationBarLandscapeLayout.spread,
type: BottomNavigationBarType.fixed, type: BottomNavigationBarType.fixed,
onTap: controller.handleNavBarTap, onTap: appController.handleNavBarTap,
showSelectedLabels: true, showSelectedLabels: true,
showUnselectedLabels: true, showUnselectedLabels: true,
selectedLabelStyle: TextStyle( selectedLabelStyle: TextStyle(
...@@ -127,23 +136,307 @@ class ApplicationPage extends GetView<ApplicationController> { ...@@ -127,23 +136,307 @@ class ApplicationPage extends GetView<ApplicationController> {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return Container( CustomClipper<Path> clipper = MyCustomClipper();
decoration: BoxDecoration( var bottom = MediaQuery.of(context).viewInsets.bottom;
image: DecorationImage( // final keyboardHeight = PersistentKeyboardHeight.of(context).keyboardHeight;
image: Image.asset("assets/images/background.png").image, return Obx(() => Stack(
fit: BoxFit.cover), children: [
), Container(
child: Obx(() => Scaffold( decoration: BoxDecoration(
backgroundColor: Color.fromARGB(0, 0, 0, 0), image: DecorationImage(
// appBar: _buildAppBar(), image: Image.asset("assets/images/background.png").image,
body: _buildPageView(), fit: BoxFit.cover),
bottomNavigationBar: _buildBottomNavigationBar(), ),
// floatingActionButton: FloatingActionButton( child: Scaffold(
// child: Icon(Icons.chat), // resizeToAvoidBottomInset: false,
// onPressed: controller.handleChat, backgroundColor: Color.fromARGB(0, 0, 0, 0),
// ), // appBar: _buildAppBar(),
// floatingActionButtonLocation: FloatingActionButtonLocation.endFloat, body: _buildPageView(),
)), bottomNavigationBar: _buildBottomNavigationBar(),
); // floatingActionButton: FloatingActionButton(
// child: Icon(Icons.chat),
// onPressed: controller.handleChat,
// ),
// floatingActionButtonLocation: FloatingActionButtonLocation.endFloat,
),
),
controller.state.showVoc
? Positioned(
top: 0,
left: 0,
bottom: 0,
right: 0,
child: GestureDetector(
onTap: () =>
FocusManager.instance.primaryFocus?.unfocus(),
child: SizedBox(
height: Get.height,
width: Get.width,
child: Container(
// margin: EdgeInsets.only(bottom: 0),
color: Colors.black.withOpacity(0.8),
child: Stack(
children: [
Positioned(
bottom: 0,
child: GestureDetector(
onLongPressStart:
controller.onLongPressStart,
onLongPressEnd: controller.onLongPressEnd,
child: DecoratedBox(
decoration: BoxDecoration(
color: Colors.blue.withAlpha(0)),
child: Transform.rotate(
//旋转90度
angle: pi / 2 * 90,
child: ClipPath(
clipper: clipper,
child: Container(
color: Color.fromARGB(
255, 56, 57, 70),
width: Get.width,
height: 300,
// child: IconButton(
// onPressed: () {},
// icon: Icon(Icons.settings_voice_sharp),
// ),
),
),
),
))),
Positioned(
left: Get.width / 2 - 30,
bottom: 90,
child: GestureDetector(
onLongPressStart:
controller.onLongPressStart,
onLongPressEnd: controller.onLongPressEnd,
child: Container(
padding: EdgeInsets.all(20),
decoration: BoxDecoration(
borderRadius:
BorderRadius.circular(40.0),
// color:
// Color.fromARGB(255, 199, 198, 202),
gradient: LinearGradient(
colors: controller.state.isSpeak
? [
Color.fromARGB(
255, 44, 46, 77),
Color.fromARGB(
255, 48, 54, 82),
Color.fromARGB(
255, 55, 62, 88)
]
: [
Color.fromARGB(
255, 199, 198, 202),
Color.fromARGB(
255, 199, 198, 202),
],
begin: Alignment.topCenter,
end: Alignment.bottomCenter,
),
boxShadow: [
BoxShadow(
color: Colors.black
.withAlpha(12),
offset: Offset(
0.0, 5.0), //阴影xy轴偏移量
blurRadius: 5.0, //阴影模糊程度
spreadRadius: 1.0 //阴影扩散程度
)
]),
child: Icon(
Icons.settings_voice_sharp,
color: controller.state.isSpeak
? Colors.white
: Color.fromARGB(255, 60, 58, 70),
),
))),
KeyboardVisibilityBuilder(
builder: (context, visible) {
return Positioned(
bottom: visible ? bottom + 100 : 200,
left: 0,
right: 0,
child: Column(
children: [
Container(
margin: const EdgeInsets.symmetric(
horizontal: 20),
padding: const EdgeInsets.only(
left: 20, top: 20, right: 20),
// margin: EdgeInsets.only(bottom: 100),
decoration: BoxDecoration(
borderRadius:
BorderRadius.circular(10),
// ignore: prefer_const_constructors
gradient: LinearGradient(
begin: Alignment.topCenter,
end: Alignment.bottomCenter,
// background-image: linear-gradient(180deg, #3d3f54, #333450, #2b2b4d);
colors: const [
Color.fromARGB(
255, 203, 104, 252),
Color.fromARGB(
255, 154, 104, 254),
Color.fromARGB(
255, 125, 102, 251)
]),
),
constraints: const BoxConstraints(
minHeight: 10,
// minWidth: 200,
// maxHeight: 200,
// 设置最小高度为100
),
// padding: EdgeInsets.all(20),
child: Column(
children: [
TextField(
cursorColor:
Colors.white, // 设置光标颜色
decoration:
const InputDecoration(
contentPadding:
EdgeInsets.fromLTRB(
20, 10, 0, 9),
border: InputBorder.none,
),
controller:
controller.textController,
// focusNode: FocusNode(),
maxLines: null,
),
Row(
mainAxisAlignment:
MainAxisAlignment.end,
children: [
LoadingAnimationWidget
.staggeredDotsWave(
color:
controller.state.isSpeak
? Colors.white
: Colors.white
.withOpacity(0),
size: 20,
),
],
)
],
)),
SizedBox(
height: 10,
),
const Text(
"轻触气泡修改文字",
style: TextStyle(
color: Color.fromARGB(
255, 129, 129, 134)),
),
SizedBox(
height: 40,
),
Row(
mainAxisAlignment:
MainAxisAlignment.spaceAround,
children: [
GestureDetector(
onTap: () {
controller.state.showVoc = false;
controller.textController.text =
'';
},
child: Container(
width: 70,
height: 70,
decoration: BoxDecoration(
borderRadius:
BorderRadius.circular(35),
// ignore: prefer_const_constructors
gradient: LinearGradient(
begin: Alignment.topCenter,
end: Alignment.bottomCenter,
// background-image: linear-gradient(180deg, #3d3f54, #333450, #2b2b4d);
colors: const [
Color.fromARGB(
255, 240, 85, 68),
Color.fromARGB(
255, 240, 85, 68)
]),
),
child: Icon(Icons.close),
),
),
SizedBox(
width: Get.width * 0.14,
),
InkWell(
onTap: () {
controller.sendMessage();
},
child: Container(
width: 70,
height: 70,
decoration: BoxDecoration(
borderRadius:
BorderRadius.circular(35),
// ignore: prefer_const_constructors
gradient: LinearGradient(
begin: Alignment.topCenter,
end: Alignment.bottomCenter,
// background-image: linear-gradient(180deg, #3d3f54, #333450, #2b2b4d);
colors: const [
Color.fromARGB(
255, 130, 106, 250),
Color.fromARGB(
255, 130, 106, 250)
]),
),
child: const Icon(Icons.done),
),
)
],
)
],
),
);
})
],
),
),
),
),
)
: const SizedBox.shrink()
],
));
}
}
class MyCustomClipper extends CustomClipper<Path> {
@override
Path getClip(Size size) {
// 左下角
var path = Path();
path.lineTo(0, 0); //第一个点
path.lineTo(0, size.height - 180); //第二个点
var firstControlPoint = Offset(size.width / 2, size.height); //曲线开始点
var firstendPoint = Offset(size.width, size.height - 180); // 曲线结束点
path.quadraticBezierTo(firstControlPoint.dx, firstControlPoint.dy,
firstendPoint.dx, firstendPoint.dy);
path.lineTo(size.width, size.height - 180); //第四个点
path.lineTo(size.width, 0); // 第五个点
return path;
}
@override
bool shouldReclip(CustomClipper<Path> oldClipper) {
return true;
} }
} }
...@@ -4,6 +4,7 @@ import 'package:chart/common/apis/apis.dart'; ...@@ -4,6 +4,7 @@ import 'package:chart/common/apis/apis.dart';
import 'package:chart/common/entities/detail.dart'; import 'package:chart/common/entities/detail.dart';
import 'package:chart/common/store/user.dart'; import 'package:chart/common/store/user.dart';
import 'package:chart/common/values/server.dart'; import 'package:chart/common/values/server.dart';
import 'package:clipboard/clipboard.dart';
import 'package:flutter/cupertino.dart'; import 'package:flutter/cupertino.dart';
import 'package:flutter_client_sse/flutter_client_sse.dart'; import 'package:flutter_client_sse/flutter_client_sse.dart';
import 'package:flutter_easyloading/flutter_easyloading.dart'; import 'package:flutter_easyloading/flutter_easyloading.dart';
...@@ -47,6 +48,11 @@ class CreationDetailController extends GetxController { ...@@ -47,6 +48,11 @@ class CreationDetailController extends GetxController {
state.detailList.addAll(items); state.detailList.addAll(items);
} }
copyText() {
FlutterClipboard.copy(state.genText).then((value) =>
EasyLoading.showToast("复制成功", maskType: EasyLoadingMaskType.none));
}
void hideKeyboard() => FocusManager.instance.primaryFocus?.unfocus(); void hideKeyboard() => FocusManager.instance.primaryFocus?.unfocus();
void genInner() async { void genInner() async {
await initEventSource(); await initEventSource();
......
...@@ -142,24 +142,73 @@ class HelloWidget extends GetView<CreationDetailController> { ...@@ -142,24 +142,73 @@ class HelloWidget extends GetView<CreationDetailController> {
padding: const EdgeInsets.symmetric( padding: const EdgeInsets.symmetric(
horizontal: 10, vertical: 20), horizontal: 10, vertical: 20),
child: Row( child: Row(
mainAxisAlignment:
MainAxisAlignment
.spaceBetween,
children: [ children: [
Container( Row(
width: 3, children: [
height: 22, Container(
decoration: BoxDecoration( width: 3,
color: const Color( height: 22,
0xFFb05ddd), decoration: BoxDecoration(
borderRadius: color: const Color(
BorderRadius.circular( 0xFFb05ddd),
20)), borderRadius:
margin: const EdgeInsets.only( BorderRadius
right: 5), .circular(
20)),
margin:
const EdgeInsets.only(
right: 5),
),
const Text('生成结果',
style: TextStyle(
fontSize: 16,
fontWeight:
FontWeight
.w500)),
],
), ),
const Text('生成结果', InkWell(
style: TextStyle( onTap: () {
fontSize: 16, controller.copyText();
fontWeight: },
FontWeight.w500)), child: Row(
children: const [
Icon(
Icons
.content_paste_rounded,
color:
Color(0xFFb05ddd),
size: 18,
),
SizedBox(
width: 10,
),
// Container(
// width: 3,
// height: 22,
// decoration: BoxDecoration(
// color: const Color(
// 0xFFb05ddd),
// borderRadius:
// BorderRadius
// .circular(
// 20)),
// margin:
// const EdgeInsets.only(
// right: 5),
// ),
Text('复制内容',
style: TextStyle(
fontSize: 16,
fontWeight:
FontWeight
.w500)),
],
),
)
], ],
), ),
), ),
...@@ -171,6 +220,13 @@ class HelloWidget extends GetView<CreationDetailController> { ...@@ -171,6 +220,13 @@ class HelloWidget extends GetView<CreationDetailController> {
padding: padding:
const EdgeInsets.all(20), const EdgeInsets.all(20),
width: Get.width, width: Get.width,
constraints:
const BoxConstraints(
minHeight: 300,
// minWidth: 200,
// maxHeight: 200,
// 设置最小高度为100
),
decoration: BoxDecoration( decoration: BoxDecoration(
borderRadius: borderRadius:
BorderRadius.circular( BorderRadius.circular(
...@@ -180,11 +236,9 @@ class HelloWidget extends GetView<CreationDetailController> { ...@@ -180,11 +236,9 @@ class HelloWidget extends GetView<CreationDetailController> {
colors: [ colors: [
// 61, 63, 84 // 61, 63, 84
Color.fromARGB( Color.fromARGB(
75, 61, 63, 84), 255, 40, 40, 57),
Color.fromARGB(
75, 51, 52, 80),
Color.fromARGB( Color.fromARGB(
75, 43, 43, 77) 255, 40, 40, 57),
], ],
begin: begin:
Alignment.topCenter, Alignment.topCenter,
......
import 'package:get/get.dart'; import 'package:get/get.dart';
import 'package:webview_flutter/webview_flutter.dart';
import 'index.dart'; import 'index.dart';
...@@ -7,6 +8,22 @@ class UserEulaController extends GetxController { ...@@ -7,6 +8,22 @@ class UserEulaController extends GetxController {
final state = UserEulaState(); final state = UserEulaState();
final webViewController = WebViewController()
..setNavigationDelegate(NavigationDelegate(
onProgress: (int progress) {
// Update loading bar.
},
onPageStarted: (String url) {},
onPageFinished: (String url) {},
onWebResourceError: (WebResourceError error) {},
// onNavigationRequest: (NavigationRequest request) {
// if (request.url.startsWith('https://www.youtube.com/')) {
// return NavigationDecision.prevent;
// }
// return NavigationDecision.navigate;
// },
));
// tap // tap
void handleTap(int index) { void handleTap(int index) {
Get.snackbar( Get.snackbar(
...@@ -25,6 +42,7 @@ class UserEulaController extends GetxController { ...@@ -25,6 +42,7 @@ class UserEulaController extends GetxController {
@override @override
void onReady() { void onReady() {
super.onReady(); super.onReady();
webViewController.loadRequest(Uri.parse('https://p.kdocs.cn/s/UODC2BAAYQ'));
} }
/// 在 [onDelete] 方法之前调用。 /// 在 [onDelete] 方法之前调用。
......
...@@ -74,9 +74,13 @@ class UserEulaPage extends GetView<UserEulaController> { ...@@ -74,9 +74,13 @@ class UserEulaPage extends GetView<UserEulaController> {
body: Container( body: Container(
height: double.infinity, height: double.infinity,
width: double.infinity, width: double.infinity,
child: WebView( child: WebViewWidget(controller: controller.webViewController),
initialUrl: "https://p.kdocs.cn/s/UODC2BAAYQ", // child:
), // WebView(
// initialUrl: "https://p.kdocs.cn/s/UODC2BAAYQ",
// onWebResourceError: (error) {
// print(error);
// }),
)); ));
}, },
); );
......
...@@ -90,14 +90,14 @@ class PayItemWidget extends GetView<PayListController> { ...@@ -90,14 +90,14 @@ class PayItemWidget extends GetView<PayListController> {
)), )),
MarqueeView( MarqueeView(
child: Row(children: [ child: Row(children: [
_buildText('手机用户159****0542购买了按订阅套餐'), _buildText('手机用户159****0542购买了按订阅套餐'),
_buildText('手机用户136****1949购买了按年订阅套餐'), _buildText('手机用户136****1949购买了按年订阅套餐'),
_buildText('手机用户159****1252购买了按订阅套餐'), _buildText('手机用户159****1252购买了按订阅套餐'),
_buildText('手机用户176****1429购买了按订阅套餐'), _buildText('手机用户176****1429购买了按订阅套餐'),
_buildText('手机用户158****8953购买了按订阅套餐'), _buildText('手机用户158****8953购买了按订阅套餐'),
_buildText('手机用户139****2752购买了按年订阅套餐'), _buildText('手机用户139****2752购买了按年订阅套餐'),
_buildText('手机用户130****5959购买了按订阅套餐'), _buildText('手机用户130****5959购买了按订阅套餐'),
_buildText('手机用户158****6048购买了按订阅套餐'), _buildText('手机用户158****6048购买了按订阅套餐'),
_buildText('手机用户136****8962购买了按年订阅套餐'), _buildText('手机用户136****8962购买了按年订阅套餐'),
]), ]),
), ),
......
import 'package:chart/common/routers/routes.dart'; import 'package:chart/common/routers/routes.dart';
import 'package:chart/common/store/store.dart'; import 'package:chart/common/store/store.dart';
import 'package:chart/pages/application/controller.dart';
import 'package:get/get.dart'; import 'package:get/get.dart';
import 'index.dart'; import 'index.dart';
...@@ -8,7 +9,7 @@ class WelcomeController extends GetxController { ...@@ -8,7 +9,7 @@ class WelcomeController extends GetxController {
final state = WelcomeState(); final state = WelcomeState();
WelcomeController(); WelcomeController();
// WILL_COME
// 跳转 注册界面 // 跳转 注册界面
handleNavSignIn() async { handleNavSignIn() async {
await ConfigStore.to.saveAlreadyOpen(); await ConfigStore.to.saveAlreadyOpen();
...@@ -19,7 +20,9 @@ class WelcomeController extends GetxController { ...@@ -19,7 +20,9 @@ class WelcomeController extends GetxController {
handleHome() async { handleHome() async {
await UserStore.to.refreshInfo(); await UserStore.to.refreshInfo();
await ConfigStore.to.saveAlreadyOpen(); await ConfigStore.to.saveAlreadyOpen();
// ApplicationController.to.state.isNetWorkErr = false;
Get.offAndToNamed(AppRoutes.Application); Get.offAndToNamed(AppRoutes.Application);
// Get.put(ApplicationController());
} }
@override @override
......
...@@ -7,6 +7,7 @@ import 'package:chart/common/values/server.dart'; ...@@ -7,6 +7,7 @@ import 'package:chart/common/values/server.dart';
import 'package:chart/entity/user_entity.dart'; import 'package:chart/entity/user_entity.dart';
import 'package:chart/package/chat_dash/dash_chat_2.dart' as Chat; import 'package:chart/package/chat_dash/dash_chat_2.dart' as Chat;
import 'package:chart/package/chat_dash/dash_chat_2.dart'; import 'package:chart/package/chat_dash/dash_chat_2.dart';
import 'package:chart/pages/application/controller.dart';
import 'package:chart/pages/category/controller.dart'; import 'package:chart/pages/category/controller.dart';
import 'package:chart/pages/frame/product/controller.dart'; import 'package:chart/pages/frame/product/controller.dart';
import 'package:flutter/foundation.dart'; import 'package:flutter/foundation.dart';
...@@ -15,6 +16,7 @@ import 'package:flutter/widgets.dart'; ...@@ -15,6 +16,7 @@ import 'package:flutter/widgets.dart';
import 'package:flutter_easyloading/flutter_easyloading.dart'; import 'package:flutter_easyloading/flutter_easyloading.dart';
import 'package:flutter_vibrate/flutter_vibrate.dart'; import 'package:flutter_vibrate/flutter_vibrate.dart';
import 'package:get/get.dart'; import 'package:get/get.dart';
import 'package:highlight/languages/awk.dart';
import 'package:share_plus/share_plus.dart'; import 'package:share_plus/share_plus.dart';
import 'package:uuid/uuid.dart'; import 'package:uuid/uuid.dart';
import 'package:flutter_chat_types/flutter_chat_types.dart' as types; import 'package:flutter_chat_types/flutter_chat_types.dart' as types;
...@@ -255,6 +257,16 @@ class HomeController extends GetxController with SingleGetTickerProviderMixin { ...@@ -255,6 +257,16 @@ class HomeController extends GetxController with SingleGetTickerProviderMixin {
Get.toNamed("${AppRoutes.CHAT_PAGE}"); Get.toNamed("${AppRoutes.CHAT_PAGE}");
} }
changeInput() async {
if (state.isInputText &&
!ApplicationController.to.speechToText.isAvailable) {
await ApplicationController.to.speechToText.initialize();
} else {
Vibrate.feedback(FeedbackType.impact);
state.isInputText = !state.isInputText;
}
}
sendMessageByBanner(String message) async { sendMessageByBanner(String message) async {
await createConversionId(); await createConversionId();
...@@ -292,9 +304,8 @@ class HomeController extends GetxController with SingleGetTickerProviderMixin { ...@@ -292,9 +304,8 @@ class HomeController extends GetxController with SingleGetTickerProviderMixin {
return; return;
} }
Map<String, dynamic> jsonMap = jsonDecode("${event.data}"); Map<String, dynamic> jsonMap = jsonDecode("${event.data}");
if (jsonMap['askType'] == 1) {
_updateMessage("${jsonMap['content']}" as String); _updateMessage("${jsonMap['content']}" as String);
}
}); });
// print(sse); // print(sse);
...@@ -308,7 +319,7 @@ class HomeController extends GetxController with SingleGetTickerProviderMixin { ...@@ -308,7 +319,7 @@ class HomeController extends GetxController with SingleGetTickerProviderMixin {
} }
_updateMessage(String text) { _updateMessage(String text) {
print(state.messageList.length); // print(state.messageList.length);
// state.messageList[0].text = state.messageList[0].text + text; // state.messageList[0].text = state.messageList[0].text + text;
// state.messageList.forEach((element) { // state.messageList.forEach((element) {
// print(element.text); // print(element.text);
...@@ -317,19 +328,34 @@ class HomeController extends GetxController with SingleGetTickerProviderMixin { ...@@ -317,19 +328,34 @@ class HomeController extends GetxController with SingleGetTickerProviderMixin {
if (state.messageList.isEmpty) { if (state.messageList.isEmpty) {
return; return;
} }
state.messageList.setRange(0, 1, [ if (text.contains("建议您重新开启一个会话。")) {
ChatMessage( state.messageList.setRange(0, 1, [
user: receiveUser, ChatMessage(
createdAt: DateTime.now(), user: receiveUser,
text: state.messageList.value[0].text == "LOADING" createdAt: DateTime.now(),
? text text: "您关联的上下文超出了我的理解能力范围,请点击右上角刷新按钮重置会话。"
: state.messageList.value[0].text + text // user: receiveUser,
// user: receiveUser, // createdAt: DateTime.now(),
// createdAt: DateTime.now(), // // id: const Uuid().v4(),
// // id: const Uuid().v4(), // text: "",
// text: "", )
) ]);
]); } else {
state.messageList.setRange(0, 1, [
ChatMessage(
user: receiveUser,
createdAt: DateTime.now(),
text: state.messageList.value[0].text == "LOADING"
? text
: state.messageList.value[0].text + text
// user: receiveUser,
// createdAt: DateTime.now(),
// // id: const Uuid().v4(),
// text: "",
)
]);
}
// state.messageList.value = [...state.messageList.value];list.setRange(1, 4, [9, 9, 9]); // state.messageList.value = [...state.messageList.value];list.setRange(1, 4, [9, 9, 9]);
// state.messageList.value[0].text = state.messageList.value[0].text + text; // state.messageList.value[0].text = state.messageList.value[0].text + text;
} }
...@@ -427,5 +453,16 @@ class HomeController extends GetxController with SingleGetTickerProviderMixin { ...@@ -427,5 +453,16 @@ class HomeController extends GetxController with SingleGetTickerProviderMixin {
// refreshController.dispose(); // refreshController.dispose();
} }
onLongPressStart(LongPressStartDetails details) {
ApplicationController.to.onLongPressStart(details);
}
onLongPressEnd(LongPressEndDetails details) {
ApplicationController.to.onLongPressEnd(details);
}
// onLongPressStart: cc.onLongPressStart,
// onLongPressEnd: cc.onLongPressEnd
// obx(Map map) {} // obx(Map map) {}
} }
...@@ -75,5 +75,13 @@ class ChatPageState { ...@@ -75,5 +75,13 @@ class ChatPageState {
set isNext(value) => _isNext.value = value; set isNext(value) => _isNext.value = value;
get isNext => _isNext.value; get isNext => _isNext.value;
final RxBool _isInputText = true.obs;
set isInputText(value) => _isInputText.value = value;
get isInputText => _isInputText.value;
final RxBool _readOnly = false.obs;
set readOnly(value) => _readOnly.value = value;
get readOnly => _readOnly.value;
// RxList<NewsItem> newsList = <NewsItem>[].obs; // RxList<NewsItem> newsList = <NewsItem>[].obs;
} }
...@@ -4,6 +4,7 @@ import 'package:flutter/material.dart'; ...@@ -4,6 +4,7 @@ import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:get/get.dart'; import 'package:get/get.dart';
import 'package:flutter_chat_types/flutter_chat_types.dart' as types; import 'package:flutter_chat_types/flutter_chat_types.dart' as types;
import 'package:gradient_borders/gradient_borders.dart';
import 'package:gradient_widgets/gradient_widgets.dart'; import 'package:gradient_widgets/gradient_widgets.dart';
import '../../../common/widgets/app.dart'; import '../../../common/widgets/app.dart';
import 'index.dart'; import 'index.dart';
...@@ -26,117 +27,194 @@ class HomePage extends GetView<HomeController> { ...@@ -26,117 +27,194 @@ class HomePage extends GetView<HomeController> {
return false; return false;
}, },
child: Obx(() => Scaffold( child: Obx(() => Scaffold(
backgroundColor: Color.fromARGB(0, 0, 0, 0), resizeToAvoidBottomInset: false,
appBar: transparentAppBar( backgroundColor: Color.fromARGB(0, 0, 0, 0),
actions: [ appBar: transparentAppBar(
RotationTransition( actions: [
turns: controller.animation, RotationTransition(
child: IconButton( turns: controller.animation,
tooltip: '重置', child: IconButton(
tooltip: '重置',
icon: const Icon(
Icons.settings_backup_restore_sharp,
color: AppColors.primaryElementText,
),
onPressed: () {
controller.reset();
},
),
),
IconButton(
tooltip: '设置',
icon: const Icon( icon: const Icon(
Icons.settings_backup_restore_sharp, Icons.settings,
color: AppColors.primaryElementText, color: AppColors.primaryElementText,
), ),
onPressed: () { onPressed: () {
controller.reset(); controller.share();
}, },
), )
), ],
IconButton( title: RichText(
tooltip: '设置', textAlign: TextAlign.center,
icon: const Icon( text: TextSpan(children: [
Icons.settings, TextSpan(
color: AppColors.primaryElementText, text: "${controller.state.page}",
), style: const TextStyle(
onPressed: () { color: AppColors.primaryElementText,
controller.share(); fontFamily: 'Montserrat',
}, fontSize: 18,
) fontWeight: FontWeight.w600,
], )),
title: RichText( TextSpan(
textAlign: TextAlign.center, text: "${controller.state.messageList.length}",
text: TextSpan(children: [ style: const TextStyle(fontSize: 0)),
TextSpan( ])),
text: "${controller.state.page}", leading: GradientButton(
style: TextStyle( increaseHeightBy: -5,
color: AppColors.primaryElementText, // increaseWidthBy: 5,
fontFamily: 'Montserrat', elevation: 0,
fontSize: 18, shadowColor: Colors.black,
fontWeight: FontWeight.w600, gradient: const LinearGradient(
)), colors: [
TextSpan( Color.fromARGB(255, 223, 188, 134),
text: "${controller.state.messageList.length}", Color.fromARGB(255, 244, 218, 129),
style: TextStyle(fontSize: 0)), Color.fromARGB(255, 248, 228, 127)
])), ],
leading: GradientButton( begin: Alignment.topLeft,
increaseHeightBy: -5, end: Alignment.bottomRight,
increaseWidthBy: 105,
elevation: 0,
shadowColor: Colors.black,
gradient: const LinearGradient(
colors: [
Color.fromARGB(255, 223, 188, 134),
Color.fromARGB(255, 244, 218, 129),
Color.fromARGB(255, 248, 228, 127)
],
begin: Alignment.topLeft,
end: Alignment.bottomRight,
),
child: Row(children: const [
Icon(
Icons.add_circle,
color: Colors.black,
size: 30,
), ),
SizedBox( child: Row(children: const [
width: 10, Icon(
Icons.add_circle,
color: Colors.black,
size: 30,
),
SizedBox(
width: 10,
),
Text("订阅",
style: TextStyle(
color: Color.fromARGB(255, 95, 54, 0),
fontSize: 16)),
]),
callback: () => controller.virtualPay()),
),
body: SizedBox(
width: double.infinity,
height: double.infinity,
// color: Color.fromARGB(0, 255, 255, 0),
// color: Colors.red,
// Color.argb(255, 29, 33, 60)
// color: Color.fromARGB(0, 29, 33, 60),
// color: Color.fromARGB(255, 26, 27, 46),
child: Chat.DashChat(
// readOnly: cc.state.readOnly,
inputOptions: Chat.InputOptions(
onLongPressStart: cc.onLongPressStart,
onLongPressEnd: cc.onLongPressEnd,
textInputAction: TextInputAction.send,
inputDisabled: cc.state.isLoading,
sendOnEnter: true,
leading: [
// GradientCircularProgressIndicator(
// radius: 100,
// ),
// GradientRotation(1.0,),
// GradientButton(
// child: Icon(Icons.text_fields_sharp), callback: () {}),
Container(
margin: const EdgeInsets.only(right: 10),
child: InkWell(
borderRadius: BorderRadius.circular(100),
onTap: cc.changeInput,
child: Container(
decoration: const BoxDecoration(
shape: BoxShape.circle,
border: GradientBoxBorder(
gradient: LinearGradient(colors: [
Color(0xFFbe6afb),
// Color(0xFF9c67f6),
Color(0xFF7965f8)
]),
width: 2,
),
),
padding: const EdgeInsets.all(10),
child: Icon(
!cc.state.isInputText
? Icons.keyboard
: Icons.keyboard_voice,
),
)),
// padding: EdgeInsets.all(10),
// margin: EdgeInsets.only(right: 10),
// child: Icon(Icons.text_fields_sharp),
// decoration: const BoxDecoration(
// shape: BoxShape.circle,
// border: GradientBoxBorder(
// gradient: LinearGradient(
// colors: [Colors.pink, Colors.orange]),
// width: 2,
// ),
// ),
),
// Container(
// padding: EdgeInsets.all(10),
// margin: EdgeInsets.only(right: 10),
// decoration: const BoxDecoration(
// // color: Colors.red,
// borderRadius: BorderRadius.all(Radius.circular(54)),
// border: Border(
// top: BorderSide(
// width: 2.0,
// color: Colors.red,
// ),
// bottom: BorderSide(
// width: 2.0,
// color: Colors.red,
// ),
// right: BorderSide(
// width: 2.0,
// color: Colors.red,
// ),
// left: BorderSide(
// width: 2.0,
// color: Colors.red,
// ),
// ),
// ),
// child: Icon(Icons.text_fields_sharp),
// )
],
// showTraillingBeforeSend: true,
isTextInput: cc.state.isInputText,
inputTextStyle: TextStyle(color: Colors.white),
inputToolbarStyle: BoxDecoration(
color: Color.fromARGB(120, 0, 0, 0),
// Color.fromARGB(0, 54, 59, 72),
borderRadius: BorderRadius.only(
topLeft: Radius.circular(16),
topRight: Radius.circular(16)),
), ),
Text("订阅", inputToolbarMargin: EdgeInsets.all(0),
style: TextStyle( sendButtonBuilder: null,
color: Color.fromARGB(255, 95, 54, 0), inputToolbarPadding: EdgeInsets.only(
fontSize: 16)), top: 15, right: 15, left: 15, bottom: 10),
]), ),
callback: () => controller.virtualPay()), currentUser: _user,
), onSend: cc.sendMessage,
body: SizedBox( messages: cc.state.messageList,
width: double.infinity, messageOptions: Chat.MessageOptions(
height: double.infinity, onPressMessage: cc.tabMessage,
// color: Color.fromARGB(0, 255, 255, 0), onLongPressMessage: (mes) => {},
// color: Colors.red,
// Color.argb(255, 29, 33, 60)
// color: Color.fromARGB(0, 29, 33, 60),
// color: Color.fromARGB(255, 26, 27, 46),
child: Chat.DashChat(
inputOptions: Chat.InputOptions(
textInputAction: TextInputAction.send,
inputDisabled: cc.state.isLoading,
sendOnEnter: true,
// showTraillingBeforeSend: true,
// inputDisabled: cc.state.isLoading,
inputTextStyle: TextStyle(color: Colors.white),
inputToolbarStyle: BoxDecoration(
color: Color.fromARGB(120, 0, 0, 0),
// Color.fromARGB(0, 54, 59, 72), // containerColor: Colors.black,
borderRadius: BorderRadius.only(
topLeft: Radius.circular(16),
topRight: Radius.circular(16)),
), ),
inputToolbarMargin: EdgeInsets.all(0),
sendButtonBuilder: null,
inputToolbarPadding:
EdgeInsets.only(top: 15, right: 15, left: 15, bottom: 10),
),
currentUser: _user,
onSend: cc.sendMessage,
messages: cc.state.messageList,
messageOptions: Chat.MessageOptions(
onPressMessage: cc.tabMessage,
onLongPressMessage: (mes) => {},
// containerColor: Colors.black,
), ),
), ),
)))); )));
} }
} }
......
...@@ -180,9 +180,6 @@ class MyPage extends GetView<MyController> { ...@@ -180,9 +180,6 @@ class MyPage extends GetView<MyController> {
), ),
), ),
), ),
Container(
child: Text("12"),
)
// GradientButton(child: Text("321"), callback: () {}) // GradientButton(child: Text("321"), callback: () {})
], ],
); );
......
import 'package:get/get.dart'; import 'package:get/get.dart';
import 'package:webview_flutter/webview_flutter.dart';
import 'index.dart'; import 'index.dart';
...@@ -7,6 +8,21 @@ class PrivacyController extends GetxController { ...@@ -7,6 +8,21 @@ class PrivacyController extends GetxController {
final state = PrivacyState(); final state = PrivacyState();
final webViewController = WebViewController()
..setNavigationDelegate(NavigationDelegate(
onProgress: (int progress) {
// Update loading bar.
},
onPageStarted: (String url) {},
onPageFinished: (String url) {},
onWebResourceError: (WebResourceError error) {},
// onNavigationRequest: (NavigationRequest request) {
// if (request.url.startsWith('https://www.youtube.com/')) {
// return NavigationDecision.prevent;
// }
// return NavigationDecision.navigate;
// },
));
// tap // tap
void handleTap(int index) { void handleTap(int index) {
Get.snackbar( Get.snackbar(
...@@ -24,6 +40,7 @@ class PrivacyController extends GetxController { ...@@ -24,6 +40,7 @@ class PrivacyController extends GetxController {
/// 在 onInit() 之后调用 1 帧。这是进入的理想场所 /// 在 onInit() 之后调用 1 帧。这是进入的理想场所
@override @override
void onReady() { void onReady() {
webViewController.loadRequest(Uri.parse('https://p.kdocs.cn/s/YXFCYBAAYQ'));
super.onReady(); super.onReady();
} }
......
...@@ -75,9 +75,10 @@ class PrivacyPage extends GetView<PrivacyController> { ...@@ -75,9 +75,10 @@ class PrivacyPage extends GetView<PrivacyController> {
body: Container( body: Container(
height: double.infinity, height: double.infinity,
width: double.infinity, width: double.infinity,
child: WebView( child: WebViewWidget(controller: controller.webViewController),
initialUrl: "https://p.kdocs.cn/s/YXFCYBAAYQ", // child: WebViewWidget(
), // initialUrl: "https://p.kdocs.cn/s/YXFCYBAAYQ",
// ),
// 【金山文档】 隐私政策 // 【金山文档】 隐私政策
// decoration: BoxDecoration( // decoration: BoxDecoration(
......
...@@ -571,6 +571,13 @@ packages: ...@@ -571,6 +571,13 @@ packages:
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "2.2.1" version: "2.2.1"
flutter_persistent_keyboard_height:
dependency: "direct main"
description:
name: flutter_persistent_keyboard_height
url: "https://pub.dartlang.org"
source: hosted
version: "1.0.5"
flutter_plugin_android_lifecycle: flutter_plugin_android_lifecycle:
dependency: transitive dependency: transitive
description: description:
...@@ -812,6 +819,13 @@ packages: ...@@ -812,6 +819,13 @@ packages:
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "1.0.0" version: "1.0.0"
keyboard_utils:
dependency: transitive
description:
name: keyboard_utils
url: "https://pub.dartlang.org"
source: hosted
version: "1.3.4"
linkify: linkify:
dependency: transitive dependency: transitive
description: description:
...@@ -1418,28 +1432,28 @@ packages: ...@@ -1418,28 +1432,28 @@ packages:
name: webview_flutter name: webview_flutter
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "3.0.4" version: "4.0.7"
webview_flutter_android: webview_flutter_android:
dependency: transitive dependency: transitive
description: description:
name: webview_flutter_android name: webview_flutter_android
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "2.10.4" version: "3.4.5"
webview_flutter_platform_interface: webview_flutter_platform_interface:
dependency: transitive dependency: transitive
description: description:
name: webview_flutter_platform_interface name: webview_flutter_platform_interface
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "1.9.5" version: "2.1.0"
webview_flutter_wkwebview: webview_flutter_wkwebview:
dependency: transitive dependency: transitive
description: description:
name: webview_flutter_wkwebview name: webview_flutter_wkwebview
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "2.9.5" version: "3.2.4"
win32: win32:
dependency: transitive dependency: transitive
description: description:
......
...@@ -49,7 +49,7 @@ dependencies: ...@@ -49,7 +49,7 @@ dependencies:
dio: ^4.0.6 dio: ^4.0.6
fluro: ^2.0.3 fluro: ^2.0.3
shared_preferences: ^2.0.15 shared_preferences: ^2.0.15
webview_flutter: ^3.0.4 webview_flutter: ^4.0.7
provider: ^6.0.3 provider: ^6.0.3
flutter_screenutil: ^5.5.3+2 flutter_screenutil: ^5.5.3+2
flutter_login: ^3.2.0 flutter_login: ^3.2.0
...@@ -126,6 +126,8 @@ dependencies: ...@@ -126,6 +126,8 @@ dependencies:
flutter_tts: ^3.6.3 flutter_tts: ^3.6.3
custom_pop_up_menu: ^1.2.4 custom_pop_up_menu: ^1.2.4
speech_to_text: ^6.1.1 speech_to_text: ^6.1.1
flutter_persistent_keyboard_height: ^1.0.5
# package:bubble/bubble.dart # package:bubble/bubble.dart
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment