import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:get/get.dart';

import '../../../../library/library.dart';
import '../../../app.dart';
import 'product_about_widget.dart';
import 'product_characteristics.dart';
import 'product_review.dart';

class ProductSpecificationsWidget extends StatelessWidget {
  final ProductModel model;

  ProductSpecificationsWidget({required this.model});

  @override
  Widget build(BuildContext context) {
    return GetBuilder<ProductController>(
      init: ProductController(model),
      builder: (pc) => DefaultTabController(
        length: 3,
        child: Scaffold(
          // backgroundColor: Colors.red,
          appBar: AppBar(
            bottom: PreferredSize(
              preferredSize: Size.fromHeight(4.0),
              child: Stack(
                fit: StackFit.passthrough,
                alignment: Alignment.bottomCenter,
                children: [
                  Container(
                    height: 3,
                    decoration: new BoxDecoration(
                      color: ThemeColor.colorE5E5E5,
                      borderRadius: BorderRadius.all(Radius.circular(4)),
                    ),
                  ),
                  TabBar(
                    onTap: (index) => pc.onTapChange(index),
                    labelColor: ThemeColor.color3A3A3A,
                    labelPadding: EdgeInsets.symmetric(horizontal: 30.w),
                    labelStyle: new TextStyle(
                      color: ThemeColor.color3A3A3A,
                      fontSize: 12.sp,
                      fontWeight: FontWeight.bold,
                    ),
                    indicatorColor: ThemeColor.mainColor,
                    isScrollable: true,
                    indicator: MaterialIndicator(
                      color: ThemeColor.mainColor,
                      strokeWidth: 3,
                      topLeftRadius: 4,
                      topRightRadius: 4,
                      bottomLeftRadius: 4,
                      bottomRightRadius: 4,
                      height: 3,
                    ),
                    tabs: [
                      Tab(text: 'about_product'.tr),
                      Tab(text: 'specifications'.tr),
                      Tab(text: 'reviews'.tr),
                    ],
                  ),
                ],
              ),
            ),
          ),
          body: TabBarView(
            children: [
              ProductAboutWidget(model: model),
              ProductCharacteristicsWidget(model: model, pc: pc),
              ProductReviewWidget(model: model),
            ],
          ),
        ),
      ),
    );
  }
}
