import 'package:fis_i18n/i18n.dart';
import 'package:fis_ui/index.dart';
import 'package:flutter/material.dart';
import 'package:flyinsono/managers/interfaces/entities/consultation_member.dart';

class MemberStatusView extends FStatelessWidget {
  final MemberStatus status;
  static final TextStyle _previewMemberTextStyle =
      TextStyle(color: Colors.grey);
  static final double _smallLivePreviewHeight = kIsMobile ? 100 : 210;
  MemberStatusView(this.status);

  @override
  FWidget build(BuildContext context) {
    switch (status) {
      case MemberStatus.Default:
        return _buildCallingText(i18nBook.college.notJoined.t);
      case MemberStatus.Calling:
        return _buildCallingText(i18nBook.realTimeConsultation.calling.t);
      case MemberStatus.Rejected:
        return _buildCallingText(i18nBook.realTimeConsultation.rejected.t);
      case MemberStatus.Left:
        return _buildCallingText(i18nBook.realTimeConsultation.hasLeft.t);
      case MemberStatus.Busyline:
        return _buildCallingText(i18nBook.realTimeConsultation.busy.t);
      case MemberStatus.Offline:
        return _buildCallingText(i18nBook.user.notOnline.t);
      case MemberStatus.Cancel:
        return _buildCallingText(i18nBook.realTimeConsultation.callCanceled.t);
      case MemberStatus.NetError:
        return _buildCallingText(i18nBook.common.networkInstability.t);
      default:
        return FSizedBox();
    }
  }

  ///呼叫中蒙层显示
  FWidget _buildCallingText(String content) {
    return FPositioned(
      left: 0,
      right: 0,
      top: 0,
      child: FContainer(
        height: _smallLivePreviewHeight,
        alignment: Alignment.center,
        decoration: BoxDecoration(
          gradient: LinearGradient(
            colors: [
              Colors.black.withOpacity(0.7),
              Colors.black.withOpacity(0.7),
            ],
            begin: Alignment.bottomCenter,
            end: Alignment.topCenter,
          ),
        ),
        child: FText(
          content,
          style: _previewMemberTextStyle,
        ),
      ),
    );
  }
}
