Untitled

 avatar
unknown
dart
3 years ago
5.0 kB
2
Indexable
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:iketfaa_delivery/App/Common/Models/Main/FollowPerson.dart';
import 'package:iketfaa_delivery/App/Common/Utilities/Constants/AppColors.dart';

class FollowersItem extends StatelessWidget {
  final FollowPerson followPerson;
  final VoidCallback? removeOnTap;
  final Widget button;

  FollowersItem(
      {required this.followPerson, required this.button, this.removeOnTap});

  @override
  Widget build(BuildContext context) {
    return removeOnTap == null
        ? getFollowerItem()
        : Dismissible(
            key: UniqueKey(),
            background: Container(
              color: AppColors.red,
              child: Center(
                child: Text(
                  'Remove'.tr,
                  style:
                      Get.textTheme.headline5!.copyWith(color: AppColors.white),
                ),
              ),
            ),
            onDismissed: (direction) {
              removeOnTap!();
            },
            child: getFollowerItem());
  }

  Widget getFollowerItem() {
    return Column(
      children: [
        Row(
          mainAxisAlignment: MainAxisAlignment.spaceBetween,
          children: [
            Expanded(
              child: Row(
                children: [
                  Container(
                    width: Get.width * 0.15,
                    height: Get.width * 0.15,
                    decoration: BoxDecoration(
                        shape: BoxShape.circle,
                        image: DecorationImage(
                            image: NetworkImage(
                              followPerson.requesterUrl!,
                            ),
                            fit: BoxFit.cover)),
                  ),
                  const SizedBox(
                    width: 16.0,
                  ),
                  Container(
                    width: Get.width * 0.5,
                    child: Text(
                      followPerson.requesterName!,
                      style: Get.textTheme.headline6,
                      maxLines: 5,
                    ),
                  )
                ],
              ),
            ),
            button
          ],
        ).paddingSymmetric(vertical: 8.0),
      ],
    );
  }
}


/*
CustomButton(
                                    width: Get.width * 0.25,
                                    background:
                                        controller.list[index].isfollow == true
                                            ? AppColors.white
                                            : AppColors.primary,
                                    text:
                                        controller.list[index].isfollow == true
                                            ? Text(
                                                'followed'.tr,
                                                style: Get.textTheme.headline6!
                                                    .copyWith(
                                                  color: AppColors.grey
                                                      .withOpacity(0.8),
                                                ),
                                              )
                                            : Text(
                                                'follow'.tr,
                                                style: Get.textTheme.headline6!
                                                    .copyWith(
                                                  color: AppColors.white,
                                                ),
                                              ),
                                    borderRadius: AppStyles.borderRadius * 2.0,
                                    padding: const EdgeInsets.all(8.0),
                                    shadow: true,
                                    border: controller.list[index].isfollow ==
                                            true
                                        ? Border.all(color: AppColors.primary)
                                        : null,
                                    onTap: () async {
                                      controller.list[index].isfollow =
                                          !(controller.list[index].isfollow!);

                                      bool result = await controller
                                          .authManager.api
                                          .followUser(controller
                                              .list[index].requesterId!);

                                      print(result);

                                      if (!result) {
                                        controller.list[index].isfollow =
                                            !(controller.list[index].isfollow!);
                                      }
                                    }),
                             

*/