
import 'package:flutter/widgets.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:get/get_rx/src/rx_types/rx_types.dart';
import 'package:get/get_state_manager/src/rx_flutter/rx_obx_widget.dart';

import '../models/entities/CardInfo.dart';
import '../models/entities/ExtendContent.dart';

class ExtendContentList extends StatelessWidget {
  final List<ContentImageList> item;

  const ExtendContentList({ Key? key, required this.item }) : super(key: key);
  
  Widget? _image(String? content) {
    if (null == content || content.isEmpty) return null;
    return Image.network(content, fit: BoxFit.cover);
  }

  Widget? _text(String? content) {
    if (null == content || content.isEmpty) return null;
    return Text(content);
  }

  @override
  Widget build(BuildContext context) {
    //
    // List<Widget> _widgets = [];
    // Container(
    //   child: item.contentType == "image" ? _image(item.content) : _text(item.content),
    // );
    // for (var i = 0; i < item.length; i += 1) {
    //   if (i != 0 ) {
    //     _widgets.add(SizedBox(height: 20.w,));
    //   }
    //   var item = item[i];
    //   _widgets.add(Container(
    //     child: item.contentType == "image" ? _image(item.content) : _text(item.content),
    //   ));
    // }

    return  Container(
      child:  Column(
        children:  item.map((item) {
          if (item.contentType != 'image') {
            return Container(
              padding: EdgeInsets.fromLTRB(0, 20, 0, 10),
              width: 344.w,
              child: _text(item.content)
            );
          } else {
            return Container(
              padding: EdgeInsets.fromLTRB(0, 10, 0, 10),
              child: _image(item.content),
            );
          }
        }).toList(),
      ),
    );

  }

}
