Skip to content

Commit e1d45ae

Browse files
committed
fix: fixed abrupt background on desktop
1 parent 6c83b85 commit e1d45ae

File tree

3 files changed

+502
-1688
lines changed

3 files changed

+502
-1688
lines changed
Lines changed: 399 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,399 @@
1+
import 'dart:io';
2+
3+
import 'package:anymex/controllers/source/source_controller.dart';
4+
import 'package:dartotsu_extension_bridge/ExtensionManager.dart';
5+
import 'package:flutter/material.dart';
6+
import 'package:get/get.dart';
7+
8+
class RepoBottomSheet extends StatefulWidget {
9+
final Function() onSave;
10+
11+
const RepoBottomSheet({
12+
super.key,
13+
required this.onSave,
14+
});
15+
16+
@override
17+
State<RepoBottomSheet> createState() => _RepoBottomSheetState();
18+
19+
static void show(BuildContext context, {required Function() onSave}) {
20+
showModalBottomSheet(
21+
context: context,
22+
isScrollControlled: true,
23+
backgroundColor: Colors.transparent,
24+
isDismissible: true,
25+
enableDrag: true,
26+
builder: (context) => RepoBottomSheet(onSave: onSave),
27+
);
28+
}
29+
}
30+
31+
class _RepoBottomSheetState extends State<RepoBottomSheet> {
32+
final controller = Get.find<SourceController>();
33+
late final bool isAndroid;
34+
35+
late final TextEditingController animeRepoController;
36+
late final TextEditingController mangaRepoController;
37+
late final TextEditingController novelRepoController;
38+
39+
int selectedTab = 0;
40+
41+
@override
42+
void initState() {
43+
super.initState();
44+
isAndroid = Platform.isAndroid;
45+
46+
final type = isAndroid && selectedTab == 1
47+
? ExtensionType.aniyomi
48+
: ExtensionType.mangayomi;
49+
50+
animeRepoController = TextEditingController(
51+
text: controller.getAnimeRepo(type),
52+
);
53+
mangaRepoController = TextEditingController(
54+
text: controller.getMangaRepo(type),
55+
);
56+
novelRepoController = TextEditingController(
57+
text: controller.activeNovelRepo,
58+
);
59+
}
60+
61+
@override
62+
void dispose() {
63+
animeRepoController.dispose();
64+
mangaRepoController.dispose();
65+
novelRepoController.dispose();
66+
super.dispose();
67+
}
68+
69+
void onTabChanged(int index) {
70+
setState(() {
71+
selectedTab = index;
72+
73+
final type = isAndroid && selectedTab == 1
74+
? ExtensionType.aniyomi
75+
: ExtensionType.mangayomi;
76+
77+
animeRepoController.text = controller.getAnimeRepo(type);
78+
mangaRepoController.text = controller.getMangaRepo(type);
79+
});
80+
}
81+
82+
Future<void> handleSave() async {
83+
final type = isAndroid && selectedTab == 1
84+
? ExtensionType.aniyomi
85+
: ExtensionType.mangayomi;
86+
87+
print('${type.name} - ${animeRepoController.text}');
88+
89+
controller.setAnimeRepo(animeRepoController.text, type);
90+
controller.setMangaRepo(mangaRepoController.text, type);
91+
92+
if (selectedTab == 0) {
93+
controller.activeNovelRepo = novelRepoController.text;
94+
}
95+
96+
Navigator.of(context).pop();
97+
await widget.onSave();
98+
}
99+
100+
@override
101+
Widget build(BuildContext context) {
102+
return Container(
103+
padding: EdgeInsets.only(
104+
bottom: MediaQuery.of(context).viewInsets.bottom,
105+
),
106+
decoration: BoxDecoration(
107+
color: Theme.of(context).colorScheme.surface,
108+
borderRadius: const BorderRadius.vertical(top: Radius.circular(20)),
109+
),
110+
child: SafeArea(
111+
child: Padding(
112+
padding: const EdgeInsets.all(20),
113+
child: Column(
114+
mainAxisSize: MainAxisSize.min,
115+
children: [
116+
Container(
117+
width: 32,
118+
height: 3,
119+
margin: const EdgeInsets.only(bottom: 20),
120+
decoration: BoxDecoration(
121+
color: Theme.of(context).colorScheme.outline.withOpacity(0.3),
122+
borderRadius: BorderRadius.circular(2),
123+
),
124+
),
125+
Text(
126+
"Repository Settings",
127+
style: Theme.of(context).textTheme.headlineSmall?.copyWith(
128+
fontWeight: FontWeight.w600,
129+
),
130+
),
131+
const SizedBox(height: 24),
132+
if (isAndroid)
133+
Container(
134+
decoration: BoxDecoration(
135+
color: Theme.of(context).colorScheme.surfaceContainer,
136+
borderRadius: BorderRadius.circular(12),
137+
),
138+
padding: const EdgeInsets.all(4),
139+
child: Row(
140+
children: [
141+
Expanded(
142+
child: GestureDetector(
143+
onTap: () => onTabChanged(0),
144+
child: Container(
145+
padding: const EdgeInsets.symmetric(vertical: 12),
146+
decoration: BoxDecoration(
147+
color: selectedTab == 0
148+
? Theme.of(context).colorScheme.surface
149+
: Colors.transparent,
150+
borderRadius: BorderRadius.circular(8),
151+
boxShadow: selectedTab == 0
152+
? [
153+
BoxShadow(
154+
color: Colors.black.withOpacity(0.1),
155+
blurRadius: 4,
156+
offset: const Offset(0, 1),
157+
),
158+
]
159+
: null,
160+
),
161+
child: Text(
162+
"Mangayomi",
163+
textAlign: TextAlign.center,
164+
style: TextStyle(
165+
fontWeight: selectedTab == 0
166+
? FontWeight.w600
167+
: FontWeight.w500,
168+
color: selectedTab == 0
169+
? Theme.of(context).colorScheme.onSurface
170+
: Theme.of(context)
171+
.colorScheme
172+
.onSurfaceVariant,
173+
),
174+
),
175+
),
176+
),
177+
),
178+
Expanded(
179+
child: GestureDetector(
180+
onTap: () => onTabChanged(1),
181+
child: Container(
182+
padding: const EdgeInsets.symmetric(vertical: 12),
183+
decoration: BoxDecoration(
184+
color: selectedTab == 1
185+
? Theme.of(context).colorScheme.surface
186+
: Colors.transparent,
187+
borderRadius: BorderRadius.circular(8),
188+
boxShadow: selectedTab == 1
189+
? [
190+
BoxShadow(
191+
color: Colors.black.withOpacity(0.1),
192+
blurRadius: 4,
193+
offset: const Offset(0, 1),
194+
),
195+
]
196+
: null,
197+
),
198+
child: Text(
199+
"Aniyomi",
200+
textAlign: TextAlign.center,
201+
style: TextStyle(
202+
fontWeight: selectedTab == 1
203+
? FontWeight.w600
204+
: FontWeight.w500,
205+
color: selectedTab == 1
206+
? Theme.of(context).colorScheme.onSurface
207+
: Theme.of(context)
208+
.colorScheme
209+
.onSurfaceVariant,
210+
),
211+
),
212+
),
213+
),
214+
),
215+
],
216+
),
217+
),
218+
const SizedBox(height: 24),
219+
Container(
220+
decoration: BoxDecoration(
221+
color: Theme.of(context)
222+
.colorScheme
223+
.errorContainer
224+
.withOpacity(0.3),
225+
borderRadius: BorderRadius.circular(12),
226+
border: Border.all(
227+
color: Theme.of(context).colorScheme.error.withOpacity(0.2),
228+
),
229+
),
230+
padding: const EdgeInsets.all(12),
231+
child: Row(
232+
children: [
233+
Icon(
234+
Icons.info_outline,
235+
color: Theme.of(context).colorScheme.error,
236+
size: 18,
237+
),
238+
const SizedBox(width: 8),
239+
Expanded(
240+
child: Text(
241+
"Third-party repositories are not officially supported",
242+
style: TextStyle(
243+
color: Theme.of(context).colorScheme.onErrorContainer,
244+
fontSize: 12,
245+
),
246+
),
247+
),
248+
],
249+
),
250+
),
251+
const SizedBox(height: 24),
252+
if (selectedTab == 0) ...[
253+
_buildRepoField(
254+
context,
255+
"Anime Repository",
256+
animeRepoController,
257+
Icons.play_circle_outline,
258+
"Enter anime repository URL",
259+
),
260+
const SizedBox(height: 16),
261+
_buildRepoField(
262+
context,
263+
"Manga Repository",
264+
mangaRepoController,
265+
Icons.book_outlined,
266+
"Enter manga repository URL",
267+
),
268+
const SizedBox(height: 16),
269+
_buildRepoField(
270+
context,
271+
"Novel Repository",
272+
novelRepoController,
273+
Icons.menu_book_outlined,
274+
"Enter novel repository URL",
275+
),
276+
] else ...[
277+
_buildRepoField(
278+
context,
279+
"Anime Repository",
280+
animeRepoController,
281+
Icons.play_circle_outline,
282+
"Enter anime repository URL",
283+
),
284+
const SizedBox(height: 16),
285+
_buildRepoField(
286+
context,
287+
"Manga Repository",
288+
mangaRepoController,
289+
Icons.book_outlined,
290+
"Enter manga repository URL",
291+
),
292+
],
293+
const SizedBox(height: 32),
294+
Row(
295+
children: [
296+
Expanded(
297+
child: TextButton(
298+
onPressed: () => Navigator.of(context).pop(),
299+
style: TextButton.styleFrom(
300+
padding: const EdgeInsets.symmetric(vertical: 14),
301+
shape: RoundedRectangleBorder(
302+
borderRadius: BorderRadius.circular(12),
303+
),
304+
),
305+
child: Text(
306+
"Cancel",
307+
style: TextStyle(
308+
fontSize: 16,
309+
fontWeight: FontWeight.w500,
310+
color: Theme.of(context).colorScheme.onSurfaceVariant,
311+
),
312+
),
313+
),
314+
),
315+
const SizedBox(width: 12),
316+
Expanded(
317+
child: ElevatedButton(
318+
onPressed: handleSave,
319+
style: ElevatedButton.styleFrom(
320+
backgroundColor: Theme.of(context).colorScheme.primary,
321+
foregroundColor:
322+
Theme.of(context).colorScheme.onPrimary,
323+
elevation: 0,
324+
padding: const EdgeInsets.symmetric(vertical: 14),
325+
shape: RoundedRectangleBorder(
326+
borderRadius: BorderRadius.circular(12),
327+
),
328+
),
329+
child: const Text(
330+
"Save",
331+
style: TextStyle(
332+
fontSize: 16,
333+
fontWeight: FontWeight.w600,
334+
),
335+
),
336+
),
337+
),
338+
],
339+
),
340+
],
341+
),
342+
),
343+
),
344+
);
345+
}
346+
347+
Widget _buildRepoField(
348+
BuildContext context,
349+
String label,
350+
TextEditingController controller,
351+
IconData icon,
352+
String hint,
353+
) {
354+
return Column(
355+
crossAxisAlignment: CrossAxisAlignment.start,
356+
children: [
357+
Text(
358+
label,
359+
style: TextStyle(
360+
fontSize: 14,
361+
fontWeight: FontWeight.w600,
362+
color: Theme.of(context).colorScheme.onSurface,
363+
),
364+
),
365+
const SizedBox(height: 8),
366+
TextField(
367+
controller: controller,
368+
decoration: InputDecoration(
369+
hintText: hint,
370+
prefixIcon: Icon(icon, size: 20),
371+
border: OutlineInputBorder(
372+
borderRadius: BorderRadius.circular(12),
373+
borderSide: BorderSide(
374+
color: Theme.of(context).colorScheme.outline,
375+
),
376+
),
377+
enabledBorder: OutlineInputBorder(
378+
borderRadius: BorderRadius.circular(12),
379+
borderSide: BorderSide(
380+
color: Theme.of(context).colorScheme.outline,
381+
),
382+
),
383+
focusedBorder: OutlineInputBorder(
384+
borderRadius: BorderRadius.circular(12),
385+
borderSide: BorderSide(
386+
color: Theme.of(context).colorScheme.primary,
387+
width: 2,
388+
),
389+
),
390+
contentPadding: const EdgeInsets.symmetric(
391+
horizontal: 16,
392+
vertical: 14,
393+
),
394+
),
395+
),
396+
],
397+
);
398+
}
399+
}

0 commit comments

Comments
 (0)