fix: 搜索框自动focus失效、修改稍后再看触发逻辑、推荐视频长按动画

This commit is contained in:
guozhigq
2023-08-06 22:36:58 +08:00
parent 90bb2a5270
commit d059a439fb
6 changed files with 117 additions and 87 deletions

View File

@ -28,9 +28,9 @@ class _MediaBangumiSkeletonState extends State<MediaBangumiSkeleton> {
color: bgColor), color: bgColor),
), ),
const SizedBox(width: 10), const SizedBox(width: 10),
SizedBox( Expanded(
height: 148, child: SizedBox(
child: Expanded( height: 148,
child: Column( child: Column(
crossAxisAlignment: CrossAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start,
children: [ children: [

View File

@ -40,11 +40,6 @@ class VideoCardH extends StatelessWidget {
longPressEnd!(); longPressEnd!();
} }
}, },
// 双击 稍后再看
onDoubleTap: () async {
var res = await UserHttp.toViewLater(bvid: videoItem.bvid);
SmartDialog.showToast(res['msg']);
},
child: InkWell( child: InkWell(
onTap: () async { onTap: () async {
try { try {
@ -185,7 +180,6 @@ class VideoContent extends StatelessWidget {
), ),
], ],
), ),
const SizedBox(height: 3),
Row( Row(
children: [ children: [
StatView( StatView(
@ -203,6 +197,27 @@ class VideoContent extends StatelessWidget {
// fontSize: 11, // fontSize: 11,
// color: Theme.of(context).colorScheme.outline), // color: Theme.of(context).colorScheme.outline),
// ) // )
const Spacer(),
SizedBox(
width: 20,
height: 20,
child: IconButton(
tooltip: '稍后再看',
style: ButtonStyle(
padding: MaterialStateProperty.all(EdgeInsets.zero),
),
onPressed: () async {
var res =
await UserHttp.toViewLater(bvid: videoItem.bvid);
SmartDialog.showToast(res['msg']);
},
icon: Icon(
Icons.more_vert_outlined,
color: Theme.of(context).colorScheme.outline,
size: 14,
),
),
),
], ],
), ),
], ],

View File

@ -45,11 +45,6 @@ class VideoCardV extends StatelessWidget {
longPressEnd!(); longPressEnd!();
} }
}, },
// 双击 稍后再看
onDoubleTap: () async {
var res = await UserHttp.toViewLater(bvid: videoItem.bvid);
SmartDialog.showToast(res['msg']);
},
child: InkWell( child: InkWell(
onTap: () async { onTap: () async {
String bvid = videoItem.bvid ?? IdUtils.av2bv(videoItem.aid); String bvid = videoItem.bvid ?? IdUtils.av2bv(videoItem.aid);
@ -119,7 +114,7 @@ class VideoContent extends StatelessWidget {
return Expanded( return Expanded(
child: Padding( child: Padding(
// 多列 // 多列
padding: const EdgeInsets.fromLTRB(4, 5, 6, 6), padding: const EdgeInsets.fromLTRB(4, 5, 0, 3),
// 单列 // 单列
// padding: const EdgeInsets.fromLTRB(14, 10, 4, 8), // padding: const EdgeInsets.fromLTRB(14, 10, 4, 8),
child: Column( child: Column(
@ -185,6 +180,26 @@ class VideoContent extends StatelessWidget {
); );
}), }),
), ),
SizedBox(
width: 20,
height: 20,
child: IconButton(
tooltip: '稍后再看',
style: ButtonStyle(
padding: MaterialStateProperty.all(EdgeInsets.zero),
),
onPressed: () async {
var res =
await UserHttp.toViewLater(bvid: videoItem.bvid);
SmartDialog.showToast(res['msg']);
},
icon: Icon(
Icons.more_vert_outlined,
color: Theme.of(context).colorScheme.outline,
size: 14,
),
),
),
], ],
), ),
// Row( // Row(

View File

@ -165,49 +165,45 @@ class CustomAppBar extends StatelessWidget implements PreferredSizeWidget {
), ),
const SizedBox(width: 10), const SizedBox(width: 10),
Expanded( Expanded(
child: Hero( child: GestureDetector(
tag: 'searchWrap', onTap: () {
child: GestureDetector( Get.toNamed('/search', parameters: {
onTap: () { 'hintText': ctr.defaultSearch.value
Get.toNamed('/search', parameters: { });
'hintText': ctr.defaultSearch.value },
}); child: Container(
}, width: 250,
child: Container( height: 45,
width: 250, clipBehavior: Clip.hardEdge,
height: 45, padding: const EdgeInsets.only(left: 12, right: 22),
clipBehavior: Clip.hardEdge, decoration: BoxDecoration(
padding: const EdgeInsets.only(left: 12, right: 22), borderRadius:
decoration: BoxDecoration( const BorderRadius.all(Radius.circular(25)),
borderRadius: color:
const BorderRadius.all(Radius.circular(25)), Theme.of(context).colorScheme.onInverseSurface,
color: Theme.of(context) ),
.colorScheme child: Row(
.onInverseSurface, children: [
), Icon(
child: Row( Icons.search_outlined,
children: [ size: 23,
Icon( color: Theme.of(context).colorScheme.outline,
Icons.search_outlined, ),
size: 23, const SizedBox(width: 7),
color: Theme.of(context).colorScheme.outline, Expanded(
), child: Obx(
const SizedBox(width: 7), () => Text(
Expanded( ctr.defaultSearch.value,
child: Obx( maxLines: 1,
() => Text( overflow: TextOverflow.ellipsis,
ctr.defaultSearch.value, style: TextStyle(
maxLines: 1, color: Theme.of(context)
overflow: TextOverflow.ellipsis, .colorScheme
style: TextStyle( .outline),
color: Theme.of(context)
.colorScheme
.outline),
),
), ),
), ),
], ),
), ],
), ),
), ),
), ),

View File

@ -60,29 +60,26 @@ class _SearchPageState extends State<SearchPage> with RouteAware {
), ),
const SizedBox(width: 10) const SizedBox(width: 10)
], ],
title: Hero( title: Obx(
tag: 'searchWrap', () => TextField(
child: Obx( autofocus: true,
() => TextField( focusNode: _searchController.searchFocusNode,
autofocus: true, controller: _searchController.controller.value,
focusNode: _searchController.searchFocusNode, textInputAction: TextInputAction.search,
controller: _searchController.controller.value, onChanged: (value) => _searchController.onChange(value),
textInputAction: TextInputAction.search, decoration: InputDecoration(
onChanged: (value) => _searchController.onChange(value), hintText: _searchController.hintText,
decoration: InputDecoration( border: InputBorder.none,
hintText: _searchController.hintText, suffixIcon: IconButton(
border: InputBorder.none, icon: Icon(
suffixIcon: IconButton( Icons.clear,
icon: Icon( size: 22,
Icons.clear, color: Theme.of(context).colorScheme.outline,
size: 22,
color: Theme.of(context).colorScheme.outline,
),
onPressed: () => _searchController.onClear(),
), ),
onPressed: () => _searchController.onClear(),
), ),
onSubmitted: (String value) => _searchController.submit(),
), ),
onSubmitted: (String value) => _searchController.submit(),
), ),
), ),
), ),

View File

@ -27,17 +27,24 @@ class RelatedVideoPanel extends GetView<ReleatedController> {
return SizedBox( return SizedBox(
height: MediaQuery.of(context).padding.bottom); height: MediaQuery.of(context).padding.bottom);
} else { } else {
return VideoCardH( return Material(
videoItem: snapshot.data['data'][index], child: VideoCardH(
longPress: () { videoItem: snapshot.data['data'][index],
ReleatedController().popupDialog = longPress: () {
_createPopupDialog(snapshot.data['data'][index]); try {
Overlay.of(context) ReleatedController().popupDialog =
.insert(ReleatedController().popupDialog!); _createPopupDialog(
}, snapshot.data['data'][index]);
longPressEnd: () { Overlay.of(context)
ReleatedController().popupDialog?.remove(); .insert(ReleatedController().popupDialog!);
}, } catch (_) {
return {};
}
},
longPressEnd: () {
ReleatedController().popupDialog?.remove();
},
),
); );
} }
}, childCount: snapshot.data['data'].length + 1)); }, childCount: snapshot.data['data'].length + 1));