3
0
Fork 0
trifid_mobile/lib/components/config/ConfigSection.dart

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

46 lines
1.4 KiB
Dart
Raw Permalink Normal View History

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 {
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;
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: [
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,
))
]);
}
}