renderActions method

List renderActions()

Implementation

List<Widget> renderActions() {
  final hasFilters = ref.watch(hasRoomFilters);
  if (_isSearchVisible) {
    return [
      Padding(
        padding: const EdgeInsets.only(right: 8.0),
        child: Row(
          mainAxisAlignment: MainAxisAlignment.end,
          children: [
            TextButton(
              key: RoomsListWidget.closeSearchActionButtonKey,
              onPressed: () {
                setState(() => _isSearchVisible = false);
              },
              child: Text(L10n.of(context).close),
            ),
          ],
        ),
      ),
    ];
  }
  return [
    if (!hasFilters)
      IconButton(
        key: RoomsListWidget.openSearchActionButtonKey,
        onPressed: () {
          setState(() {
            _isSearchVisible = true;
            searchFocus.requestFocus();
          });
        },
        padding: const EdgeInsets.only(right: 10, left: 5),
        icon: const Icon(Atlas.magnifying_glass),
      ),
    if (hasFilters)
      IconButton(
        key: RoomsListWidget.openSearchActionButtonKey,
        onPressed: () {
          setState(() => _isSearchVisible = true);
        },
        padding: const EdgeInsets.only(right: 10, left: 5),
        icon: Badge(
          backgroundColor: Theme.of(context).colorScheme.badgeImportant,
          child: const Icon(Atlas.filter_thin),
        ),
      ),
    PlusIconWidget(
      onPressed: () => context.pushNamed(Routes.createChat.name),
    ),
  ];
}