-
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
2c2db29
commit 008e690
Showing
14 changed files
with
255 additions
and
15 deletions.
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
22 changes: 22 additions & 0 deletions
22
example/lib/src/component_library/components/avatar/avatar_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,22 @@ | ||
import 'package:impaktfull_ui_example/src/component_library/components/avatar/avatar_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'; | ||
|
||
class AvatarLibraryItem extends ComponentLibraryItem { | ||
const AvatarLibraryItem(); | ||
|
||
@override | ||
String get title => 'ImpaktfullUiAvatar'; | ||
|
||
@override | ||
List<ComponentLibraryVariant> getComponentVariants() { | ||
return [ | ||
const AvatarLibraryVariant(), | ||
]; | ||
} | ||
} | ||
|
||
class AvatarLibraryInputs extends ComponentLibraryInputs { | ||
@override | ||
List<ComponentLibraryInputItem> buildInputItems() => []; | ||
} |
37 changes: 37 additions & 0 deletions
37
example/lib/src/component_library/components/avatar/avatar_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,37 @@ | ||
import 'package:flutter/material.dart'; | ||
import 'package:impaktfull_ui_2/impaktfull_ui.dart'; | ||
import 'package:impaktfull_ui_example/src/component_library/components/avatar/avatar_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'; | ||
|
||
class AvatarLibraryVariant | ||
extends ComponentLibraryVariant<AvatarLibraryPrimaryInputs> { | ||
const AvatarLibraryVariant(); | ||
|
||
@override | ||
String get title => 'Default'; | ||
|
||
@override | ||
List<Widget> build(BuildContext context, AvatarLibraryPrimaryInputs inputs) { | ||
return [ | ||
ImpaktfullUiAvatar( | ||
url: NetworkImages.profilePicture, | ||
width: 40, | ||
height: 40, | ||
onTap: () => ImpaktfullUiNotification.show(title: 'Avatar tapped'), | ||
), | ||
ImpaktfullUiAvatar( | ||
url: null, | ||
width: 40, | ||
height: 40, | ||
onTap: () => | ||
ImpaktfullUiNotification.show(title: 'Empty Avatar tapped'), | ||
), | ||
]; | ||
} | ||
|
||
@override | ||
AvatarLibraryPrimaryInputs inputs() => AvatarLibraryPrimaryInputs(); | ||
} | ||
|
||
class AvatarLibraryPrimaryInputs extends AvatarLibraryInputs {} |
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 |
---|---|---|
@@ -1,4 +1,6 @@ | ||
class NetworkImages { | ||
const NetworkImages._(); | ||
static const String profilePicture = 'https://vanlooverenkoen.be/img/me.png'; | ||
|
||
static const String random = 'https://picsum.photos/300/300'; | ||
} |
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,89 @@ | ||
import 'package:flutter/material.dart'; | ||
import 'package:impaktfull_ui_2/src/components/asset/asset_widget.dart'; | ||
import 'package:impaktfull_ui_2/src/components/avatar/avatar_style.dart'; | ||
import 'package:impaktfull_ui_2/src/components/network_image/network_image.dart'; | ||
import 'package:impaktfull_ui_2/src/components/theme/theme_component_builder.dart'; | ||
import 'package:impaktfull_ui_2/src/components/touch_feedback/touch_feedback.dart'; | ||
import 'package:impaktfull_ui_2/src/models/asset.dart'; | ||
import 'package:impaktfull_ui_2/src/util/descriptor/component_descriptor_mixin.dart'; | ||
|
||
export 'avatar_style.dart'; | ||
|
||
part 'avatar.describe.dart'; | ||
|
||
class ImpaktfullUiAvatar extends StatelessWidget with ComponentDescriptorMixin { | ||
final String? url; | ||
final ImpaktfullUiAsset? placeholderAsset; | ||
final double width; | ||
final double height; | ||
final VoidCallback? onTap; | ||
final ImpaktfullUiAvatarTheme? theme; | ||
|
||
const ImpaktfullUiAvatar({ | ||
required this.url, | ||
this.placeholderAsset, | ||
this.width = 40, | ||
this.height = 40, | ||
this.onTap, | ||
this.theme, | ||
super.key, | ||
}); | ||
|
||
@override | ||
Widget build(BuildContext context) { | ||
return ImpaktfullUiComponentThemeBuidler<ImpaktfullUiAvatarTheme>( | ||
overrideComponentTheme: theme, | ||
builder: (context, theme, componentTheme) => SizedBox( | ||
width: width, | ||
height: height, | ||
child: Stack( | ||
alignment: Alignment.center, | ||
children: [ | ||
Container( | ||
decoration: BoxDecoration( | ||
border: Border.all( | ||
color: componentTheme.colors.border, | ||
width: 1, | ||
), | ||
borderRadius: componentTheme.dimens.borderRadius, | ||
color: componentTheme.colors.background, | ||
), | ||
child: ClipRRect( | ||
borderRadius: componentTheme.dimens.borderRadius, | ||
child: Builder(builder: (context) { | ||
if (url == null) { | ||
return Center( | ||
child: ImpaktfullUiAssetWidget( | ||
asset: placeholderAsset ?? | ||
componentTheme.assets.placeholder, | ||
color: componentTheme.colors.placeholder, | ||
size: width / 2, | ||
), | ||
); | ||
} | ||
return ImpaktfullUiNetworkImage( | ||
url: url!, | ||
); | ||
}), | ||
), | ||
), | ||
if (onTap != null) ...[ | ||
Positioned.fill( | ||
child: ImpaktfullUiTouchFeedback( | ||
onTap: onTap, | ||
borderRadius: componentTheme.dimens.borderRadius, | ||
child: const ColoredBox( | ||
color: Colors.transparent, | ||
), | ||
), | ||
), | ||
], | ||
], | ||
), | ||
), | ||
); | ||
} | ||
|
||
@override | ||
String describe(BuildContext context) => _describeInstance(context, this); | ||
} |
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,11 @@ | ||
part of 'avatar.dart'; | ||
|
||
String _describeInstance(BuildContext context, ImpaktfullUiAvatar instance) { | ||
final descriptor = ComponentDescriptor(); | ||
descriptor.add('url', instance.url); | ||
descriptor.add('placeholderAsset', instance.placeholderAsset); | ||
descriptor.add('width', instance.width); | ||
descriptor.add('height', instance.height); | ||
descriptor.add('theme', instance.theme); | ||
return descriptor.describe(); | ||
} |
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,49 @@ | ||
import 'package:flutter/widgets.dart'; | ||
import 'package:impaktfull_ui_2/src/models/asset.dart'; | ||
import 'package:impaktfull_ui_2/src/theme/theme.dart'; | ||
|
||
class ImpaktfullUiAvatarTheme extends ImpaktfullUiComponentTheme { | ||
final ImpaktfullUiAvatarAssetsTheme assets; | ||
final ImpaktfullUiAvatarColorTheme colors; | ||
final ImpaktfullUiAvatarDimensTheme dimens; | ||
final ImpaktfullUiAvatarTextStyleTheme textStyles; | ||
|
||
const ImpaktfullUiAvatarTheme({ | ||
required this.assets, | ||
required this.colors, | ||
required this.dimens, | ||
required this.textStyles, | ||
}); | ||
|
||
static ImpaktfullUiAvatarTheme of(BuildContext context) => | ||
ImpaktfullUiTheme.of(context).components.avatar; | ||
} | ||
|
||
class ImpaktfullUiAvatarAssetsTheme { | ||
final ImpaktfullUiAsset? placeholder; | ||
const ImpaktfullUiAvatarAssetsTheme({ | ||
required this.placeholder, | ||
}); | ||
} | ||
|
||
class ImpaktfullUiAvatarColorTheme { | ||
final Color border; | ||
final Color background; | ||
final Color placeholder; | ||
const ImpaktfullUiAvatarColorTheme({ | ||
required this.border, | ||
required this.background, | ||
required this.placeholder, | ||
}); | ||
} | ||
|
||
class ImpaktfullUiAvatarDimensTheme { | ||
final BorderRadiusGeometry borderRadius; | ||
const ImpaktfullUiAvatarDimensTheme({ | ||
required this.borderRadius, | ||
}); | ||
} | ||
|
||
class ImpaktfullUiAvatarTextStyleTheme { | ||
const ImpaktfullUiAvatarTextStyleTheme(); | ||
} |
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
Oops, something went wrong.