PostLikes.dart

mail@pastecode.io avatar
unknown
plain_text
2 years ago
3.2 kB
1
Indexable
Never
import 'package:fancy_shimmer_image/fancy_shimmer_image.dart';
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:mobile/app/models/responses/get_all_provider_likes.dart';
import 'package:mobile/app/modules/account/controllers/posts_likes_controller.dart';
import 'package:mobile/app/modules/feed/controller/likes_controller.dart';

class PostLikes extends GetView<PostsLikesController> {
  Widget listItem(LikesItems e, BuildContext context) {
    return Container(
      margin: EdgeInsets.only(left: 10, right: 10, top: 10),
      child: Column(
        mainAxisAlignment: MainAxisAlignment.start,
        crossAxisAlignment: CrossAxisAlignment.start,
        children: [
          Row(
            mainAxisAlignment: MainAxisAlignment.start,
            children: [
              e.requesterUrl != null
                  ? ClipRRect(
                      borderRadius: new BorderRadius.circular(50.0),
                      child: CircleAvatar(
                        radius: 35,
                        child: FancyShimmerImage(
                          imageUrl: '${e.requesterUrl}',
                        ),
                      ),
                    )
                  : Image.asset(
                      'assets/img/def_user.jpg',
                      width: 80,
                      height: 80,
                    ),
              Expanded(
                child: Column(
                  mainAxisAlignment: MainAxisAlignment.start,
                  crossAxisAlignment: CrossAxisAlignment.start,
                  children: [
                    RichText(
                      text: TextSpan(
                        text: e.requesterName + "  ",
                        style: Get.textTheme.bodyText1.copyWith(
                            fontWeight: FontWeight.bold, fontSize: 14),
                      ),
                    ).paddingSymmetric(horizontal: 8),
                  ],
                ),
              ),
            ],
          ),
        ],
      ),
    );
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      backgroundColor: Colors.white,
      appBar: AppBar(
        iconTheme: IconThemeData(
          color: Colors.black, //change your color here
        ),
        backgroundColor: Colors.white,
        title: Text("Likes".tr,
            style:
                Get.textTheme.headline4.copyWith(fontWeight: FontWeight.w800)),
        centerTitle: true,
        elevation: 0,
      ),
      body: controller.likes.length > 0
          ? ListView.builder(
              padding: EdgeInsets.zero,
              itemCount: controller.likes.toSet().toList().length,
              itemBuilder: (context, index) {
                return listItem(
                    controller.likes.toSet().toList()[index], context);
              },
            )
          : Center(
              child: Text(
                "There is no Likes yet".tr,
                style: Get.theme.textTheme.headline5.merge(
                  TextStyle(
                      color: context.theme.hoverColor,
                      fontWeight: FontWeight.w600),
                ),
              ),
            ),
    );
  }
}