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),
),
const SizedBox(width: 10),
SizedBox(
height: 148,
child: Expanded(
Expanded(
child: SizedBox(
height: 148,
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [

View File

@ -40,11 +40,6 @@ class VideoCardH extends StatelessWidget {
longPressEnd!();
}
},
// 双击 稍后再看
onDoubleTap: () async {
var res = await UserHttp.toViewLater(bvid: videoItem.bvid);
SmartDialog.showToast(res['msg']);
},
child: InkWell(
onTap: () async {
try {
@ -185,7 +180,6 @@ class VideoContent extends StatelessWidget {
),
],
),
const SizedBox(height: 3),
Row(
children: [
StatView(
@ -203,6 +197,27 @@ class VideoContent extends StatelessWidget {
// fontSize: 11,
// 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!();
}
},
// 双击 稍后再看
onDoubleTap: () async {
var res = await UserHttp.toViewLater(bvid: videoItem.bvid);
SmartDialog.showToast(res['msg']);
},
child: InkWell(
onTap: () async {
String bvid = videoItem.bvid ?? IdUtils.av2bv(videoItem.aid);
@ -119,7 +114,7 @@ class VideoContent extends StatelessWidget {
return Expanded(
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),
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(

View File

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

View File

@ -60,29 +60,26 @@ class _SearchPageState extends State<SearchPage> with RouteAware {
),
const SizedBox(width: 10)
],
title: Hero(
tag: 'searchWrap',
child: Obx(
() => TextField(
autofocus: true,
focusNode: _searchController.searchFocusNode,
controller: _searchController.controller.value,
textInputAction: TextInputAction.search,
onChanged: (value) => _searchController.onChange(value),
decoration: InputDecoration(
hintText: _searchController.hintText,
border: InputBorder.none,
suffixIcon: IconButton(
icon: Icon(
Icons.clear,
size: 22,
color: Theme.of(context).colorScheme.outline,
),
onPressed: () => _searchController.onClear(),
title: Obx(
() => TextField(
autofocus: true,
focusNode: _searchController.searchFocusNode,
controller: _searchController.controller.value,
textInputAction: TextInputAction.search,
onChanged: (value) => _searchController.onChange(value),
decoration: InputDecoration(
hintText: _searchController.hintText,
border: InputBorder.none,
suffixIcon: IconButton(
icon: Icon(
Icons.clear,
size: 22,
color: Theme.of(context).colorScheme.outline,
),
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(
height: MediaQuery.of(context).padding.bottom);
} else {
return VideoCardH(
videoItem: snapshot.data['data'][index],
longPress: () {
ReleatedController().popupDialog =
_createPopupDialog(snapshot.data['data'][index]);
Overlay.of(context)
.insert(ReleatedController().popupDialog!);
},
longPressEnd: () {
ReleatedController().popupDialog?.remove();
},
return Material(
child: VideoCardH(
videoItem: snapshot.data['data'][index],
longPress: () {
try {
ReleatedController().popupDialog =
_createPopupDialog(
snapshot.data['data'][index]);
Overlay.of(context)
.insert(ReleatedController().popupDialog!);
} catch (_) {
return {};
}
},
longPressEnd: () {
ReleatedController().popupDialog?.remove();
},
),
);
}
}, childCount: snapshot.data['data'].length + 1));