Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
C
ChatGPT
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Labels
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Jobs
Commits
Open sidebar
关振斌
ChatGPT
Commits
764aaf37
Commit
764aaf37
authored
Apr 11, 2023
by
skeyboy
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
语音播放动画
parent
02675894
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
147 additions
and
1 deletion
+147
-1
assets/images/left_voice_1.png
assets/images/left_voice_1.png
+0
-0
assets/images/left_voice_2.png
assets/images/left_voice_2.png
+0
-0
assets/images/left_voice_3.png
assets/images/left_voice_3.png
+0
-0
lib/package/chat_dash/src/widgets/message_row/default_message_text.dart
...at_dash/src/widgets/message_row/default_message_text.dart
+1
-1
lib/package/chat_dash/src/widgets/voice_image_animation/voice_image_animation.dart
.../widgets/voice_image_animation/voice_image_animation.dart
+146
-0
No files found.
assets/images/left_voice_1.png
0 → 100755
View file @
764aaf37
730 Bytes
assets/images/left_voice_2.png
0 → 100755
View file @
764aaf37
1.34 KB
assets/images/left_voice_3.png
0 → 100755
View file @
764aaf37
2.17 KB
lib/package/chat_dash/src/widgets/message_row/default_message_text.dart
View file @
764aaf37
...
@@ -64,7 +64,7 @@ class _DefaultMessageTextState extends State<DefaultMessageText> {
...
@@ -64,7 +64,7 @@ class _DefaultMessageTextState extends State<DefaultMessageText> {
controller:
controller
,
controller:
controller
,
menuBuilder:
()
=>
_buildLongPressMenu
(
widget
.
message
),
menuBuilder:
()
=>
_buildLongPressMenu
(
widget
.
message
),
barrierColor:
Colors
.
transparent
,
barrierColor:
Colors
.
transparent
,
position:
PreferredPosition
.
bottom
,
//
position: PreferredPosition.bottom,
pressType:
PressType
.
longPress
,
pressType:
PressType
.
longPress
,
child:
Column
(
child:
Column
(
crossAxisAlignment:
widget
.
isOwnMessage
crossAxisAlignment:
widget
.
isOwnMessage
...
...
lib/package/chat_dash/src/widgets/voice_image_animation/voice_image_animation.dart
0 → 100644
View file @
764aaf37
import
'package:flutter/material.dart'
;
/**
GestureDetector(
onTap: () {
voiceImageAnimationController.reverse();
},
child: VoiceImageAnimation(
assetList: [
"images/left_voice_1.png",
"images/left_voice_2.png",
"images/left_voice_3.png"
],
controller: voiceImageAnimationController,
width: 100,
height: 100),
),
*/
class
VoiceImageAnimationController
extends
ChangeNotifier
{
bool
isPlaying
=
false
;
void
reverse
()
{
isPlaying
=
!
isPlaying
;
notifyListeners
();
}
void
startAnimation
()
{
isPlaying
=
true
;
notifyListeners
();
}
void
endAnimation
()
{
isPlaying
=
false
;
notifyListeners
();
}
}
class
VoiceImageAnimation
extends
StatefulWidget
{
List
<
String
>
assetList
;
int
interval
=
200
;
double
width
,
height
;
VoiceImageAnimationController
?
controller
;
VoiceImageAnimation
(
{
Key
?
key
,
required
this
.
assetList
,
required
this
.
controller
,
required
this
.
width
,
required
this
.
height
})
:
super
(
key:
key
);
@override
State
<
VoiceImageAnimation
>
createState
()
=>
_VoiceImageAnimationState
();
}
class
_VoiceImageAnimationState
extends
State
<
VoiceImageAnimation
>
with
SingleTickerProviderStateMixin
{
bool
isPlaying
=
false
;
// 动画控制
late
Animation
<
double
>
_animation
;
late
AnimationController
_controller
;
int
interval
=
200
;
List
<
Widget
>
images
=
[];
@override
void
initState
()
{
// TODO: implement initState
for
(
int
index
=
0
;
index
<
widget
.
assetList
.
length
;
index
++)
{
images
.
add
(
Image
.
asset
(
widget
.
assetList
[
index
],
width:
widget
.
width
,
height:
widget
.
height
,
));
}
final
int
imageCount
=
widget
.
assetList
.
length
;
final
int
maxTime
=
interval
*
imageCount
;
_controller
=
AnimationController
(
duration:
Duration
(
milliseconds:
maxTime
),
vsync:
this
);
_controller
.
addStatusListener
((
status
)
{
if
(
status
==
AnimationStatus
.
completed
)
{
_controller
.
forward
(
from:
0.0
);
}
});
_animation
=
Tween
<
double
>(
begin:
0.0
,
end:
imageCount
.
toDouble
())
.
animate
(
_controller
)
..
addListener
(()
{
setState
(()
{});
});
WidgetsBinding
.
instance
.
addPostFrameCallback
((
timeStamp
)
{
if
(
mounted
)
{
widget
.
controller
??=
VoiceImageAnimationController
();
widget
.
controller
?.
addListener
(()
{
setState
(()
{});
});
_controller
.
forward
();
}
});
super
.
initState
();
}
@override
void
dispose
()
{
// TODO: implement dispose
widget
.
controller
?.
dispose
();
_controller
.
dispose
();
super
.
dispose
();
}
@override
Widget
build
(
BuildContext
context
)
{
if
((
widget
.
controller
?.
isPlaying
??
false
)
==
false
)
{
return
Stack
(
alignment:
Alignment
.
center
,
children:
[
Image
.
asset
(
widget
.
assetList
[
2
],
width:
widget
.
width
,
height:
widget
.
height
,
)
]);
}
else
{
int
ix
=
_animation
.
value
.
floor
()
%
widget
.
assetList
.
length
;
List
<
Widget
>
images
=
[];
// 把所有图片都加载进内容,否则每一帧加载时会卡顿
for
(
int
i
=
0
;
i
<
widget
.
assetList
.
length
;
++
i
)
{
if
(
i
!=
ix
)
{
images
.
add
(
Image
.
asset
(
widget
.
assetList
[
i
],
width:
0
,
height:
0
,
));
}
}
images
.
add
(
Image
.
asset
(
widget
.
assetList
[
ix
],
width:
widget
.
width
,
height:
widget
.
height
,
));
return
Stack
(
alignment:
Alignment
.
center
,
children:
images
,
);
}
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment