79 lines
2.3 KiB
Dart
79 lines
2.3 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:flutter_bloc/flutter_bloc.dart';
|
|
import 'package:notube/dlForm/cubit/dl_form_cubit.dart';
|
|
import 'package:notube/dlForm/formComponents/format_dropdown.dart';
|
|
import 'package:notube/dlForm/formComponents/submit_button.dart';
|
|
import 'package:notube/dlForm/formComponents/url_text_field.dart';
|
|
|
|
class DlForm extends StatelessWidget {
|
|
const DlForm({super.key});
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return BlocProvider(
|
|
create: (context) => DlFormCubit(),
|
|
child: Form(child: LayoutBuilder(
|
|
builder: (BuildContext context, BoxConstraints constraints) {
|
|
if (constraints.maxWidth < 320) {
|
|
return Column(
|
|
children: [
|
|
Row(children: <Widget>[
|
|
UrlTextField(),
|
|
]),
|
|
Row(children: <Widget>[
|
|
Expanded(flex: 1, child: DropdownFormat()),
|
|
]),
|
|
Row(children: <Widget>[
|
|
Expanded(flex: 1, child: SubmitButton()),
|
|
]),
|
|
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 {
|
|
return Column(
|
|
children: [
|
|
Row(children: <Widget>[
|
|
UrlTextField(),
|
|
DropdownFormat(),
|
|
SubmitButton(),
|
|
]),
|
|
DebugDlFormState(),
|
|
],
|
|
);
|
|
}
|
|
})));
|
|
}
|
|
}
|
|
|
|
class DebugDlFormState extends StatelessWidget {
|
|
const DebugDlFormState({super.key});
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return BlocBuilder<DlFormCubit, DlFormState>(builder: (context, state) {
|
|
final url = state.url;
|
|
final format = state.format;
|
|
|
|
return Column(
|
|
children: <Widget>[
|
|
Text('Url: $url'),
|
|
Text('Format: ${format.format}'),
|
|
],
|
|
);
|
|
});
|
|
}
|
|
}
|