fix Textfield not visible on mobile when typing
This commit is contained in:
parent
76617e2fa6
commit
22cbf2dc44
1 changed files with 162 additions and 123 deletions
|
|
@ -1,4 +1,3 @@
|
|||
import 'package:draggable_menu/draggable_menu.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
import 'package:mangayomi/models/manga.dart';
|
||||
|
|
@ -6,6 +5,7 @@ import 'package:mangayomi/models/track.dart';
|
|||
import 'package:mangayomi/models/track_search.dart';
|
||||
import 'package:mangayomi/modules/manga/detail/providers/track_state_providers.dart';
|
||||
import 'package:mangayomi/modules/widgets/custom_extended_image_provider.dart';
|
||||
import 'package:mangayomi/modules/widgets/error_text.dart';
|
||||
import 'package:mangayomi/modules/widgets/progress_center.dart';
|
||||
import 'package:mangayomi/utils/extensions/build_context_extensions.dart';
|
||||
|
||||
|
|
@ -28,13 +28,20 @@ class _TrackerWidgetSearchState extends ConsumerState<TrackerWidgetSearch> {
|
|||
}
|
||||
|
||||
late String query = widget.track.title!.trim();
|
||||
bool hide = false;
|
||||
late List<TrackSearch>? tracks = [];
|
||||
String? _errorMsg;
|
||||
_init() async {
|
||||
await Future.delayed(const Duration(microseconds: 100));
|
||||
tracks = await ref
|
||||
.read(trackStateProvider(track: widget.track, itemType: widget.itemType)
|
||||
.notifier)
|
||||
.search(query);
|
||||
try {
|
||||
tracks = await ref
|
||||
.read(
|
||||
trackStateProvider(track: widget.track, itemType: widget.itemType)
|
||||
.notifier)
|
||||
.search(query);
|
||||
} catch (e) {
|
||||
_errorMsg = e.toString();
|
||||
}
|
||||
if (mounted) {
|
||||
setState(() {
|
||||
_isLoading = false;
|
||||
|
|
@ -52,115 +59,133 @@ class _TrackerWidgetSearchState extends ConsumerState<TrackerWidgetSearch> {
|
|||
bottomLeft: Radius.circular(20), bottomRight: Radius.circular(20)),
|
||||
clipBehavior: Clip.antiAliasWithSaveLayer,
|
||||
child: _isLoading
|
||||
? const ProgressCenter()
|
||||
? SizedBox(
|
||||
height: context.height(0.3),
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(20),
|
||||
child: const ProgressCenter(),
|
||||
),
|
||||
)
|
||||
: Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 10),
|
||||
child: SizedBox(
|
||||
height: context.height(0.8),
|
||||
child: Column(
|
||||
children: [
|
||||
Flexible(
|
||||
child: ListView.separated(
|
||||
padding: const EdgeInsets.only(top: 20),
|
||||
itemCount: tracks!.length,
|
||||
itemBuilder: (context, index) {
|
||||
return Padding(
|
||||
padding: const EdgeInsets.only(top: 5),
|
||||
child: InkWell(
|
||||
onTap: () {
|
||||
Navigator.pop(context, tracks![index]);
|
||||
},
|
||||
child: Column(
|
||||
children: [
|
||||
Row(
|
||||
crossAxisAlignment:
|
||||
CrossAxisAlignment.start,
|
||||
children: [
|
||||
Material(
|
||||
borderRadius: BorderRadius.circular(5),
|
||||
color: Colors.transparent,
|
||||
clipBehavior:
|
||||
Clip.antiAliasWithSaveLayer,
|
||||
child: Ink.image(
|
||||
height: 120,
|
||||
width: 80,
|
||||
fit: BoxFit.cover,
|
||||
image:
|
||||
CustomExtendedNetworkImageProvider(
|
||||
tracks![index].coverUrl!),
|
||||
if (_errorMsg != null) ErrorText(_errorMsg!),
|
||||
if (_errorMsg == null && !hide)
|
||||
Flexible(
|
||||
child: ListView.separated(
|
||||
padding: const EdgeInsets.only(top: 20),
|
||||
itemCount: tracks!.length,
|
||||
itemBuilder: (context, index) {
|
||||
return Padding(
|
||||
padding: const EdgeInsets.only(top: 5),
|
||||
child: InkWell(
|
||||
onTap: () {
|
||||
Navigator.pop(context, tracks![index]);
|
||||
},
|
||||
child: Column(
|
||||
children: [
|
||||
Row(
|
||||
crossAxisAlignment:
|
||||
CrossAxisAlignment.start,
|
||||
children: [
|
||||
Material(
|
||||
borderRadius:
|
||||
BorderRadius.circular(5),
|
||||
color: Colors.transparent,
|
||||
clipBehavior:
|
||||
Clip.antiAliasWithSaveLayer,
|
||||
child: Ink.image(
|
||||
height: 120,
|
||||
width: 80,
|
||||
fit: BoxFit.cover,
|
||||
image:
|
||||
CustomExtendedNetworkImageProvider(
|
||||
tracks![index].coverUrl!),
|
||||
),
|
||||
),
|
||||
),
|
||||
const SizedBox(
|
||||
width: 10,
|
||||
),
|
||||
Column(
|
||||
crossAxisAlignment:
|
||||
CrossAxisAlignment.start,
|
||||
children: [
|
||||
SizedBox(
|
||||
width: context.width(0.6),
|
||||
child: Text(
|
||||
tracks![index].title!,
|
||||
style: const TextStyle(
|
||||
fontWeight: FontWeight.bold),
|
||||
const SizedBox(
|
||||
width: 10,
|
||||
),
|
||||
Column(
|
||||
crossAxisAlignment:
|
||||
CrossAxisAlignment.start,
|
||||
children: [
|
||||
SizedBox(
|
||||
width: context.width(0.6),
|
||||
child: Text(
|
||||
tracks![index].title!,
|
||||
style: const TextStyle(
|
||||
fontWeight:
|
||||
FontWeight.bold),
|
||||
),
|
||||
),
|
||||
),
|
||||
Row(
|
||||
children: [
|
||||
const Text(
|
||||
"Type : ",
|
||||
style: TextStyle(
|
||||
fontWeight: FontWeight.bold,
|
||||
fontSize: 12),
|
||||
),
|
||||
Text(
|
||||
tracks![index].publishingType!,
|
||||
style: const TextStyle(
|
||||
fontSize: 12),
|
||||
),
|
||||
],
|
||||
),
|
||||
Row(
|
||||
children: [
|
||||
const Text(
|
||||
"Status : ",
|
||||
style: TextStyle(
|
||||
fontWeight: FontWeight.bold,
|
||||
fontSize: 12),
|
||||
),
|
||||
Text(
|
||||
tracks![index]
|
||||
.publishingStatus!,
|
||||
style: const TextStyle(
|
||||
fontSize: 12),
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
)
|
||||
],
|
||||
),
|
||||
Text(
|
||||
tracks![index].summary!,
|
||||
style: const TextStyle(
|
||||
fontSize: 12,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
Row(
|
||||
children: [
|
||||
const Text(
|
||||
"Type : ",
|
||||
style: TextStyle(
|
||||
fontWeight:
|
||||
FontWeight.bold,
|
||||
fontSize: 12),
|
||||
),
|
||||
Text(
|
||||
tracks![index]
|
||||
.publishingType!,
|
||||
style: const TextStyle(
|
||||
fontSize: 12),
|
||||
),
|
||||
],
|
||||
),
|
||||
Row(
|
||||
children: [
|
||||
const Text(
|
||||
"Status : ",
|
||||
style: TextStyle(
|
||||
fontWeight:
|
||||
FontWeight.bold,
|
||||
fontSize: 12),
|
||||
),
|
||||
Text(
|
||||
tracks![index]
|
||||
.publishingStatus!,
|
||||
style: const TextStyle(
|
||||
fontSize: 12),
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
)
|
||||
],
|
||||
),
|
||||
maxLines: 3,
|
||||
),
|
||||
],
|
||||
Text(
|
||||
tracks![index].summary!,
|
||||
style: const TextStyle(
|
||||
fontSize: 12,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
),
|
||||
maxLines: 3,
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
separatorBuilder: (BuildContext context, int index) {
|
||||
return const Divider();
|
||||
},
|
||||
);
|
||||
},
|
||||
separatorBuilder: (BuildContext context, int index) {
|
||||
return const Divider();
|
||||
},
|
||||
),
|
||||
),
|
||||
),
|
||||
Padding(
|
||||
padding: const EdgeInsets.symmetric(vertical: 10),
|
||||
child: TextFormField(
|
||||
onTap: () {
|
||||
setState(() {
|
||||
hide = true;
|
||||
});
|
||||
},
|
||||
controller: _controller,
|
||||
keyboardType: TextInputType.text,
|
||||
onChanged: (d) {
|
||||
|
|
@ -171,16 +196,24 @@ class _TrackerWidgetSearchState extends ConsumerState<TrackerWidgetSearch> {
|
|||
onFieldSubmitted: (d) async {
|
||||
setState(() {
|
||||
_isLoading = true;
|
||||
_errorMsg = null;
|
||||
});
|
||||
tracks = await ref
|
||||
.read(trackStateProvider(
|
||||
track: widget.track,
|
||||
itemType: widget.itemType)
|
||||
.notifier)
|
||||
.search(d.trim());
|
||||
try {
|
||||
tracks = await ref
|
||||
.read(trackStateProvider(
|
||||
track: widget.track,
|
||||
itemType: widget.itemType)
|
||||
.notifier)
|
||||
.search(d.trim());
|
||||
} catch (e) {
|
||||
_errorMsg = e.toString();
|
||||
hide = false;
|
||||
}
|
||||
|
||||
if (mounted) {
|
||||
setState(() {
|
||||
_isLoading = false;
|
||||
hide = false;
|
||||
});
|
||||
}
|
||||
},
|
||||
|
|
@ -218,13 +251,18 @@ class _TrackerWidgetSearchState extends ConsumerState<TrackerWidgetSearch> {
|
|||
|
||||
trackersSearchraggableMenu(BuildContext context,
|
||||
{required Track track, required ItemType itemType}) async {
|
||||
return await DraggableMenu.open(
|
||||
context,
|
||||
DraggableMenu(
|
||||
blockMenuClosing: true,
|
||||
ui: ClassicDraggableMenu(
|
||||
radius: 20,
|
||||
barItem: Container(
|
||||
var padding = MediaQuery.of(context).padding;
|
||||
return await showDialog(
|
||||
context: context,
|
||||
builder: (context) => Scaffold(
|
||||
backgroundColor: Colors.transparent,
|
||||
body: SingleChildScrollView(
|
||||
child: SizedBox(
|
||||
height: context.height(1) - padding.top - padding.bottom,
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.end,
|
||||
children: [
|
||||
Container(
|
||||
decoration: BoxDecoration(
|
||||
color: Theme.of(context).scaffoldBackgroundColor,
|
||||
borderRadius: const BorderRadius.only(
|
||||
|
|
@ -245,16 +283,17 @@ trackersSearchraggableMenu(BuildContext context,
|
|||
)
|
||||
],
|
||||
),
|
||||
const Divider()
|
||||
],
|
||||
),
|
||||
)),
|
||||
levels: [
|
||||
DraggableMenuLevel.ratio(ratio: 0.9),
|
||||
],
|
||||
minimizeBeforeFastDrag: true,
|
||||
child: TrackerWidgetSearch(
|
||||
track: track,
|
||||
itemType: itemType,
|
||||
)));
|
||||
),
|
||||
TrackerWidgetSearch(
|
||||
track: track,
|
||||
itemType: itemType,
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue