Browse Source

优化新手指引

newdev_shunjiawei
tanlongsheng 1 year ago
parent
commit
849eda28d9
  1. 107
      lib/core/widgets/intro_overlay_builder.dart
  2. 244
      lib/modules/agent/views/agent_view.dart
  3. 8
      lib/modules/home/views/home_view.dart

107
lib/core/widgets/intro_overlay_builder.dart

@ -73,13 +73,16 @@ class IntroOverlayBuilder {
bool alignment = true, bool alignment = true,
Function? onNext, Function? onNext,
Function? onFinish, Function? onFinish,
Function? onTap,
}) { }) {
double height = double dy = params.offset?.dy ?? 0;
(params.offset?.dy ?? 0) - ScreenUtil().statusBarHeight - 20.w; double width = params.size.width;
double height = params.size.height;
double totalHeight = dy + height + 3 - ScreenUtil().statusBarHeight;
double left = params.offset?.dx ?? 0; double left = params.offset?.dx ?? 0;
double right = 1.sw - left - params.size.width; double right = 1.sw - left - width;
return SizedBox( return SizedBox(
height: height, height: totalHeight,
child: Column( child: Column(
mainAxisAlignment: MainAxisAlignment.spaceBetween, mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [ children: [
@ -96,15 +99,15 @@ class IntroOverlayBuilder {
), ),
Padding( Padding(
padding: EdgeInsets.only( padding: EdgeInsets.only(
left: alignment ? left : 12.w, left: alignment ? left - 3 : 12.w - 3,
right: alignment ? 12.w : right, right: alignment ? 12.w - 3 : right - 3,
), ),
child: Column( child: Column(
crossAxisAlignment: crossAxisAlignment:
alignment ? CrossAxisAlignment.start : CrossAxisAlignment.end, alignment ? CrossAxisAlignment.start : CrossAxisAlignment.end,
children: [ children: [
Padding( Padding(
padding: EdgeInsets.only(bottom: 10.w), padding: const EdgeInsets.symmetric(horizontal: 3),
child: Text( child: Text(
text, text,
style: TextStyle( style: TextStyle(
@ -117,23 +120,51 @@ class IntroOverlayBuilder {
Row( Row(
children: [ children: [
if (onNext != null) if (onNext != null)
_button( Padding(
buttonText, padding: EdgeInsets.only(top: 10.w, left: 3, right: 3),
() { child: _button(
params.onNext!(); buttonText,
onNext(); () {
}, params.onNext!();
onNext();
},
),
), ),
if (onFinish != null) if (onFinish != null)
_button( Padding(
buttonText, padding: EdgeInsets.only(top: 10.w, left: 3, right: 3),
() { child: _button(
params.onFinish(); buttonText,
onFinish(); () {
}, params.onFinish();
onFinish();
},
),
), ),
], ],
), ),
SizedBox(height: 20.w),
onTap != null
? _AnimatedBorderButton(
onTap: () {
onTap();
},
isButton: false,
child: Padding(
padding: const EdgeInsetsGeometry.all(3),
child: SizedBox(
width: width,
height: height,
),
),
)
: Padding(
padding: const EdgeInsetsGeometry.all(3),
child: SizedBox(
width: width,
height: height,
),
),
], ],
), ),
), ),
@ -162,8 +193,21 @@ class IntroOverlayBuilder {
), ),
) )
: _AnimatedBorderButton( : _AnimatedBorderButton(
text: text,
onTap: onTap, onTap: onTap,
child: Container(
padding: EdgeInsets.symmetric(horizontal: 15.w, vertical: 5.w),
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(20.r),
border: Border.all(color: Colors.transparent),
),
child: Text(
text,
style: TextStyle(
fontSize: 14.sp,
color: Colors.white,
),
),
),
); );
} }
} }
@ -228,12 +272,14 @@ class _AnimatedLottieWidgetState extends State<_AnimatedLottieWidget>
// 新增的带边框流动动画的按钮组件 // 新增的带边框流动动画的按钮组件
class _AnimatedBorderButton extends StatefulWidget { class _AnimatedBorderButton extends StatefulWidget {
final String text; final Widget child;
final bool isButton;
final Function() onTap; final Function() onTap;
const _AnimatedBorderButton({ const _AnimatedBorderButton({
required this.text, required this.child,
required this.onTap, required this.onTap,
this.isButton = true,
}); });
@override @override
@ -276,22 +322,9 @@ class _AnimatedBorderButtonState extends State<_AnimatedBorderButton>
return CustomPaint( return CustomPaint(
painter: _FlowingBorderPainter( painter: _FlowingBorderPainter(
progress: _animation.value, progress: _animation.value,
borderRadius: 20.r, borderRadius: widget.isButton ? 20.r : 0.r,
),
child: Container(
padding: EdgeInsets.symmetric(horizontal: 15.w, vertical: 5.w),
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(20.r),
border: Border.all(color: Colors.transparent),
),
child: Text(
widget.text,
style: TextStyle(
fontSize: 14.sp,
color: Colors.white,
),
),
), ),
child: widget.child,
); );
}, },
), ),

244
lib/modules/agent/views/agent_view.dart

@ -742,151 +742,143 @@ class _AgentViewState extends State<AgentView> with WidgetsBindingObserver {
SizedBox(width: 8.w), SizedBox(width: 8.w),
// 动态按钮区域:展开按钮 + 发送按钮 或 图片选择按钮 // 动态按钮区域:展开按钮 + 发送按钮 或 图片选择按钮
Builder(builder: (context) { IntroStepBuilder(
StepWidgetParams? widgetParams; group: 'ai',
return IntroStepBuilder( order: 2,
group: 'ai', getOverlayPosition:
order: 2, IntroOverlayBuilder.overlayPosition,
onHighlightWidgetTap: () async { overlayBuilder: (params) {
await controller return IntroOverlayBuilder.aiBuilder(
.noviceGuideService.aiStepsList[ params,
controller.noviceGuideService.aiStep] '点击发送,${controller.noviceGuideService.aiStepsList[controller.noviceGuideService.aiStep]['send']}',
['method'](); alignment: false,
widgetParams!.onNext!(); onTap: () async {
controller.sendMessage(); await controller
}, .noviceGuideService.aiStepsList[
getOverlayPosition: controller.noviceGuideService
IntroOverlayBuilder.overlayPosition, .aiStep]['method']();
overlayBuilder: (params) { params.onNext!();
widgetParams = params; controller.sendMessage();
return IntroOverlayBuilder.aiBuilder( },
params, );
'点击发送,${controller.noviceGuideService.aiStepsList[controller.noviceGuideService.aiStep]['send']}', },
alignment: false, builder: (BuildContext context, GlobalKey key) =>
); Obx(
}, key: key,
builder: () {
(BuildContext context, GlobalKey key) => final hasText = controller.hasTextInput.value;
Obx( final hasImage =
key: key, controller.isImageInputActive.value;
() { final shouldShowSend = hasText || hasImage;
final hasText = final shouldShowExpand =
controller.hasTextInput.value; controller.shouldShowExpandButton.value;
final hasImage =
controller.isImageInputActive.value;
final shouldShowSend = hasText || hasImage;
final shouldShowExpand =
controller.shouldShowExpandButton.value;
if (shouldShowSend) { if (shouldShowSend) {
// 显示发送按钮(可能还有展开按钮) // 显示发送按钮(可能还有展开按钮)
return Column( return Column(
children: [ children: [
// 展开按钮(在发送按钮上方) // 展开按钮(在发送按钮上方)
if (shouldShowExpand && hasText) if (shouldShowExpand && hasText)
Padding( Padding(
padding: padding:
EdgeInsets.only(bottom: 40.h), EdgeInsets.only(bottom: 40.h),
child: GestureDetector( child: GestureDetector(
onTap: () { onTap: () {
// 打开底部弹出编辑模式 // 打开底部弹出编辑模式
controller.openFullScreenEdit();
showModalBottomSheet(
context: context,
isScrollControlled: true,
backgroundColor:
Colors.transparent,
builder: (context) =>
const FullScreenEditor(),
).then((_) {
// 弹出页关闭时的回调
controller controller
.openFullScreenEdit(); .closeFullScreenEdit();
showModalBottomSheet( });
context: context, },
isScrollControlled: true, child: Container(
backgroundColor: width: 32.w,
Colors.transparent, height: 32.w,
builder: (context) => decoration: BoxDecoration(
const FullScreenEditor(), color: isDarkMode
).then((_) { ? Colors.grey[700]
// 弹出页关闭时的回调 : Colors.grey[300],
controller borderRadius:
.closeFullScreenEdit(); BorderRadius.circular(
}); 16.w),
}, ),
child: Container( child: Icon(
width: 32.w, Icons.expand_less,
height: 32.w, color: isDarkMode
decoration: BoxDecoration( ? Colors.grey[300]
color: isDarkMode : Colors.grey[700],
? Colors.grey[700] size: 20.sp,
: Colors.grey[300],
borderRadius:
BorderRadius.circular(
16.w),
),
child: Icon(
Icons.expand_less,
color: isDarkMode
? Colors.grey[300]
: Colors.grey[700],
size: 20.sp,
),
), ),
),
),
// 发送按钮
GestureDetector(
onTap: () =>
controller.sendMessage(),
child: Container(
width: 44.w,
height: 44.w,
margin: EdgeInsets.symmetric(
vertical: 2.w),
decoration: BoxDecoration(
color: primaryColor,
borderRadius:
BorderRadius.circular(22.w),
),
child: Icon(
Icons.send,
color: Colors.white,
size: 22.sp,
), ),
), ),
), ),
], // 发送按钮
); GestureDetector(
} else { onTap: () => controller.sendMessage(),
// 显示'+'选择按钮
return Obx(() {
final isExpanded = controller
.isPlusOptionsExpanded.value;
return GestureDetector(
onTap: () {
controller.togglePlusOptions();
},
child: Container( child: Container(
width: 44.w, width: 44.w,
height: 44.w, height: 44.w,
margin: EdgeInsets.symmetric( margin: EdgeInsets.symmetric(
vertical: 2.w), vertical: 2.w),
decoration: BoxDecoration( decoration: BoxDecoration(
color: isDarkMode color: primaryColor,
? Colors.grey[800]
: Colors.grey[200],
borderRadius: borderRadius:
BorderRadius.circular(22.w), BorderRadius.circular(22.w),
), ),
child: Icon( child: Icon(
isExpanded Icons.send,
? Icons.close color: Colors.white,
: Icons.add,
color: isDarkMode
? Colors.grey[300]
: Colors.grey[700],
size: 22.sp, size: 22.sp,
), ),
), ),
); ),
}); ],
} );
}, } else {
), // 显示'+'选择按钮
); return Obx(() {
}), final isExpanded = controller
.isPlusOptionsExpanded.value;
return GestureDetector(
onTap: () {
controller.togglePlusOptions();
},
child: Container(
width: 44.w,
height: 44.w,
margin: EdgeInsets.symmetric(
vertical: 2.w),
decoration: BoxDecoration(
color: isDarkMode
? Colors.grey[800]
: Colors.grey[200],
borderRadius:
BorderRadius.circular(22.w),
),
child: Icon(
isExpanded
? Icons.close
: Icons.add,
color: isDarkMode
? Colors.grey[300]
: Colors.grey[700],
size: 22.sp,
),
),
);
});
}
},
),
),
], ],
), ),

8
lib/modules/home/views/home_view.dart

@ -740,15 +740,15 @@ class HomeView extends GetView<HomeController> {
child: IntroStepBuilder( child: IntroStepBuilder(
group: 'home', group: 'home',
order: 3, order: 3,
onHighlightWidgetTap: () {
Intro.of(Get.context!).dispose();
controller.exploreAIFeatures();
},
getOverlayPosition: IntroOverlayBuilder.overlayPosition, getOverlayPosition: IntroOverlayBuilder.overlayPosition,
overlayBuilder: (params) { overlayBuilder: (params) {
return IntroOverlayBuilder.aiBuilder( return IntroOverlayBuilder.aiBuilder(
params, params,
'太棒了!你已成功唤醒小言,接下来试试让它帮你做件事吧', '太棒了!你已成功唤醒小言,接下来试试让它帮你做件事吧',
onTap: () {
params.onFinish();
controller.exploreAIFeatures();
},
); );
}, },
builder: (BuildContext context, GlobalKey key) => SizedBox( builder: (BuildContext context, GlobalKey key) => SizedBox(

Loading…
Cancel
Save