-
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
021694b
commit be31019
Showing
13 changed files
with
327 additions
and
112 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
39 changes: 39 additions & 0 deletions
39
example/lib/src/component_library/components/pagination/pagination_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,39 @@ | ||
import 'package:impaktfull_ui_example/src/component_library/components/pagination/pagination_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 PaginationLibraryItem extends ComponentLibraryItem { | ||
const PaginationLibraryItem(); | ||
|
||
@override | ||
String get title => 'ImpaktfullUiPagination'; | ||
|
||
@override | ||
List<ComponentLibraryVariant> getComponentVariants() { | ||
return [ | ||
const PaginationLibraryVariant(), | ||
]; | ||
} | ||
} | ||
|
||
class PaginationLibraryInputs extends ComponentLibraryInputs { | ||
final ComponentLibraryIntInput page = ComponentLibraryIntInput( | ||
'Page', | ||
initialValue: 1, | ||
); | ||
final ComponentLibraryIntInput amountOfItems = ComponentLibraryIntInput( | ||
'amountOfItems', | ||
initialValue: 55, | ||
); | ||
final ComponentLibraryIntInput itemsPerPage = ComponentLibraryIntInput( | ||
'itemsPerPage', | ||
initialValue: 10, | ||
); | ||
@override | ||
List<ComponentLibraryInputItem> buildInputItems() => [ | ||
itemsPerPage, | ||
amountOfItems, | ||
page, | ||
]; | ||
} |
31 changes: 31 additions & 0 deletions
31
example/lib/src/component_library/components/pagination/pagination_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,31 @@ | ||
import 'package:flutter/material.dart'; | ||
import 'package:impaktfull_ui_2/impaktfull_ui.dart'; | ||
import 'package:impaktfull_ui_example/src/component_library/components/pagination/pagination_library_item.dart'; | ||
import 'package:impaktfull_ui_example/src/component_library/config/component_library_item.dart'; | ||
|
||
class PaginationLibraryVariant extends ComponentLibraryVariant<PaginationLibraryPrimaryInputs> { | ||
const PaginationLibraryVariant(); | ||
|
||
@override | ||
String get title => 'Default'; | ||
|
||
@override | ||
List<Widget> build(BuildContext context, PaginationLibraryPrimaryInputs inputs) { | ||
return [ | ||
ImpaktfullUiPagination( | ||
amountOfItems: inputs.amountOfItems.value ?? 0, | ||
itemsPerPage: inputs.itemsPerPage.value ?? 0, | ||
page: inputs.page.value ?? 0, | ||
onLoadPage: (page) { | ||
inputs.page.updateState(page); | ||
ImpaktfullUiNotification.show(title: 'Load page $page'); | ||
}, | ||
), | ||
]; | ||
} | ||
|
||
@override | ||
PaginationLibraryPrimaryInputs inputs() => PaginationLibraryPrimaryInputs(); | ||
} | ||
|
||
class PaginationLibraryPrimaryInputs extends PaginationLibraryInputs {} |
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
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,63 @@ | ||
import 'package:flutter/material.dart'; | ||
import 'package:impaktfull_ui_2/src/components/auto_layout/auto_layout.dart'; | ||
import 'package:impaktfull_ui_2/src/components/button/button.dart'; | ||
import 'package:impaktfull_ui_2/src/components/pagination/pagination_style.dart'; | ||
import 'package:impaktfull_ui_2/src/components/theme/theme_component_builder.dart'; | ||
import 'package:impaktfull_ui_2/src/util/descriptor/component_descriptor_mixin.dart'; | ||
|
||
export 'pagination_style.dart'; | ||
|
||
part 'pagination.describe.dart'; | ||
|
||
class ImpaktfullUiPagination extends StatelessWidget with ComponentDescriptorMixin { | ||
final int page; | ||
final int itemsPerPage; | ||
final int amountOfItems; | ||
final ValueChanged<int> onLoadPage; | ||
final ImpaktfullUiPaginationTheme? theme; | ||
|
||
int get amountOfPages => (amountOfItems / itemsPerPage).ceil(); | ||
bool get isFinalPage => page == amountOfPages; | ||
|
||
const ImpaktfullUiPagination({ | ||
required this.page, | ||
required this.itemsPerPage, | ||
required this.amountOfItems, | ||
required this.onLoadPage, | ||
this.theme, | ||
super.key, | ||
}); | ||
|
||
@override | ||
Widget build(BuildContext context) { | ||
return ImpaktfullUiComponentThemeBuidler<ImpaktfullUiPaginationTheme>( | ||
overrideComponentTheme: theme, | ||
builder: (context, theme, componentTheme) => ImpaktfullUiAutoLayout.horizontal( | ||
spacing: 8, | ||
crossAxisAlignment: CrossAxisAlignment.center, | ||
children: [ | ||
ImpaktfullUiButton( | ||
type: ImpaktfullUiButtonType.secondaryGrey, | ||
leadingIcon: componentTheme.assets.arrowLeft, | ||
onTap: page == 1 ? null : () => onLoadPage(page - 1), | ||
), | ||
Expanded( | ||
child: Text( | ||
'Page $page of $amountOfPages', | ||
style: componentTheme.textStyles.text, | ||
textAlign: TextAlign.center, | ||
), | ||
), | ||
ImpaktfullUiButton( | ||
type: ImpaktfullUiButtonType.secondaryGrey, | ||
leadingIcon: componentTheme.assets.arrowRight, | ||
onTap: isFinalPage ? null : () => onLoadPage(page + 1), | ||
), | ||
], | ||
), | ||
); | ||
} | ||
|
||
@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,7 @@ | ||
part of 'pagination.dart'; | ||
|
||
String _describeInstance(BuildContext context, ImpaktfullUiPagination instance) { | ||
final descriptor = ComponentDescriptor(); | ||
descriptor.add('theme', instance.theme); | ||
return descriptor.describe(); | ||
} |
Oops, something went wrong.