Files
2024-11-13 19:18:27 +01:00

156 lines
4.1 KiB
Dart

import 'package:flutter/material.dart';
import 'package:multimedia/constants.dart';
import 'package:multimedia/widgets/movies/details/settings_box_local_path.dart';
import 'package:multimedia/widgets/movies/details/settings_box_resolution.dart';
import 'package:multimedia/widgets/movies/details/state_box.dart';
// ignore: must_be_immutable
class MovieDetailsSettingsBox extends StatelessWidget {
MovieDetailsSettingsBox({
super.key,
required this.localPath,
required this.resolution,
required this.state,
required this.settingsChanged,
});
String localPath;
String resolution;
int state;
final Function(String localPath, String resolution, int state) settingsChanged;
void localPathChanged(String localPath) {
this.localPath = localPath;
settingsChanged(localPath, resolution, state);
}
void resolutionChanged(String resolution) {
this.resolution = resolution;
settingsChanged(localPath, resolution, state);
}
void stateChanged(int state) {
this.state = state;
settingsChanged(localPath, resolution, state);
}
Widget generateInputs(BuildContext context) {
double width = MediaQuery.of(context).size.width;
if (width < 1000) {
return Table(
columnWidths: const {
0: IntrinsicColumnWidth(),
1: IntrinsicColumnWidth(),
},
children: [
TableRow(
children: [
MovieDetailsSettingsBoxResolution(
resolution: resolution,
resolutionChanged: resolutionChanged,
),
],
),
TableRow(
children: [
MovieDetailsSettingsBoxLocalPath(
localPath: localPath,
localPathChanged: localPathChanged,
),
],
),
TableRow(
children: [
MovieDetailsSettingsStateBox(
state: state,
stateChanged: stateChanged,
),
],
),
],
);
}
return Table(
columnWidths: const {
0: IntrinsicColumnWidth(),
1: IntrinsicColumnWidth(),
2: IntrinsicColumnWidth(),
},
children: [
TableRow(
children: [
MovieDetailsSettingsBoxLocalPath(
localPath: localPath,
localPathChanged: localPathChanged,
),
MovieDetailsSettingsBoxResolution(
resolution: resolution,
resolutionChanged: resolutionChanged,
),
MovieDetailsSettingsStateBox(
state: state,
stateChanged: stateChanged,
),
],
),
],
);
}
@override
Widget build(BuildContext context) {
return Container(
decoration: BoxDecoration(
color: BoxColor.backgroundColor,
borderRadius: const BorderRadius.all(
Radius.circular(10.0),
),
),
child: Column(
children: [
Padding(
padding: const EdgeInsets.only(
left: 5.0,
right: 5.0,
top: 10.0,
bottom: 5.0,
),
child: Container(
decoration: BoxDecoration(
color: BoxColor.titleBackgroundColor,
borderRadius: const BorderRadius.all(
Radius.circular(10.0),
),
),
child: Column(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
Text(
'Settings',
style: TextStyle(
fontWeight: FontWeight.bold,
color: BoxColor.titleColor),
textAlign: TextAlign.center,
),
],
),
),
),
Container(
alignment: Alignment.centerLeft,
child: SingleChildScrollView(
scrollDirection: Axis.horizontal,
child: generateInputs(context),
),
),
],
),
);
}
}