first commit
This commit is contained in:
72
lib/src/easy_component_settings_group.dart
Normal file
72
lib/src/easy_component_settings_group.dart
Normal file
@@ -0,0 +1,72 @@
|
||||
import 'package:easy_settings_screen/src/easy_component_settings_item.dart';
|
||||
import 'package:easy_settings_screen/src/settings_screen_utils.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
/// This component group the Settings items (BabsComponentSettingsItem)
|
||||
/// All one BabsComponentSettingsGroup have a title and the developper can improve the design.
|
||||
class SettingsGroup extends StatelessWidget {
|
||||
final String? settingsGroupTitle;
|
||||
final TextStyle? settingsGroupTitleStyle;
|
||||
final List<SettingsItem> items;
|
||||
final EdgeInsets? margin;
|
||||
final Color? backgroundColor;
|
||||
// Icons size
|
||||
final double? iconItemSize;
|
||||
|
||||
const SettingsGroup({
|
||||
super.key,
|
||||
this.settingsGroupTitle,
|
||||
this.settingsGroupTitleStyle,
|
||||
required this.items,
|
||||
this.backgroundColor,
|
||||
this.margin,
|
||||
this.iconItemSize = 25,
|
||||
});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
if (iconItemSize != null) {
|
||||
SettingsScreenUtils.settingsGroupIconSize = iconItemSize;
|
||||
}
|
||||
|
||||
return Container(
|
||||
margin: margin ?? EdgeInsets.only(bottom: 20),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
// The title
|
||||
(settingsGroupTitle != null)
|
||||
? Padding(
|
||||
padding: const EdgeInsets.only(bottom: 5),
|
||||
child: Text(
|
||||
settingsGroupTitle!,
|
||||
style: (settingsGroupTitleStyle == null)
|
||||
? TextStyle(fontSize: 25, fontWeight: FontWeight.bold)
|
||||
: settingsGroupTitleStyle,
|
||||
),
|
||||
)
|
||||
: Container(),
|
||||
// The SettingsGroup sections
|
||||
Container(
|
||||
decoration: BoxDecoration(
|
||||
color: backgroundColor ?? Theme.of(context).cardColor,
|
||||
borderRadius: BorderRadius.circular(15),
|
||||
),
|
||||
child: ListView.separated(
|
||||
separatorBuilder: (context, index) {
|
||||
return Divider();
|
||||
},
|
||||
itemCount: items.length,
|
||||
itemBuilder: (BuildContext context, int index) {
|
||||
return items[index];
|
||||
},
|
||||
shrinkWrap: true,
|
||||
padding: EdgeInsets.zero,
|
||||
physics: ScrollPhysics(),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user