[ui] basic responsive

This commit is contained in:
jscampucci 2024-06-11 14:40:49 +02:00
parent 5a951403cd
commit 3503f37134
5 changed files with 59 additions and 29 deletions

View File

@ -15,7 +15,8 @@ class DlForm extends StatelessWidget {
child: Form(child: LayoutBuilder( child: Form(child: LayoutBuilder(
builder: (BuildContext context, BoxConstraints constraints) { builder: (BuildContext context, BoxConstraints constraints) {
debugPrint('Max width: ${constraints.maxWidth}'); debugPrint('Max width: ${constraints.maxWidth}');
if (constraints.maxWidth < 720) { debugPrint('Max height: ${MediaQuery.of(context).size.height}');
if (constraints.maxWidth < 320) {
return Column( return Column(
children: [ children: [
Row(children: <Widget>[ Row(children: <Widget>[
@ -23,11 +24,26 @@ class DlForm extends StatelessWidget {
]), ]),
Row(children: <Widget>[ Row(children: <Widget>[
Expanded(flex: 1, child: DropdownFormat()), Expanded(flex: 1, child: DropdownFormat()),
]),
Row(children: <Widget>[
Expanded(flex: 1, child: SubmitButton()), Expanded(flex: 1, child: SubmitButton()),
]), ]),
DebugDlFormState(), DebugDlFormState(),
], ],
); );
} else if (constraints.maxWidth < 720) {
return Column(
children: [
Row(children: <Widget>[
UrlTextField(),
]),
Row(children: <Widget>[
Expanded(flex: 1, child: DropdownFormat()),
Expanded(flex: 2, child: SubmitButton()),
]),
DebugDlFormState(),
],
);
} else { } else {
return Column( return Column(
children: [ children: [

View File

@ -17,24 +17,27 @@ class _SubmitButtonState extends State<SubmitButton> {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
var dlForm = context.watch<DlFormState>(); var dlForm = context.watch<DlFormState>();
return MouseRegion( return ConstrainedBox(
cursor: SystemMouseCursors.click, constraints: BoxConstraints.tightFor(width: 200),
child: GestureDetector( child: MouseRegion(
onTap: () { cursor: SystemMouseCursors.click,
dlForm.download(); child: GestureDetector(
}, onTap: () {
child: InkWell( dlForm.download();
onHover: (hovering) {
setState(() => isHovering = hovering);
}, },
child: Container( child: InkWell(
padding: onHover: (hovering) {
const EdgeInsets.symmetric(horizontal: 80, vertical: 14), debugPrint('Hovering: $hovering');
decoration: BoxDecoration( setState(() => isHovering = hovering);
color: isHovering ? colorDarkRed : colorMainRed, },
child: Container(
padding: const EdgeInsets.symmetric(vertical: 14),
decoration: BoxDecoration(
color: isHovering ? colorDarkRed : colorMainRed,
),
child: const Text('Ok', textAlign: TextAlign.center).tr(),
), ),
child: const Text('Ok').tr(), ))),
), );
)));
} }
} }

View File

@ -13,15 +13,24 @@ class Home extends StatelessWidget {
title: Text('home').tr(), title: Text('home').tr(),
), ),
body: Center( body: Center(
child: Column( child: Container(
children: <Widget>[ constraints: BoxConstraints.expand(),
SizedBox(height: 10), decoration: BoxDecoration(
Text('home_intro').tr(), image: DecorationImage(
SizedBox(height: 10), image: AssetImage("assets/images/wallpaper.webp"),
Padding( fit: BoxFit.cover,
padding: EdgeInsets.symmetric(horizontal: 20), ),
child: DlForm()) ),
], child: Column(
children: <Widget>[
SizedBox(height: 10),
Text('home_intro').tr(),
SizedBox(height: 10),
Padding(
padding: EdgeInsets.symmetric(horizontal: 20),
child: DlForm())
],
),
), ),
)); ));
} }

View File

@ -38,12 +38,13 @@ class DlFormState extends ChangeNotifier {
}); });
var ytDlpPath = tempFile.path; var ytDlpPath = tempFile.path;
var command = url.trim(); var command =
'${url.trim()} --sub-langs "all,-live_chat" --embed-subs --embed-thumbnail --embed-metadata --output temp.mp4';
var shell = Shell(); var shell = Shell();
debugPrint('Running $ytDlpPath $command'); debugPrint('Running $ytDlpPath $command');
var results = await shell.run(''' var results = await shell.run('''
pwd dir
$ytDlpPath $command $ytDlpPath $command
'''); ''');
} }

View File

@ -31,6 +31,7 @@ flutter:
assets: assets:
- lib/translations/ - lib/translations/
- assets/images/
- assets/executable/ - assets/executable/
flutter_intl: flutter_intl:
enabled: true enabled: true