Untitled

mail@pastecode.io avatar
unknown
plain_text
a year ago
8.2 kB
0
Indexable
Never
import 'package:barcode_scanner_example/component/product_detail_component.dart';
import 'package:barcode_scanner_example/model/cosmetic_model.dart';
import 'package:barcode_scanner_example/utils/colors.dart';
import 'package:barcode_scanner_example/utils/widgets.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';

class CosmeticsDetailScreen extends StatefulWidget {
  final CosmeticModel? cosmeticData;

  const CosmeticsDetailScreen({Key? key,this.cosmeticData}) : super(key: key);

  @override
  State<CosmeticsDetailScreen> createState() => _CosmeticsDetailScreenState();
}

class _CosmeticsDetailScreenState extends State<CosmeticsDetailScreen> {
  bool favoriteCheck = false;

  Widget _tabSection(BuildContext context) {
    return DefaultTabController(
      length: 3,
      child: SingleChildScrollView(
        child: Column(
          mainAxisSize: MainAxisSize.min,
          children: [
            TabBar(
              labelColor: Colors.black,
              padding: EdgeInsets.zero,
              unselectedLabelColor: Colors.grey,
              labelStyle: TextStyle(fontWeight: FontWeight.bold, fontSize: 14),
              indicatorWeight: 3,
              indicatorColor: productBgColor,
              indicatorSize: TabBarIndicatorSize.label,
              tabs: [
                Tab(text: "Ingredients"),
                Tab(text: "Reviews"),
                Tab(text: "Alternatives"),
              ],
            ),
            SizedBox(height: 24),
            Container(
              height: MediaQuery.of(context).size.height,
              child: TabBarView(
                children: [
                  ProductDetailComponent(),
                  ProductDetailComponent(),
                  ProductDetailComponent(),
                ],
              ),
            ),
          ],
        ),
      ),
    );
  }

  @override
  void initState() {
    super.initState();
    SystemChrome.setSystemUIOverlayStyle(SystemUiOverlayStyle.light.copyWith(
      statusBarColor: Colors.transparent,
    ));
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      backgroundColor: mainBgColor,
      body: Stack(
        clipBehavior: Clip.none,
        children: [
          Column(
            children: [
              Padding(
                padding: EdgeInsets.only(left: 22, right: 22, top: 50),
                child: Row(
                  mainAxisAlignment: MainAxisAlignment.spaceBetween,
                  children: [
                    InkWell(
                      onTap: () {
                        Navigator.pop(context);
                      },
                      child: Container(
                        padding: EdgeInsets.all(8),
                        decoration: BoxDecoration(
                          color: Colors.white,
                          shape: BoxShape.circle,
                        ),
                        child: Icon(Icons.close),
                      ),
                    ),
                    InkWell(
                      onTap: () {
                        setState(() {
                          favoriteCheck = !favoriteCheck;
                        });
                        print(favoriteCheck);
                      },
                      child: Container(
                        padding: EdgeInsets.all(8),
                        decoration: BoxDecoration(
                          color: Colors.white,
                          shape: BoxShape.circle,
                        ),
                        child: Icon(
                          favoriteCheck
                              ? Icons.favorite
                              : Icons.favorite_border_rounded,
                          color: favoriteCheck ? Colors.red : Colors.black,
                        ),
                      ),
                    ),
                  ],
                ),
              ),
              Stack(
                alignment: Alignment.bottomCenter,
                clipBehavior: Clip.none,
                children: [
                  Center(
                    child: Container(
                      margin: EdgeInsets.only(top: 20),
                      alignment: Alignment.center,
                      decoration: BoxDecoration(
                        color: productBgColor.withOpacity(0.8),
                        shape: BoxShape.circle,
                      ),
                      height: 180,
                      width: 180,
                    ),
                  ),
                  Positioned(
                    top: -20,
                    child: Image.asset(
                      widget.cosmeticData!.cosmeticImage.toString(),
                      fit: BoxFit.cover,
                      height: 250,
                    ),
                  ),
                ],
              ),
              SizedBox(height: 45),
              Row(
                mainAxisAlignment: MainAxisAlignment.spaceEvenly,
                children: [
                  cosmeticType(
                    typeImage: 'images/leaf.png',
                    cosmeticTypeName: "VEGAN",
                  ),
                  SizedBox(width: 24),
                  cosmeticType(
                    typeImage: 'images/silicon.png',
                    cosmeticTypeName: "SILICONE FREE",
                  ),
                  SizedBox(width: 24),
                  cosmeticType(
                    typeImage: 'images/recycle.png',
                    cosmeticTypeName: "RECYCABLE",
                  ),
                ],
              ),
            ],
          ),
          Container(
            // height: MediaQuery.of(context).size.height,
            margin: EdgeInsets.only(
              top: MediaQuery.of(context).size.height * 0.45,
            ),
            decoration: BoxDecoration(
              color: Colors.white,
              borderRadius: BorderRadius.only(
                topLeft: Radius.circular(24),
                topRight: Radius.circular(24),
              ),
            ),
            child: SingleChildScrollView(
              child: Column(
                children: [
                  Padding(
                    padding: EdgeInsets.all(24.0),
                    child: Row(
                      mainAxisAlignment: MainAxisAlignment.spaceBetween,
                      children: [
                        Column(
                          crossAxisAlignment: CrossAxisAlignment.start,
                          children: [
                            Text(
                              'The Ordinary',
                              style: TextStyle(
                                fontWeight: FontWeight.normal,
                                color: Colors.grey,
                              ),
                            ),
                            SizedBox(height: 8),
                            Text(
                              'Hyaluronic acid serum',
                              style: TextStyle(
                                  fontWeight: FontWeight.bold, fontSize: 22),
                            ),
                          ],
                        ),
                        Container(
                          decoration: BoxDecoration(
                            color: productBgColor,
                            borderRadius: BorderRadius.all(Radius.circular(8)),
                          ),
                          padding: EdgeInsets.all(16),
                          child: Text(
                            '4/5',
                            style: TextStyle(
                              fontWeight: FontWeight.bold,
                              color: Colors.white,
                            ),
                          ),
                        ),
                      ],
                    ),
                  ),
                  _tabSection(context),
                ],
              ),
            ),
          )
        ],
      ),
    );
  }
}