import 'dart:convert';
import 'dart:typed_data';

import 'package:doctor_app_flutter/config/size_config.dart';
import 'package:flutter/material.dart';

import '../shared/app_texts_widget.dart';
import '../shared/rounded_container_widget.dart';

/* 
 *@author: ibrahim albitar 
 *@Date:28/4/2020  
 *@param: 
 *@return:
 *@desc:   
 */

class MedicineItemWidget extends StatefulWidget {
  final String label;
  final Color backgroundColor;
  final bool showBorder;
  final Color borderColor;
  final String url;

  MedicineItemWidget(
      {@required this.label,
      this.backgroundColor = Colors.white,
      this.showBorder = false,
      this.borderColor = Colors.white,
      this.url});
  @override
  _MedicineItemWidgetState createState() => _MedicineItemWidgetState();
}

class _MedicineItemWidgetState extends State<MedicineItemWidget> {
  @override
  Widget build(BuildContext context) {
    return new RoundedContainer(
      height: SizeConfig.heightMultiplier * 8,
      child: Padding(
        padding: const EdgeInsets.all(5.0),
        child: Row(
          crossAxisAlignment: CrossAxisAlignment.stretch,
          mainAxisAlignment: MainAxisAlignment.start,
          children: <Widget>[
            if (widget.url != null)
              Container(
                height: 39,
                width: 39,
                child: ClipRRect(
                  borderRadius: BorderRadius.all(Radius.circular(7)),
                  child: Image.network(
                    widget.url,
                    height: SizeConfig.imageSizeMultiplier * 15,
                    width: SizeConfig.imageSizeMultiplier * 15,
                    fit: BoxFit.cover,
                  ),
                ),
              ),
            Expanded(
                child: Padding(
                    padding: EdgeInsets.all(5),
                    child: Align(
                        alignment: Alignment.centerLeft,
                        child: AppText(widget.label))))
          ],
        ),
      ),
      backgroundColor: widget.backgroundColor,
      showBorder: widget.showBorder,
      borderColor: widget.borderColor,
      margin: EdgeInsets.all(4),
      raduis: 10,
    );
  }

  Image imageFromBase64String(String base64String) {
    return Image.memory(base64Decode(base64String));
  }

  Uint8List dataFromBase64String(String base64String) {
    return base64Decode(base64String);
  }

  String base64String(Uint8List data) {
    return base64Encode(data);
  }
}
