Skip to content

Commit

Permalink
feat: Pagination (#46)
Browse files Browse the repository at this point in the history
* pagination

* dropdown pagination, docs

* widget book

* fixing todo

* fixing disabled logic
  • Loading branch information
mikecoomber authored Apr 12, 2024
1 parent 5840382 commit d782481
Show file tree
Hide file tree
Showing 7 changed files with 444 additions and 1 deletion.
2 changes: 2 additions & 0 deletions example/lib/home.dart
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import 'package:zeta_example/pages/components/stepper_example.dart';
import 'package:zeta_example/pages/components/switch_example.dart';
import 'package:zeta_example/pages/components/snackbar_example.dart';
import 'package:zeta_example/pages/components/tabs_example.dart';
import 'package:zeta_example/pages/components/pagination_example.dart';
import 'package:zeta_example/pages/theme/color_example.dart';
import 'package:zeta_example/pages/components/password_input_example.dart';
import 'package:zeta_example/pages/components/progress_example.dart';
Expand Down Expand Up @@ -48,6 +49,7 @@ final List<Component> components = [
Component(ChipExample.name, (context) => const ChipExample()),
Component(ListItemExample.name, (context) => const ListItemExample()),
Component(NavigationBarExample.name, (context) => const NavigationBarExample()),
Component(PaginationExample.name, (context) => const PaginationExample()),
Component(PasswordInputExample.name, (context) => const PasswordInputExample()),
Component(DropdownExample.name, (context) => const DropdownExample()),
Component(ProgressExample.name, (context) => const ProgressExample()),
Expand Down
56 changes: 56 additions & 0 deletions example/lib/pages/components/pagination_example.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
import 'package:flutter/material.dart';
import 'package:zeta_example/widgets.dart';
import 'package:zeta_flutter/zeta_flutter.dart';

class PaginationExample extends StatefulWidget {
static const name = 'Pagination';

const PaginationExample({super.key});

@override
State<PaginationExample> createState() => _PaginationExampleState();
}

class _PaginationExampleState extends State<PaginationExample> {
int currentPage = 1;

@override
Widget build(BuildContext context) {
return ExampleScaffold(
name: PaginationExample.name,
child: Center(
child: Padding(
padding: const EdgeInsets.all(64),
child: Column(
children: [
Expanded(
child: Center(
child: Text(
'Current Page: ${currentPage}',
style: Theme.of(context).textTheme.bodyLarge,
),
),
),
ZetaPagination(
pages: 10,
currentPage: currentPage,
onChange: (val) => setState(() {
currentPage = val;
}),
),
const SizedBox(height: 8),
ZetaPagination(
pages: 10,
currentPage: currentPage,
onChange: (val) => setState(() {
currentPage = val;
}),
type: ZetaPaginationType.dropdown,
),
],
),
),
),
);
}
}
2 changes: 2 additions & 0 deletions example/widgetbook/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import 'pages/components/dropdown_widgetbook.dart';
import 'pages/components/in_page_banner_widgetbook.dart';
import 'pages/components/list_item_widgetbook.dart';
import 'pages/components/navigation_bar_widgetbook.dart';
import 'pages/components/pagination_widgetbook.dart';
import 'pages/components/password_input_widgetbook.dart';
import 'pages/components/progress_widgetbook.dart';
import 'pages/components/radio_widgetbook.dart';
Expand Down Expand Up @@ -87,6 +88,7 @@ class HotReload extends StatelessWidget {
WidgetbookUseCase(name: 'Dial Pad', builder: (context) => dialPadUseCase(context)),
WidgetbookUseCase(name: 'List Item', builder: (context) => listItemUseCase(context)),
WidgetbookUseCase(name: 'Navigation Bar', builder: (context) => navigationBarUseCase(context)),
WidgetbookUseCase(name: 'Pagination', builder: (context) => paginationUseCase(context)),
WidgetbookComponent(
name: 'Progress',
useCases: [
Expand Down
18 changes: 18 additions & 0 deletions example/widgetbook/pages/components/pagination_widgetbook.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import 'package:flutter/material.dart';
import 'package:widgetbook/widgetbook.dart';
import 'package:zeta_flutter/zeta_flutter.dart';

import '../../test/test_components.dart';

Widget paginationUseCase(BuildContext context) => WidgetbookTestWidget(
widget: ZetaPagination(
pages: 10,
type: context.knobs.list<ZetaPaginationType>(
label: 'Type',
options: ZetaPaginationType.values,
labelBuilder: (value) => value.name.split('.').last.toUpperCase(),
),
rounded: context.knobs.boolean(label: 'Rounded'),
disabled: context.knobs.boolean(label: 'Disabled'),
),
);
7 changes: 6 additions & 1 deletion example/windows/flutter/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,11 @@ include(${EPHEMERAL_DIR}/generated_config.cmake)
# https://github.com/flutter/flutter/issues/57146.
set(WRAPPER_ROOT "${EPHEMERAL_DIR}/cpp_client_wrapper")

# Set fallback configurations for older versions of the flutter tool.
if (NOT DEFINED FLUTTER_TARGET_PLATFORM)
set(FLUTTER_TARGET_PLATFORM "windows-x64")
endif()

# === Flutter Library ===
set(FLUTTER_LIBRARY "${EPHEMERAL_DIR}/flutter_windows.dll")

Expand Down Expand Up @@ -92,7 +97,7 @@ add_custom_command(
COMMAND ${CMAKE_COMMAND} -E env
${FLUTTER_TOOL_ENVIRONMENT}
"${FLUTTER_ROOT}/packages/flutter_tools/bin/tool_backend.bat"
windows-x64 $<CONFIG>
${FLUTTER_TARGET_PLATFORM} $<CONFIG>
VERBATIM
)
add_custom_target(flutter_assemble DEPENDS
Expand Down
Loading

0 comments on commit d782481

Please sign in to comment.