buildTitle method

Widget buildTitle(
  1. ValueNotifier<List> selectedList,
  2. ValueNotifier<List<PlatformFile>> listFiles,
  3. ValueNotifier<bool> isSelecting
)

Implementation

Widget buildTitle(
    ValueNotifier<List> selectedList,
    ValueNotifier<List<PlatformFile>> listFiles,
    ValueNotifier<bool> isSelecting) {
  return isSelecting.value
      ? Row(
          // mainAxisAlignment: MainAxisAlignment.spaceBetween,
          children: [
            const SizedBox(width: 10),
            HMIconButton(
                onPressed: () {
                  selectedList.value = [];
                  isSelecting.value = false;
                },
                size: HMIconButtonSize.sm,
                icon: const Icon(Icons.close_rounded),
                iconColor: Colors.black),
            Expanded(
              child: Padding(
                padding: const EdgeInsets.only(left: 20),
                child: Text(
                  '${selectedList.value.length} selected',
                  style: const TextStyle(
                      fontSize: 18, fontWeight: FontWeight.bold),
                ),
              ),
            ),
            HMIconButton(
                onPressed: () {
                  if (selectedList.value.length != listFiles.value.length ||
                      selectedList.value.isEmpty) {
                    selectedList.value = List.from(listFiles.value);
                  } else {
                    selectedList.value = [];
                  }
                },
                size: HMIconButtonSize.sm,
                icon: const Icon(Icons.select_all_rounded),
                iconColor: Colors.black),
            const SizedBox(width: 20),
            HMIconButton(
                disabled: selectedList.value.isEmpty,
                onPressed: () {
                  List<PlatformFile> a = List.from(listFiles.value);
                  for (int i = 0; i < selectedList.value.length; i++) {
                    a.remove(selectedList.value[i]);
                  }
                  listFiles.value = a;
                  selectedList.value = [];
                  isSelecting.value = false;
                  onEditingFile(listFiles.value);
                },
                size: HMIconButtonSize.sm,
                icon: const Icon(Icons.delete),
                iconColor: Colors.black),
            const SizedBox(width: 10),
          ],
        )
      : Row(
          children: [
            const Expanded(
              child: Center(
                child: Text(
                  'Selected Files',
                  style: TextStyle(fontSize: 18, fontWeight: FontWeight.bold),
                ),
              ),
            ),
            HMIconButton(
              onPressed: () {
                isSelecting.value = true;
              },
              disabled: listFiles.value.isEmpty,
              size: HMIconButtonSize.sm,
              icon: const Icon(Icons.highlight_alt),
              iconColor: Colors.black,
            ),
            const SizedBox(width: 20),
          ],
        );
}