notificationView property

String notificationView

Implementation

static String get notificationView =>
    '''import 'package:flutter/material.dart';
import 'package:mega_commons/mega_commons.dart';
import 'package:mega_commons_dependencies/mega_commons_dependencies.dart';
import 'package:mega_features/mega_features.dart';

class NotificationView extends GetView<NotificationController> {
const NotificationView({super.key});

@override
Widget build(BuildContext context) {
  return Scaffold(
    appBar: AppBar(
      title: const Text('Notificações'),
    ),
    body: Obx(
      () => MegaContainerLoading(
        isLoading: controller.isLoadingDelete,
        textLoading: 'removendo notificação',
        child: Scaffold(
          body: SafeArea(
            child: Column(
              children: [
                Expanded(
                  child: Padding(
                    padding: const EdgeInsets.symmetric(horizontal: 20),
                    child: RefreshIndicator(
                      onRefresh: () => Future.sync(
                        () => controller.pagingController.refresh(),
                      ),
                      child: PagedListView<int, MegaNotification>(
                        pagingController: controller.pagingController,
                        builderDelegate: PagedChildBuilderDelegate(
                          animateTransitions: true,
                          transitionDuration:
                              const Duration(milliseconds: 500),
                          itemBuilder: (context, item, index) =>
                              ItemNotification(
                            notification: item,
                            removeNotification: () async {
                              await controller.removeNotification(item.id);
                            },
                          ),
                          firstPageErrorIndicatorBuilder: (context) =>
                              ErrorIndicator(
                            error: controller.pagingController.error,
                            onTryAgain: () =>
                                controller.pagingController.refresh(),
                          ),
                          noItemsFoundIndicatorBuilder: (context) =>
                              const EmptyListIndicator(
                            message: 'Sem notificações para exibir',
                          ),
                          firstPageProgressIndicatorBuilder: (context) =>
                              Column(
                            mainAxisAlignment: MainAxisAlignment.center,
                            children: [
                              SpinKitWave(
                                itemCount: 4,
                                itemBuilder: (_, int index) {
                                  return DecoratedBox(
                                    decoration: BoxDecoration(
                                      color: Get.theme.primaryColor,
                                    ),
                                  );
                                },
                                size: 20,
                              ),
                              const SizedBox(height: 10),
                              Text(
                                'Carregando Notificações...',
                                style: Get.textTheme.bodyText2,
                              )
                            ],
                          ),
                        ),
                      ),
                    ),
                  ),
                )
              ],
            ),
          ),
        ),
      ),
    ),
  );
}
}

class ItemNotification extends StatelessWidget {
const ItemNotification({
  super.key,
  required this.notification,
  required this.removeNotification,
});

final MegaNotification notification;
final Function() removeNotification;

@override
Widget build(BuildContext context) {
  return Padding(
    padding: const EdgeInsets.only(bottom: 10),
    child: Column(
      children: [
        Row(
          children: [
            Expanded(
              child: Column(
                crossAxisAlignment: CrossAxisAlignment.start,
                mainAxisSize: MainAxisSize.min,
                children: [
                  Text(
                    notification.created!.toDateHourMinute(),
                    style: const TextStyle(
                      color: Color(0x66000000),
                      fontSize: 13,
                    ),
                  ),
                  const SizedBox(height: 8),
                  Text(
                    notification.title ?? '',
                    style: const TextStyle(
                      color: Colors.black,
                      fontSize: 14,
                      fontFamily: 'SF Pro Text',
                      fontWeight: FontWeight.w700,
                    ),
                  ),
                  const SizedBox(height: 8),
                  Text(
                    notification.content ?? '',
                    style: const TextStyle(
                      color: Colors.black,
                      fontSize: 14,
                    ),
                  ),
                ],
              ),
            ),
            GestureDetector(
              onTap: () {
                MegaModal.showConfirmCancelModal(
                  context,
                  title: 'Deseja excluir esta notificação?',
                  onConfirmPressed: () {
                    Get.back();
                    removeNotification();
                  },
                );
              },
              child: const Icon(
                Icons.delete,
                color: Color(0x66000000),
              ),
            ),
          ],
        ),
        const SizedBox(height: 10),
        const Divider(
          color: Color(0x66000000),
          height: 1,
        ),
      ],
    ),
  );
}
}
''';