Skip to content

Commit

Permalink
fix Textfield not visible on mobile when typing
Browse files Browse the repository at this point in the history
  • Loading branch information
kodjodevf committed Jan 9, 2025
1 parent 76617e2 commit 22cbf2d
Showing 1 changed file with 161 additions and 122 deletions.
283 changes: 161 additions & 122 deletions lib/modules/manga/detail/widgets/tracker_search_widget.dart
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
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';
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';

Expand All @@ -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;
Expand All @@ -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!),
),
),
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),
),
],
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!),
),
Row(
children: [
const Text(
"Status : ",
style: TextStyle(
fontWeight: FontWeight.bold,
fontSize: 12),
),
Text(
tracks![index]
.publishingStatus!,
),
const SizedBox(
width: 10,
),
Column(
crossAxisAlignment:
CrossAxisAlignment.start,
children: [
SizedBox(
width: context.width(0.6),
child: Text(
tracks![index].title!,
style: const TextStyle(
fontSize: 12),
fontWeight:
FontWeight.bold),
),
],
),
],
)
],
),
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),
),
],
),
],
)
],
),
Text(
tracks![index].summary!,
style: const TextStyle(
fontSize: 12,
overflow: TextOverflow.ellipsis,
),
maxLines: 3,
),
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) {
Expand All @@ -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;
});
}
},
Expand Down Expand Up @@ -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(
Expand All @@ -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,
),
],
),
),
),
),
);
}

1 comment on commit 22cbf2d

@NBA2K1
Copy link
Contributor

@NBA2K1 NBA2K1 commented on 22cbf2d Jan 10, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did my fix not work (#345)?
Sry, but this looks bad. And the textfield rises on Desktop, too.

Please sign in to comment.