rluv_client/lib/features/notes/screens/notes_screen.dart

52 lines
1.6 KiB
Dart
Raw Normal View History

2023-07-22 21:29:32 -06:00
import 'package:flutter/material.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:helpers/helpers/misc_build/build_media.dart';
import '../../../global/store.dart';
class SharedNotesScreen extends ConsumerStatefulWidget {
const SharedNotesScreen({super.key, required this.initialData});
final Map<String, dynamic> initialData;
@override
ConsumerState<SharedNotesScreen> createState() => _SharedNotesScreenState();
}
class _SharedNotesScreenState extends ConsumerState<SharedNotesScreen> {
@override
Widget build(BuildContext context) {
final sharedNotes = ref.watch(Store().sharedNotesProvider);
return Column(
children: [
const Padding(
padding: EdgeInsets.all(18.0),
child: Text(
'Notes:',
style: TextStyle(fontSize: 20),
textAlign: TextAlign.center,
),
),
if (sharedNotes.isEmpty) const Text('Add notes to get started:'),
if (sharedNotes.isNotEmpty)
GridView.builder(
gridDelegate: const SliverGridDelegateWithFixedCrossAxisCount(
crossAxisCount: 2,
),
itemBuilder: (BuildContext context, int index) {
final note = sharedNotes[index];
return SizedBox(
width: BuildMedia(context).width * 0.4,
child: Card(
child: Padding(
padding: const EdgeInsets.all(8.0),
child: Text(note.content),
),
),
);
},
),
],
);
}
}