Skip to content

Commit

Permalink
Uses hooks instead of stateful components
Browse files Browse the repository at this point in the history
  • Loading branch information
martyfuhry committed Jan 31, 2024
1 parent bfab33f commit d21964c
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions mobile/lib/modules/memories/views/memory_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -16,19 +16,12 @@ class MemoryPage extends HookConsumerWidget {
final List<Memory> memories;
final int memoryIndex;

MemoryPage({
const MemoryPage({
required this.memories,
required this.memoryIndex,
super.key,
});

/// The list of all of the asset page controllers
late final memoryAssetPageControllers =
List.generate(memories.length, (i) => PageController());

/// The main vertically scrolling page controller with each list of memories
late final memoryPageController = PageController(initialPage: memoryIndex);

@override
Widget build(BuildContext context, WidgetRef ref) {
final currentMemory = useState(memories[memoryIndex]);
Expand All @@ -39,6 +32,13 @@ class MemoryPage extends HookConsumerWidget {
);
const bgColor = Colors.black;

/// The list of all of the asset page controllers
final memoryAssetPageControllers =
List.generate(memories.length, (i) => usePageController());

/// The main vertically scrolling page controller with each list of memories
final memoryPageController = usePageController(initialPage: memoryIndex);

// The Page Controller that scrolls horizontally with all of the assets
PageController currentMemoryAssetPageController =
memoryAssetPageControllers[currentMemoryIndex.value];
Expand Down

0 comments on commit d21964c

Please sign in to comment.