From 9d5e33da01dbb17799c4e1f8dc88a2c707c2518f Mon Sep 17 00:00:00 2001 From: sneurlax Date: Fri, 21 Jul 2023 18:21:15 -0500 Subject: [PATCH] DesktopOrdinalsList widget --- .../ordinals/desktop_ordinals_view.dart | 4 +- .../subwidgets/desktop_ordinals_list.dart | 49 +++++++++++++++++++ 2 files changed, 51 insertions(+), 2 deletions(-) create mode 100644 lib/pages_desktop_specific/ordinals/subwidgets/desktop_ordinals_list.dart diff --git a/lib/pages_desktop_specific/ordinals/desktop_ordinals_view.dart b/lib/pages_desktop_specific/ordinals/desktop_ordinals_view.dart index 46d732e3a..a50cc85db 100644 --- a/lib/pages_desktop_specific/ordinals/desktop_ordinals_view.dart +++ b/lib/pages_desktop_specific/ordinals/desktop_ordinals_view.dart @@ -14,7 +14,7 @@ import 'package:flutter_svg/svg.dart'; import 'package:stackwallet/models/isar/models/contact_entry.dart'; import 'package:stackwallet/pages/address_book_views/subviews/add_address_book_entry_view.dart'; import 'package:stackwallet/pages/address_book_views/subviews/address_book_filter_view.dart'; -import 'package:stackwallet/pages/ordinals/widgets/ordinals_list.dart'; +import 'package:stackwallet/pages_desktop_specific/ordinals/subwidgets/desktop_ordinals_list.dart'; import 'package:stackwallet/pages_desktop_specific/address_book_view/subwidgets/desktop_address_book_scaffold.dart'; import 'package:stackwallet/pages_desktop_specific/address_book_view/subwidgets/desktop_contact_details.dart'; import 'package:stackwallet/providers/global/address_book_service_provider.dart'; @@ -176,7 +176,7 @@ class _DesktopOrdinals extends ConsumerState { height: 16, ), Expanded( - child: OrdinalsList( + child: DesktopOrdinalsList( walletId: widget.walletId, ordinalsFuture: (_manager.wallet as OrdinalsInterface).getOrdinals(), ), diff --git a/lib/pages_desktop_specific/ordinals/subwidgets/desktop_ordinals_list.dart b/lib/pages_desktop_specific/ordinals/subwidgets/desktop_ordinals_list.dart new file mode 100644 index 000000000..f12fe6834 --- /dev/null +++ b/lib/pages_desktop_specific/ordinals/subwidgets/desktop_ordinals_list.dart @@ -0,0 +1,49 @@ +import 'package:flutter/material.dart'; +import 'package:stackwallet/models/ordinal.dart'; + +import 'package:stackwallet/pages/ordinals/widgets/ordinal_card.dart'; + +class DesktopOrdinalsList extends StatelessWidget { + const DesktopOrdinalsList({ + Key? key, + required this.walletId, + required this.ordinalsFuture, + }) : super(key: key); + + final String walletId; + final Future> ordinalsFuture; + + get spacing => 2.0; + + @override + Widget build(BuildContext context) { + return FutureBuilder>( + future: ordinalsFuture, + builder: (context, snapshot) { + if (snapshot.connectionState == ConnectionState.waiting) { + return const CircularProgressIndicator(); + } else if (snapshot.hasError) { + return Text('Error: ${snapshot.error}'); + } else if (snapshot.hasData) { + final List ordinals = snapshot.data!; + return GridView.builder( + shrinkWrap: true, + itemCount: ordinals.length, + gridDelegate: SliverGridDelegateWithFixedCrossAxisCount( + crossAxisSpacing: spacing as double, + mainAxisSpacing: spacing as double, + crossAxisCount: 4, + childAspectRatio: 6 / 7, // was 3/4, less data displayed now + ), + itemBuilder: (_, i) => OrdinalCard( + walletId: walletId, + ordinal: ordinals[i], + ), + ); + } else { + return const Text('No data found.'); + } + }, + ); + } +} \ No newline at end of file