import 'package:flutter/material.dart';
import 'package:initial_folder/providers/counter_qna_like_provider.dart';
import 'package:initial_folder/widgets/counter_qna_like.dart';
import 'package:provider/provider.dart';

import '../theme.dart';

class CounterQnaLikePage extends StatelessWidget {
  const CounterQnaLikePage({Key? key, required this.idQna}) : super(key: key);

  final idQna;

  @override
  Widget build(BuildContext context) {
    return ChangeNotifierProvider(
      create: (context) => CounterQnaLikeProvider(idQna: idQna),
      child: Consumer<CounterQnaLikeProvider>(builder: (context, state, _) {
        if (state.state == ResultState.loading) {
          print(idQna);
          return Center(
            child: CircularProgressIndicator(
              color: primaryColor,
              strokeWidth: 2,
            ),
          );
        } else if (state.state == ResultState.noData) {
          return Center(
            child: Text(
              'TIDAK ADA',
              style: thirdTextStyle,
            ),
          );
        } else if (state.state == ResultState.hasData) {
          var counterQna = state.result!.data;

          return CounterQnaLike(
            counterLike: counterQna,
          );
          // var counterQna = state.result!.data;
          // return CounterQnaComment(
          //   counterComment: counterQna,
          // );
        } else if (state.state == ResultState.error) {
          return Center(
              child: Column(
            children: [
              Text(
                'Terjadi Kesalahan Coba Lagi',
                style: thirdTextStyle,
              ),
            ],
          ));
        }
        return Center(
          child: Text(
            'Terjadi Kesalahan',
            style: thirdTextStyle,
          ),
        );
      }),
    );
  }
}
