-
-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Parent space list on click of spaces badge
- Loading branch information
1 parent
bea1581
commit 7f8bbb6
Showing
6 changed files
with
104 additions
and
22 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
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,75 @@ | ||
import 'package:acter/common/providers/room_providers.dart'; | ||
import 'package:acter/common/widgets/spaces/space_card.dart'; | ||
import 'package:flutter_gen/gen_l10n/l10n.dart'; | ||
import 'package:flutter/material.dart'; | ||
import 'package:flutter_riverpod/flutter_riverpod.dart'; | ||
import 'package:logging/logging.dart'; | ||
import 'package:skeletonizer/skeletonizer.dart'; | ||
|
||
final _log = Logger('a3::space::parent-space-list'); | ||
|
||
Future<void> showParentSpaceList( | ||
BuildContext context, | ||
String roomId, | ||
) async { | ||
showModalBottomSheet( | ||
context: context, | ||
showDragHandle: true, | ||
useSafeArea: true, | ||
isScrollControlled: true, | ||
constraints: const BoxConstraints(maxHeight: 450), | ||
builder: (context) { | ||
return ParentSpaceList(roomId: roomId); | ||
}, | ||
); | ||
} | ||
|
||
class ParentSpaceList extends ConsumerWidget { | ||
final String roomId; | ||
|
||
const ParentSpaceList({ | ||
super.key, | ||
required this.roomId, | ||
}); | ||
|
||
@override | ||
Widget build(BuildContext context, WidgetRef ref) { | ||
final parentSpaceListData = ref.watch(parentIdsProvider(roomId)); | ||
return parentSpaceListData.when( | ||
data: (spaceList) => spaceListUI(context, spaceList), | ||
error: (e, s) { | ||
_log.severe('Failed to load space', e, s); | ||
return Text(L10n.of(context).errorLoadingSpaces(e)); | ||
}, | ||
loading: () => const Skeletonizer( | ||
child: SizedBox(height: 100, width: 100), | ||
), | ||
); | ||
} | ||
|
||
Widget spaceListUI(BuildContext context, List<String> spaceList) { | ||
return Column( | ||
children: [ | ||
Text( | ||
L10n.of(context).parentSpaces, | ||
style: Theme.of(context).textTheme.titleMedium, | ||
), | ||
const SizedBox(height: 10), | ||
Expanded( | ||
child: ListView.builder( | ||
shrinkWrap: true, | ||
itemCount: spaceList.length, | ||
itemBuilder: (context, index) { | ||
final roomId = spaceList[index]; | ||
return SpaceCard( | ||
key: Key('limited-space-list-item-$roomId'), | ||
roomId: roomId, | ||
showParents: true, | ||
); | ||
}, | ||
), | ||
), | ||
], | ||
); | ||
} | ||
} |
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