Skip to content

Commit

Permalink
fix: sidebase showcase examples
Browse files Browse the repository at this point in the history
  • Loading branch information
vanlooverenkoen committed Oct 5, 2024
1 parent cd3c676 commit 01577d9
Show file tree
Hide file tree
Showing 24 changed files with 332 additions and 138 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ import 'package:impaktfull_ui_2/impaktfull_ui.dart';
import 'package:impaktfull_ui_example/src/component_library/components/badge/badge_library_item.dart';
import 'package:impaktfull_ui_example/src/component_library/config/component_library_item.dart';

class BadgeTypeLibraryVariant extends ComponentLibraryVariant<BadgeLibraryVariantInputs> {
class BadgeTypeLibraryVariant
extends ComponentLibraryVariant<BadgeLibraryVariantInputs> {
final ImpaktfullUiBadgeType type;
BadgeTypeLibraryVariant(this.type);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,3 @@ class NetworkImageLibraryInputs extends ComponentLibraryInputs {
@override
List<ComponentLibraryInputItem> buildInputItems() => [];
}

Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,16 @@ import 'package:impaktfull_ui_example/src/component_library/components/network_i
import 'package:impaktfull_ui_example/src/component_library/config/component_library_item.dart';
import 'package:impaktfull_ui_example/src/util/network_images.dart';

class NetworkImageLibraryVariant extends ComponentLibraryVariant<NetworkImageLibraryPrimaryInputs> {
class NetworkImageLibraryVariant
extends ComponentLibraryVariant<NetworkImageLibraryPrimaryInputs> {
const NetworkImageLibraryVariant();

@override
String get title => 'Default';

@override
List<Widget> build(BuildContext context, NetworkImageLibraryPrimaryInputs inputs) {
List<Widget> build(
BuildContext context, NetworkImageLibraryPrimaryInputs inputs) {
return [
const ImpaktfullUiNetworkImage(
url: NetworkImages.profilePicture,
Expand All @@ -20,7 +22,8 @@ class NetworkImageLibraryVariant extends ComponentLibraryVariant<NetworkImageLib
}

@override
NetworkImageLibraryPrimaryInputs inputs() => NetworkImageLibraryPrimaryInputs();
NetworkImageLibraryPrimaryInputs inputs() =>
NetworkImageLibraryPrimaryInputs();
}

class NetworkImageLibraryPrimaryInputs extends NetworkImageLibraryInputs {}
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import 'package:impaktfull_ui_example/src/component_library/components/sidebar_navigation/sidebar_navigation_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_int_input.dart';

class SidebarNavigationLibraryItem extends ComponentLibraryItem {
const SidebarNavigationLibraryItem();
Expand All @@ -17,6 +18,13 @@ class SidebarNavigationLibraryItem extends ComponentLibraryItem {
}

class SidebarNavigationLibraryInputs extends ComponentLibraryInputs {
final ComponentLibraryIntInput amountOfSecondaryItems =
ComponentLibraryIntInput(
'Amount of secondary items',
initialValue: 0,
);
@override
List<ComponentLibraryInputItem> buildInputItems() => [];
List<ComponentLibraryInputItem> buildInputItems() => [
amountOfSecondaryItems,
];
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,51 @@ import 'package:impaktfull_ui_2/impaktfull_ui.dart';
import 'package:impaktfull_ui_example/src/component_library/components/sidebar_navigation/sidebar_navigation_library_item.dart';
import 'package:impaktfull_ui_example/src/component_library/config/component_library_item.dart';
import 'package:impaktfull_ui_example/src/util/network_images.dart';
import 'package:impaktfull_ui_example/src/widget/components/components_library_variant_descriptor.dart';

class SidebarNavigationLibraryVariant extends ComponentLibraryVariant<SidebarNavigationLibraryPrimaryInputs> {
class SidebarNavigationLibraryVariant
extends ComponentLibraryVariant<SidebarNavigationLibraryPrimaryInputs> {
const SidebarNavigationLibraryVariant();

@override
String get title => 'Default';

@override
List<Widget> build(BuildContext context, SidebarNavigationLibraryPrimaryInputs inputs) {
List<Widget> build(
BuildContext context, SidebarNavigationLibraryPrimaryInputs inputs) {
return [
SizedBox(
ComponentsLibraryVariantDescriptor(
height: 250,
child: ImpaktfullUiSidebarNavigation(
width: 200,
header: ImpaktfullUiAssetWidget(
asset: theme.assets.images.logo,
width: 150,
),
items: [
ImpaktfullUiSidebarNavigationItem(
leading: theme.assets.icons.home,
title: 'Home',
items: [
ImpaktfullUiSidebarNavigationItem(
leading: theme.assets.icons.confetti,
title: 'Projects',
),
ImpaktfullUiSidebarNavigationItem(
leading: theme.assets.icons.confetti,
title: 'Apps',
),
],
),
ImpaktfullUiSidebarNavigationItem(
leading: theme.assets.icons.search,
title: 'Search',
),
],
),
),
ComponentsLibraryVariantDescriptor(
height: 500,
width: 300,
child: ImpaktfullUiSidebarNavigation(
asset: theme.assets.images.logo,
items: [
Expand All @@ -28,6 +60,15 @@ class SidebarNavigationLibraryVariant extends ComponentLibraryVariant<SidebarNav
title: 'Search',
),
],
secondaryItems: List.generate(
inputs.amountOfSecondaryItems.value ?? 0, (index) => index)
.map(
(index) => ImpaktfullUiSidebarNavigationItem(
leading: theme.assets.icons.confetti,
title: 'Submenu $index',
),
)
.toList(),
footerItems: [
ImpaktfullUiSidebarNavigationItem(
leading: theme.assets.icons.settings,
Expand All @@ -54,10 +95,12 @@ class SidebarNavigationLibraryVariant extends ComponentLibraryVariant<SidebarNav
),
),
trailingWidgetBuilder: (context) => const SizedBox(width: 40),
borderRadius: ImpaktfullUiSidebarNavigationItemTheme.of(context).dimens.borderRadius,
borderRadius: ImpaktfullUiSidebarNavigationItemTheme.of(context)
.dimens
.borderRadius,
padding: const EdgeInsets.symmetric(
horizontal: 12,
vertical: 4,
vertical: 8,
),
title: 'impaktfull admin',
subtitle: '[email protected]',
Expand All @@ -70,7 +113,8 @@ class SidebarNavigationLibraryVariant extends ComponentLibraryVariant<SidebarNav
textDirection: Directionality.of(context),
child: ImpaktfullUiIconButton(
asset: theme.assets.icons.logout,
onTap: () => ImpaktfullUiNotification.show(title: 'Logout tapped'),
onTap: () =>
ImpaktfullUiNotification.show(title: 'Logout tapped'),
),
),
],
Expand All @@ -81,7 +125,9 @@ class SidebarNavigationLibraryVariant extends ComponentLibraryVariant<SidebarNav
}

@override
SidebarNavigationLibraryPrimaryInputs inputs() => SidebarNavigationLibraryPrimaryInputs();
SidebarNavigationLibraryPrimaryInputs inputs() =>
SidebarNavigationLibraryPrimaryInputs();
}

class SidebarNavigationLibraryPrimaryInputs extends SidebarNavigationLibraryInputs {}
class SidebarNavigationLibraryPrimaryInputs
extends SidebarNavigationLibraryInputs {}
11 changes: 1 addition & 10 deletions example/lib/src/widget/components/component_card.dart
Original file line number Diff line number Diff line change
Expand Up @@ -38,16 +38,7 @@ class ComponentCard extends StatelessWidget {
child: ClipRect(
child: Padding(
padding: const EdgeInsets.all(16),
child: LayoutBuilder(
builder: (context, constraints) => OverflowBox(
alignment: Alignment.center,
minWidth: 0.0,
minHeight: 0.0,
maxWidth: constraints.maxWidth,
maxHeight: constraints.maxHeight + 500,
child: correctChild,
),
),
child: correctChild,
),
),
),
Expand Down
2 changes: 1 addition & 1 deletion lib/impaktfull_ui.dart
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ export 'src/components/grid_view/grid_view.dart';
export 'src/components/horizontal_tab/horizontal_tab.dart';
export 'src/components/horizontal_tabs/horizontal_tabs.dart';
export 'src/components/icon_button/icon_button.dart';
export 'src/components/input_field/action/input_field_action.dart';
export 'src/components/input_field/input_field.dart';
export 'src/components/list_item/list_item.dart';
export 'src/components/list_view/list_view.dart';
Expand Down Expand Up @@ -49,6 +48,7 @@ export 'src/components/theme/theme_builder.dart';
// Widget Library
export 'src/util/descriptor/component_descriptor_mixin.dart';
// Extensions
export 'src/util/extension/edge_insets_geometry_extension.dart';
export 'src/util/extension/border_radius_geometry_extension.dart';
// Util
export 'src/util/responsive/responsive_extension.dart';
Expand Down
6 changes: 4 additions & 2 deletions lib/src/components/asset/asset_widget.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ import 'package:rive/rive.dart' hide Image;

part 'asset_widget.describe.dart';

class ImpaktfullUiAssetWidget extends StatelessWidget with ComponentDescriptorMixin {
class ImpaktfullUiAssetWidget extends StatelessWidget
with ComponentDescriptorMixin {
final ImpaktfullUiAsset? asset;
final Color? color;
final double? width;
Expand Down Expand Up @@ -53,7 +54,8 @@ class ImpaktfullUiAssetWidget extends StatelessWidget with ComponentDescriptorMi
if (svgAsset != null) {
return SvgPicture.asset(
svgAsset,
colorFilter: color == null ? null : ColorFilter.mode(color, BlendMode.srcIn),
colorFilter:
color == null ? null : ColorFilter.mode(color, BlendMode.srcIn),
width: width,
height: height,
package: asset.package,
Expand Down
15 changes: 10 additions & 5 deletions lib/src/components/command_menu/command_menu.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,14 @@ export 'command_menu_style.dart';

part 'command_menu.describe.dart';

class ImpaktfullUiCommandMenu extends StatefulWidget with ComponentDescriptorMixin {
class ImpaktfullUiCommandMenu extends StatefulWidget
with ComponentDescriptorMixin {
final ShortcutActivator? shortcutActivator;
final Widget child;
final Widget Function(BuildContext context, ImpaktfullUiCommandMenuTheme theme, CommanderController controller)
builder;
final Widget Function(
BuildContext context,
ImpaktfullUiCommandMenuTheme theme,
CommanderController controller) builder;
final ImpaktfullUiCommandMenuTheme? theme;

const ImpaktfullUiCommandMenu({
Expand All @@ -24,7 +27,8 @@ class ImpaktfullUiCommandMenu extends StatefulWidget with ComponentDescriptorMix
});

@override
State<ImpaktfullUiCommandMenu> createState() => _ImpaktfullUiCommandMenuState();
State<ImpaktfullUiCommandMenu> createState() =>
_ImpaktfullUiCommandMenuState();

@override
String describe(BuildContext context) => _describeInstance(context, this);
Expand All @@ -47,7 +51,8 @@ class _ImpaktfullUiCommandMenuState extends State<ImpaktfullUiCommandMenu> {
bindings: <ShortcutActivator, VoidCallback>{
shortcutActivator: () => _commanderController.hide(),
},
child: widget.builder(context, componentTheme, _commanderController),
child:
widget.builder(context, componentTheme, _commanderController),
),
child: widget.child,
);
Expand Down
1 change: 1 addition & 0 deletions lib/src/components/input_field/input_field.dart
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import 'package:impaktfull_ui_2/src/util/descriptor/component_descriptor_mixin.d
import 'package:impaktfull_ui_2/src/util/extension/border_radius_geometry_extension.dart';

export 'input_field_style.dart';
export 'action/input_field_action.dart';

part 'input_field.describe.dart';

Expand Down
3 changes: 2 additions & 1 deletion lib/src/components/list_item/list_item.dart
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ export 'list_item_type.dart';

part 'list_item.describe.dart';

class ImpaktfullUiListItem extends StatefulWidget with ComponentDescriptorMixin {
class ImpaktfullUiListItem extends StatefulWidget
with ComponentDescriptorMixin {
final String title;
final String? subtitle;
final ImpaktfullUiAsset? leading;
Expand Down
6 changes: 4 additions & 2 deletions lib/src/components/network_image/network_image.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ export 'network_image_style.dart';

part 'network_image.describe.dart';

class ImpaktfullUiNetworkImage extends StatelessWidget with ComponentDescriptorMixin {
class ImpaktfullUiNetworkImage extends StatelessWidget
with ComponentDescriptorMixin {
final String url;
final double? height;
final double? width;
Expand Down Expand Up @@ -35,7 +36,8 @@ class ImpaktfullUiNetworkImage extends StatelessWidget with ComponentDescriptorM
builder: (context, theme, componentTheme) {
String fullUrl = url;
if (url.startsWith('https://picsum.photos')) {
fullUrl = 'https://picsum.photos/${(width ?? 300).toInt()}/${(height ?? 300).toInt()}';
fullUrl =
'https://picsum.photos/${(width ?? 300).toInt()}/${(height ?? 300).toInt()}';
}
return Image.network(
fullUrl,
Expand Down
5 changes: 3 additions & 2 deletions lib/src/components/network_image/network_image.describe.dart
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
part of 'network_image.dart';

String _describeInstance(BuildContext context, ImpaktfullUiNetworkImage instance) {
String _describeInstance(
BuildContext context, ImpaktfullUiNetworkImage instance) {
final descriptor = ComponentDescriptor();
descriptor.add('theme', instance.theme);
return descriptor.describe();
}
}
4 changes: 2 additions & 2 deletions lib/src/components/network_image/network_image_style.dart
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ class ImpaktfullUiNetworkImageTheme extends ImpaktfullUiComponentTheme {
required this.textStyles,
});

static ImpaktfullUiNetworkImageTheme of(BuildContext context) => ImpaktfullUiTheme.of(context).components.networkImage;
static ImpaktfullUiNetworkImageTheme of(BuildContext context) =>
ImpaktfullUiTheme.of(context).components.networkImage;
}

class ImpaktfullUiNetworkImageAssetsTheme {
Expand All @@ -29,7 +30,6 @@ class ImpaktfullUiNetworkImageDimensTheme {
const ImpaktfullUiNetworkImageDimensTheme();
}


class ImpaktfullUiNetworkImageTextStyleTheme {
const ImpaktfullUiNetworkImageTextStyleTheme();
}
Loading

0 comments on commit 01577d9

Please sign in to comment.