-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
66db63e
commit 03c6f85
Showing
10 changed files
with
193 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
38 changes: 38 additions & 0 deletions
38
.../lib/src/component_library/components/switch_list_item/switch_list_item_library_item.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import 'package:impaktfull_ui_example/src/component_library/components/switch_list_item/switch_list_item_library_variant.dart'; | ||
import 'package:impaktfull_ui_example/src/component_library/config/component_library_inputs.dart'; | ||
import 'package:impaktfull_ui_example/src/component_library/config/component_library_item.dart'; | ||
import 'package:impaktfull_ui_example/src/component_library/inputs/component_library_boolean_input.dart'; | ||
import 'package:impaktfull_ui_example/src/component_library/inputs/component_library_string_input.dart'; | ||
|
||
class SwitchListItemLibraryItem extends ComponentLibraryItem { | ||
const SwitchListItemLibraryItem(); | ||
|
||
@override | ||
String get title => 'ImpaktfullUiSwitchListItem'; | ||
|
||
@override | ||
List<ComponentLibraryVariant> getComponentVariants() { | ||
return [ | ||
const SwitchListItemLibraryVariant(), | ||
]; | ||
} | ||
} | ||
|
||
class SwitchListItemLibraryInputs extends ComponentLibraryInputs { | ||
final ComponentLibraryStringInput title = ComponentLibraryStringInput( | ||
'Title', | ||
initialValue: 'Title', | ||
); | ||
final ComponentLibraryStringInput subtitle = ComponentLibraryStringInput( | ||
'Subtitle', | ||
initialValue: 'Subtitle', | ||
); | ||
final ComponentLibraryBoolInput switchValue = | ||
ComponentLibraryBoolInput('Switch value'); | ||
@override | ||
List<ComponentLibraryInputItem> buildInputItems() => [ | ||
title, | ||
subtitle, | ||
switchValue, | ||
]; | ||
} |
32 changes: 32 additions & 0 deletions
32
...b/src/component_library/components/switch_list_item/switch_list_item_library_variant.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import 'package:flutter/material.dart'; | ||
import 'package:impaktfull_ui_2/impaktfull_ui.dart'; | ||
import 'package:impaktfull_ui_example/src/component_library/components/switch_list_item/switch_list_item_library_item.dart'; | ||
import 'package:impaktfull_ui_example/src/component_library/config/component_library_item.dart'; | ||
|
||
class SwitchListItemLibraryVariant | ||
extends ComponentLibraryVariant<SwitchListItemLibraryPrimaryInputs> { | ||
const SwitchListItemLibraryVariant(); | ||
|
||
@override | ||
String get title => 'Default'; | ||
|
||
@override | ||
List<Widget> build( | ||
BuildContext context, SwitchListItemLibraryPrimaryInputs inputs) { | ||
return [ | ||
ImpaktfullUiSwitchListItem( | ||
title: inputs.title.value ?? '', | ||
subtitle: inputs.subtitle.value, | ||
leading: theme.assets.icons.settings, | ||
value: inputs.switchValue.value ?? false, | ||
onChanged: inputs.switchValue.updateState, | ||
), | ||
]; | ||
} | ||
|
||
@override | ||
SwitchListItemLibraryPrimaryInputs inputs() => | ||
SwitchListItemLibraryPrimaryInputs(); | ||
} | ||
|
||
class SwitchListItemLibraryPrimaryInputs extends SwitchListItemLibraryInputs {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
import 'package:flutter/material.dart'; | ||
import 'package:impaktfull_ui_2/impaktfull_ui.dart'; | ||
import 'package:impaktfull_ui_2/src/components/theme/theme_component_builder.dart'; | ||
|
||
export 'switch_list_item_style.dart'; | ||
|
||
part 'switch_list_item.describe.dart'; | ||
|
||
class ImpaktfullUiSwitchListItem extends StatelessWidget | ||
with ComponentDescriptorMixin { | ||
final String title; | ||
final String? subtitle; | ||
final bool value; | ||
final ImpaktfullUiAsset? leading; | ||
final ValueChanged<bool>? onChanged; | ||
final ImpaktfullUiSwitchListItemTheme? theme; | ||
|
||
const ImpaktfullUiSwitchListItem({ | ||
required this.title, | ||
required this.value, | ||
required this.onChanged, | ||
this.subtitle, | ||
this.leading, | ||
this.theme, | ||
super.key, | ||
}); | ||
|
||
@override | ||
Widget build(BuildContext context) { | ||
return ImpaktfullUiComponentThemeBuidler<ImpaktfullUiSwitchListItemTheme>( | ||
overrideComponentTheme: theme, | ||
builder: (context, theme, componentTheme) => ImpaktfullUiSimpleListItem( | ||
title: title, | ||
subtitle: subtitle, | ||
onTap: onChanged == null ? null : _onTap, | ||
type: ImpaktfullUiSimpleListItemType.neutral, | ||
leadingWidgetBuilder: leading == null | ||
? null | ||
: (context) => ImpaktfullUiAssetWidget( | ||
asset: leading, | ||
color: componentTheme.colors.icons, | ||
), | ||
trailingWidgetBuilder: (context) => ImpaktfullUiSwitch( | ||
value: value, | ||
onChanged: onChanged == null ? null : _onChanged, | ||
), | ||
), | ||
); | ||
} | ||
|
||
@override | ||
String describe(BuildContext context) => _describeInstance(context, this); | ||
|
||
void _onTap() => _onChanged(!value); | ||
|
||
void _onChanged(bool value) => onChanged?.call(value); | ||
} |
8 changes: 8 additions & 0 deletions
8
lib/src/components/switch_list_item/switch_list_item.describe.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
part of 'switch_list_item.dart'; | ||
|
||
String _describeInstance( | ||
BuildContext context, ImpaktfullUiSwitchListItem instance) { | ||
final descriptor = ComponentDescriptor(); | ||
descriptor.add('theme', instance.theme); | ||
return descriptor.describe(); | ||
} |
38 changes: 38 additions & 0 deletions
38
lib/src/components/switch_list_item/switch_list_item_style.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import 'package:flutter/widgets.dart'; | ||
import 'package:impaktfull_ui_2/src/theme/theme.dart'; | ||
|
||
class ImpaktfullUiSwitchListItemTheme extends ImpaktfullUiComponentTheme { | ||
final ImpaktfullUiSwitchListItemAssetsTheme assets; | ||
final ImpaktfullUiSwitchListItemColorTheme colors; | ||
final ImpaktfullUiSwitchListItemDimensTheme dimens; | ||
final ImpaktfullUiSwitchListItemTextStyleTheme textStyles; | ||
|
||
const ImpaktfullUiSwitchListItemTheme({ | ||
required this.assets, | ||
required this.colors, | ||
required this.dimens, | ||
required this.textStyles, | ||
}); | ||
|
||
static ImpaktfullUiSwitchListItemTheme of(BuildContext context) => | ||
ImpaktfullUiTheme.of(context).components.switchListItem; | ||
} | ||
|
||
class ImpaktfullUiSwitchListItemAssetsTheme { | ||
const ImpaktfullUiSwitchListItemAssetsTheme(); | ||
} | ||
|
||
class ImpaktfullUiSwitchListItemColorTheme { | ||
final Color icons; | ||
const ImpaktfullUiSwitchListItemColorTheme({ | ||
required this.icons, | ||
}); | ||
} | ||
|
||
class ImpaktfullUiSwitchListItemDimensTheme { | ||
const ImpaktfullUiSwitchListItemDimensTheme(); | ||
} | ||
|
||
class ImpaktfullUiSwitchListItemTextStyleTheme { | ||
const ImpaktfullUiSwitchListItemTextStyleTheme(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters