-
Notifications
You must be signed in to change notification settings - Fork 0
Feat/add player settings buttons 9885815689951910001 #247
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
c586175
49fea21
b73e042
0701b0f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -131,6 +131,60 @@ mixin TimeBatteryMixin<T extends StatefulWidget> on State<T> { | |
| ); | ||
| } | ||
|
|
||
| /// 选择字幕 | ||
| void showSelectSubtitle() { | ||
| showBottomSheet( | ||
| (context, setState) { | ||
| final theme = Theme.of(context); | ||
| return Padding( | ||
| padding: const EdgeInsets.all(12), | ||
| child: Material( | ||
| clipBehavior: Clip.hardEdge, | ||
| color: theme.colorScheme.surface, | ||
| borderRadius: const BorderRadius.all(Radius.circular(12)), | ||
| child: CustomScrollView( | ||
| slivers: [ | ||
| const SliverToBoxAdapter( | ||
| child: SizedBox( | ||
| height: 45, | ||
| child: Center( | ||
| child: Text('选择字幕', style: titleStyle), | ||
| ), | ||
| ), | ||
| ), | ||
| SliverList.builder( | ||
| itemCount: videoDetailCtr.subtitles.length + 1, | ||
| itemBuilder: (context, index) { | ||
| final bool isCurrent = videoDetailCtr.subtitle.value == index; | ||
| return ListTile( | ||
| dense: true, | ||
| onTap: () { | ||
| Get.back(); | ||
| videoDetailCtr.setSubtitle(index); | ||
| }, | ||
| contentPadding: const EdgeInsets.symmetric( | ||
| horizontal: 20, | ||
| ), | ||
| title: Text(index == 0 | ||
| ? '关闭' | ||
| : videoDetailCtr.subtitles[index - 1].lanDoc!), | ||
| trailing: isCurrent | ||
| ? Icon( | ||
| Icons.done, | ||
| color: theme.colorScheme.primary, | ||
| ) | ||
| : null, | ||
| ); | ||
| }, | ||
| ), | ||
| ], | ||
| ), | ||
| ), | ||
| ); | ||
| }, | ||
| ); | ||
| } | ||
|
|
||
| List<Widget>? get timeBatteryWidgets { | ||
| if (_showCurrTime) { | ||
| return [ | ||
|
|
@@ -1321,6 +1375,23 @@ class HeaderControlState extends State<HeaderControl> | |
| secondary: const Icon(Icons.comment_outlined, size: 20), | ||
| title: const Text('弹幕', style: titleStyle), | ||
| ), | ||
| ListTile( | ||
| dense: true, | ||
| onTap: () { | ||
| Get.back(); | ||
| showSelectSubtitle(); | ||
| }, | ||
| leading: const Icon(Icons.subtitles_outlined, size: 20), | ||
| title: const Text('字幕', style: titleStyle), | ||
| ), | ||
| SwitchListTile( | ||
| value: videoDetailCtr.vttSubtitlesIndex.value > 0, | ||
| onChanged: (value) { | ||
| videoDetailCtr.setSubtitle(value ? 1 : 0); | ||
|
||
| }, | ||
| secondary: const Icon(Icons.subtitles_outlined, size: 20), | ||
| title: const Text('开启字幕', style: titleStyle), | ||
| ), | ||
|
Comment on lines
+1378
to
+1394
|
||
| ListTile( | ||
| dense: true, | ||
| onTap: () { | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Potential null pointer exception when accessing lanDoc property. If videoDetailCtr.subtitles[index - 1].lanDoc is null, the null assertion operator (!) will cause a runtime exception. Consider using null-aware operators or providing a fallback value to handle cases where lanDoc might be null.