2020-07-27 20:43:58 +00:00
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
import 'package:mobile_nebula/services/utils.dart';
|
|
|
|
|
|
|
|
import 'ConfigHeader.dart';
|
|
|
|
|
|
|
|
class ConfigSection extends StatelessWidget {
|
2022-09-21 20:27:35 +00:00
|
|
|
const ConfigSection({Key? key, this.label, required this.children, this.borderColor, this.labelColor})
|
|
|
|
: super(key: key);
|
2020-07-27 20:43:58 +00:00
|
|
|
|
|
|
|
final List<Widget> children;
|
2022-09-21 20:27:35 +00:00
|
|
|
final String? label;
|
|
|
|
final Color? borderColor;
|
|
|
|
final Color? labelColor;
|
2020-07-27 20:43:58 +00:00
|
|
|
|
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
final border = BorderSide(color: borderColor ?? Utils.configSectionBorder(context));
|
|
|
|
|
|
|
|
List<Widget> _children = [];
|
|
|
|
final len = children.length;
|
|
|
|
|
|
|
|
for (var i = 0; i < len; i++) {
|
|
|
|
_children.add(children[i]);
|
|
|
|
|
|
|
|
if (i < len - 1) {
|
|
|
|
double pad = 15;
|
|
|
|
if (children[i + 1].runtimeType.toString() == 'ConfigButtonItem') {
|
|
|
|
pad = 0;
|
|
|
|
}
|
|
|
|
_children.add(Padding(
|
|
|
|
child: Divider(height: 1, color: Utils.configSectionBorder(context)), padding: EdgeInsets.only(left: pad)));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return Column(crossAxisAlignment: CrossAxisAlignment.start, children: [
|
2022-09-21 20:27:35 +00:00
|
|
|
label != null ? ConfigHeader(label: label!, color: labelColor) : Container(height: 20),
|
2020-07-27 20:43:58 +00:00
|
|
|
Container(
|
|
|
|
decoration:
|
|
|
|
BoxDecoration(border: Border(top: border, bottom: border), color: Utils.configItemBackground(context)),
|
|
|
|
child: Column(
|
|
|
|
children: _children,
|
|
|
|
))
|
|
|
|
]);
|
|
|
|
}
|
|
|
|
}
|