Untitled

mail@pastecode.io avatar
unknown
dart
8 days ago
33 kB
2
Indexable
Never
import 'package:clean_architecture_tdd_flutter_template/core/common/widgets/app_bar_detail.dart';
import 'package:clean_architecture_tdd_flutter_template/core/res/media_res.dart';
import 'package:clean_architecture_tdd_flutter_template/src/find/presentation/domain/entities/charger.dart';
import 'package:clean_architecture_tdd_flutter_template/src/find/presentation/domain/entities/user_review_request.dart';
import 'package:clean_architecture_tdd_flutter_template/src/find/presentation/views/review_screen.dart';
import 'package:clean_architecture_tdd_flutter_template/src/find/presentation/widgets/expansion_tile_charger.dart';
import 'package:flutter/material.dart';
import 'package:flutter_svg/flutter_svg.dart';
import 'package:google_maps_flutter/google_maps_flutter.dart';
import '../../../../core/res/colours.dart';
import '../domain/entities/charger_station.dart';

class ChargerstationDetail extends StatefulWidget {
  const ChargerstationDetail({super.key});
  static const routeName = '/chargerstation_detail';
  @override
  State<ChargerstationDetail> createState() => _ChargerstationDetailState();
}

class _ChargerstationDetailState extends State<ChargerstationDetail> {
  final PageController controller = PageController(initialPage: 0);

  @override
  void dispose() {
    controller.dispose();
    super.dispose();
  }

  final ChargerStation chargerstation = const ChargerStation(
    id: 1,
    name: 'Pakubuwono Residence 2nd Floor',
    location: 'Kebayoran Baru, South Jakarta',
    score: '5',
    reviews: 'blablabla',
    powerRate: '11.66 kWh',
    chargingCost: 'Rp10.000/hour',
    parkingCost: 'Rp8.000/hour',
    reviewers: '(99 reviews)',
    info: 'Lorem ipsum dolor sit amet, ......',
    chargers: [charger1, charger2, charger3],
    latlng: LatLng(37.42796133580664, 122.01),
  );

  static const Charger charger1 = Charger(
    name: 'Charger A',
    id: 1,
    chargerType: 'Type 1',
    chargerStatus: 'Available',
  );

  static const Charger charger2 = Charger(
    id: 1,
    name: 'Charger B',
    chargerType: 'Type 1',
    chargerStatus: 'Available',
  );

  static const Charger charger3 = Charger(
    id: 1,
    name: 'Charger C',
    chargerType: 'Type 1',
    chargerStatus: 'Available',
  );

  static const UserReview user1 = UserReview(
    name: 'You',
    time: 'January 24, 2024  20:00',
    review:
        'Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.',
  );

  int parseToInt(String str) {
    int result = int.parse(str);
    return result;
  }

  double value = 0;

  @override
  Widget build(BuildContext context) {
    return Scaffold(
        body: Column(children: [
      Column(
        children: [
          Stack(children: [
            Image.asset(
              MediaRes.chargerstationDetailBackground,
              fit: BoxFit.cover,
              width: MediaQuery.of(context).size.width,
            ),
            const AppBarDetail(title: ''),
          ]),
          Container(
            height: MediaQuery.of(context).size.height * 0.32,
            decoration: const BoxDecoration(
                color: Colors.white,
                borderRadius: BorderRadius.only(
                  topLeft: Radius.circular(30),
                  topRight: Radius.circular(30),
                )),
            child: Container(
              padding: const EdgeInsets.symmetric(vertical: 20, horizontal: 24),
              child: Column(
                mainAxisSize: MainAxisSize.max,
                children: [
                  Column(
                    children: [
                      SizedBox(
                        width: MediaQuery.of(context).size.width * 0.89,
                        height: MediaQuery.of(context).size.height * 0.125,
                        child: Column(
                          mainAxisAlignment: MainAxisAlignment.spaceAround,
                          children: [
                            Row(
                              mainAxisAlignment: MainAxisAlignment.spaceBetween,
                              children: [
                                Column(
                                  crossAxisAlignment: CrossAxisAlignment.start,
                                  children: [
                                    Text(
                                      chargerstation.name,
                                      style: const TextStyle(
                                          fontSize: 18,
                                          fontFamily: 'Poppins',
                                          fontWeight: FontWeight.w800,
                                          color: Colours.blackColour),
                                    ),
                                    Padding(
                                      padding: const EdgeInsets.only(top: 5.0),
                                      child: Row(
                                        children: [
                                          SvgPicture.asset(
                                            MediaRes.locationIcon,
                                            width: 15,
                                          ),
                                          const SizedBox(
                                            width: 10,
                                          ),
                                          Text(
                                            chargerstation.location,
                                            style: const TextStyle(
                                                fontSize: 14,
                                                fontFamily: 'Poppins',
                                                fontWeight: FontWeight.bold,
                                                color: Colours
                                                    .secondaryColourDisabled),
                                          )
                                        ],
                                      ),
                                    ),
                                  ],
                                ),
                              ],
                            ),
                            Row(
                              mainAxisAlignment: MainAxisAlignment.spaceBetween,
                              children: [
                                Text(
                                  '${chargerstation.score}.0',
                                  style: const TextStyle(
                                    color: Colours.blackColour,
                                    fontWeight: FontWeight.w800,
                                  ),
                                ),
                                SingleChildScrollView(
                                  scrollDirection: Axis.horizontal,
                                  child: Row(
                                    children: List.generate(
                                        parseToInt(chargerstation.score),
                                        (index) {
                                      return Column(
                                        children: [
                                          SvgPicture.asset(MediaRes.starIcon)
                                        ],
                                      );
                                    }),
                                  ),
                                ),
                                Text(
                                  chargerstation.reviewers,
                                  style: const TextStyle(
                                    color: Colours.secondaryColourDisabled,
                                    fontWeight: FontWeight.w600,
                                  ),
                                ),
                                const SizedBox(
                                  width: 80,
                                ),
                              ],
                            ),
                          ],
                        ),
                      ),
                      const SizedBox(
                        height: 10,
                      ),
                      const Divider(
                        color: Colours.secondaryColourDisabled,
                      ),
                      const SizedBox(
                        height: 10,
                      ),
                      SvgPicture.asset(MediaRes.contohIcon),
                      //
                      const Divider(
                        color: Colours.secondaryColourDisabled,
                      ),
                      Padding(
                        padding: const EdgeInsets.only(right: 20, left: 20),
                        child: Row(
                          mainAxisAlignment: MainAxisAlignment.spaceBetween,
                          children: [
                            TextButton(
                              onPressed: () {
                                controller.animateToPage(0,
                                    duration: const Duration(milliseconds: 1),
                                    curve: Curves.linear);
                              },
                              child: const Padding(
                                padding: EdgeInsets.only(left: 10),
                                child: Text(
                                  'Info',
                                  style: TextStyle(
                                    fontSize: 18,
                                    fontWeight: FontWeight.w700,
                                    color: Colours.secondaryColour,
                                  ),
                                ),
                              ),
                            ),
                            TextButton(
                              onPressed: () {
                                controller.animateToPage(1,
                                    duration: const Duration(milliseconds: 1),
                                    curve: Curves.linear);
                              },
                              child: const Padding(
                                padding: EdgeInsets.only(left: 10),
                                child: Text(
                                  'Chargers',
                                  style: TextStyle(
                                    fontSize: 18,
                                    fontWeight: FontWeight.w700,
                                    color: Colours.secondaryColour,
                                  ),
                                ),
                              ),
                            ),
                            TextButton(
                              onPressed: () {
                                controller.animateToPage(2,
                                    duration: const Duration(milliseconds: 1),
                                    curve: Curves.linear);
                              },
                              child: const Padding(
                                padding: EdgeInsets.only(left: 10),
                                child: Text(
                                  'Review',
                                  style: TextStyle(
                                    fontSize: 18,
                                    fontWeight: FontWeight.w700,
                                    color: Colours.secondaryColour,
                                  ),
                                ),
                              ),
                            ),
                          ],
                        ),
                      ),
                      const Divider(
                        color: Colours.secondaryColourDisabled,
                      ),
                    ],
                  ),
                ],
              ),
            ),
          ),
        ],
      ),
      Column(children: [
        SizedBox(
          height: MediaQuery.of(context).size.height * 0.32,
          width: MediaQuery.of(context).size.width * 0.88,
          child: PageView(
            controller: controller,
            children: [
              const SingleChildScrollView(
                child: Column(
                  children: [
                    Padding(
                      padding: EdgeInsets.only(left: 20, right: 20),
                      child: Text(
                          'Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum'),
                    ),
                    SizedBox(
                      height: 10,
                    ),
                    Divider(
                      color: Colours.secondaryColourDisabled,
                    ),
                  ],
                ),
              ),
              SingleChildScrollView(
                child: Column(
                  children: [
                    Padding(
                      padding: const EdgeInsets.only(top: 20),
                      child:
                          ExpansionTileCharger(title: 'Charger A', children: [
                        const SizedBox(
                          height: 20,
                        ),
                        Padding(
                          padding: const EdgeInsets.only(left: 10, right: 10),
                          child: Row(
                              mainAxisAlignment: MainAxisAlignment.spaceBetween,
                              children: [
                                Row(
                                  // mainAxisAlignment: ,
                                  children: [
                                    SvgPicture.asset(MediaRes.electricIcon),
                                    const SizedBox(
                                      width: 7,
                                    ),
                                    Text(
                                      chargerstation.powerRate,
                                      style: const TextStyle(
                                        color: Colours.secondaryColourDisabled,
                                        fontWeight: FontWeight.w600,
                                      ),
                                    ),
                                  ],
                                ),
                                Row(
                                  children: [
                                    SvgPicture.asset(MediaRes.moneyIcon),
                                    const SizedBox(
                                      width: 7,
                                    ),
                                    Text(
                                      chargerstation.chargingCost,
                                      style: const TextStyle(
                                        color: Colours.secondaryColourDisabled,
                                        fontWeight: FontWeight.w600,
                                      ),
                                    ),
                                  ],
                                ),
                                Row(
                                  children: [
                                    SvgPicture.asset(MediaRes.parkingIcon),
                                    const SizedBox(
                                      width: 7,
                                    ),
                                    Text(
                                      chargerstation.parkingCost,
                                      style: const TextStyle(
                                        color: Colours.secondaryColourDisabled,
                                        fontWeight: FontWeight.w600,
                                      ),
                                    ),
                                  ],
                                ),
                              ]),
                        ),
                        const SizedBox(
                          height: 20,
                        ),
                      ]),
                    ),
                    Padding(
                      padding: const EdgeInsets.only(top: 20),
                      child:
                          ExpansionTileCharger(title: 'Charger A', children: [
                        const SizedBox(
                          height: 20,
                        ),
                        Padding(
                          padding: const EdgeInsets.only(left: 10, right: 10),
                          child: Row(
                              mainAxisAlignment: MainAxisAlignment.spaceBetween,
                              children: [
                                Row(
                                  // mainAxisAlignment: ,
                                  children: [
                                    SvgPicture.asset(MediaRes.electricIcon),
                                    const SizedBox(
                                      width: 7,
                                    ),
                                    Text(
                                      chargerstation.powerRate,
                                      style: const TextStyle(
                                        color: Colours.secondaryColourDisabled,
                                        fontWeight: FontWeight.w600,
                                      ),
                                    ),
                                  ],
                                ),
                                Row(
                                  children: [
                                    SvgPicture.asset(MediaRes.moneyIcon),
                                    const SizedBox(
                                      width: 7,
                                    ),
                                    Text(
                                      chargerstation.chargingCost,
                                      style: const TextStyle(
                                        color: Colours.secondaryColourDisabled,
                                        fontWeight: FontWeight.w600,
                                      ),
                                    ),
                                  ],
                                ),
                                Row(
                                  children: [
                                    SvgPicture.asset(MediaRes.parkingIcon),
                                    const SizedBox(
                                      width: 7,
                                    ),
                                    Text(
                                      chargerstation.parkingCost,
                                      style: const TextStyle(
                                        color: Colours.secondaryColourDisabled,
                                        fontWeight: FontWeight.w600,
                                      ),
                                    ),
                                  ],
                                ),
                              ]),
                        ),
                        const SizedBox(
                          height: 20,
                        ),
                      ]),
                    ),
                    Padding(
                      padding: const EdgeInsets.only(top: 20),
                      child:
                          ExpansionTileCharger(title: 'Charger A', children: [
                        const SizedBox(
                          height: 20,
                        ),
                        Padding(
                          padding: const EdgeInsets.only(left: 10, right: 10),
                          child: Row(
                              mainAxisAlignment: MainAxisAlignment.spaceBetween,
                              children: [
                                Row(
                                  // mainAxisAlignment: ,
                                  children: [
                                    SvgPicture.asset(MediaRes.electricIcon),
                                    const SizedBox(
                                      width: 7,
                                    ),
                                    Text(
                                      chargerstation.powerRate,
                                      style: const TextStyle(
                                        color: Colours.secondaryColourDisabled,
                                        fontWeight: FontWeight.w600,
                                      ),
                                    ),
                                  ],
                                ),
                                Row(
                                  children: [
                                    SvgPicture.asset(MediaRes.moneyIcon),
                                    const SizedBox(
                                      width: 7,
                                    ),
                                    Text(
                                      chargerstation.chargingCost,
                                      style: const TextStyle(
                                        color: Colours.secondaryColourDisabled,
                                        fontWeight: FontWeight.w600,
                                      ),
                                    ),
                                  ],
                                ),
                                Row(
                                  children: [
                                    SvgPicture.asset(MediaRes.parkingIcon),
                                    const SizedBox(
                                      width: 7,
                                    ),
                                    Text(
                                      chargerstation.parkingCost,
                                      style: const TextStyle(
                                        color: Colours.secondaryColourDisabled,
                                        fontWeight: FontWeight.w600,
                                      ),
                                    ),
                                  ],
                                ),
                              ]),
                        ),
                        const SizedBox(
                          height: 20,
                        ),
                      ]),
                    ),
                  ],
                ),
              ),
              SingleChildScrollView(
                child: Column(
                  crossAxisAlignment: CrossAxisAlignment.start,
                  children: [
                    Padding(
                      padding: const EdgeInsets.only(left: 20, right: 20),
                      child: Column(
                        children: [
                          Row(
                            mainAxisAlignment: MainAxisAlignment.start,
                            children: [
                              SizedBox(
                                width: 60,
                                height: 60,
                                child: Image.asset(
                                  MediaRes.userImage,
                                  fit: BoxFit.cover,
                                ),
                              ),
                              Padding(
                                padding: const EdgeInsets.only(left: 20),
                                child: Column(
                                  crossAxisAlignment: CrossAxisAlignment.start,
                                  children: [
                                    Text(
                                      user1.name,
                                      style: const TextStyle(
                                        color: Colours.blackColour,
                                        fontWeight: FontWeight.w800,
                                        fontSize: 20,
                                      ),
                                    ),
                                    Text(
                                      user1.time,
                                      style: const TextStyle(
                                        color: Colours.secondaryColourDisabled,
                                        fontWeight: FontWeight.w600,
                                      ),
                                    ),
                                  ],
                                ),
                              ),
                            ],
                          ),
                          const SizedBox(
                            height: 20,
                          ),
                          Text(
                            user1.review,
                            style: const TextStyle(
                              color: Colours.blackColour,
                              fontWeight: FontWeight.w600,
                            ),
                          )
                        ],
                      ),
                    ),
                    const SizedBox(
                      height: 20,
                    ),
                    InkWell(
                      onTap: () {
                        Navigator.of(context).pushNamed(ReviewScreen.routeName);
                      },
                      child: const Text(
                        'Write feedback (Edit feedback)',
                        style: TextStyle(
                          color: Colours.secondaryColour,
                          fontWeight: FontWeight.w600,
                        ),
                      ),
                    ),
                    const SizedBox(
                      height: 20,
                    ),
                    Padding(
                      padding: const EdgeInsets.only(left: 20, right: 20),
                      child: Row(
                        mainAxisAlignment: MainAxisAlignment.spaceBetween,
                        children: [
                          Column(
                            children: [
                              Text(
                                '${chargerstation.score}.0',
                                style: const TextStyle(
                                  color: Colours.secondaryColourDisabled,
                                  fontWeight: FontWeight.w400,
                                  fontSize: 80,
                                ),
                              ),
                              Row(
                                children: List.generate(
                                    parseToInt(chargerstation.score), (index) {
                                  return Column(
                                    children: [
                                      SvgPicture.asset(MediaRes.starIcon)
                                    ],
                                  );
                                }),
                              ),
                              const SizedBox(
                                height: 10,
                              ),
                              Text(chargerstation.reviewers,
                                  style: const TextStyle(
                                    color: Colours.secondaryColourDisabled,
                                    fontWeight: FontWeight.w400,
                                    fontSize: 15,
                                  )),
                            ],
                          ),
                          Column(
                            children: List.generate(
                              5,
                              (index) => Column(
                                children: [
                                  Row(
                                    children: [
                                      Text(
                                        (-index + 5).toString(),
                                        style: const TextStyle(
                                          fontSize: 15,
                                        ),
                                      ),
                                      const SizedBox(
                                        width: 10,
                                      ),
                                      Container(
                                          height: 10,
                                          width: 170,
                                          decoration: BoxDecoration(
                                            color: (value == index)
                                                ? Colours.secondaryColour
                                                : Colours.fadeColour,
                                            borderRadius:
                                                BorderRadius.circular(10),
                                          )),
                                    ],
                                  ),
                                  const SizedBox(
                                    height: 15,
                                  ),
                                ],
                              ),
                            ),
                          ),
                        ],
                      ),
                    ),
                    const SizedBox(
                      height: 40,
                    ),
                    Padding(
                      padding: const EdgeInsets.only(left: 20, right: 20),
                      child: Column(
                        children: [
                          Row(
                            mainAxisAlignment: MainAxisAlignment.start,
                            children: [
                              SizedBox(
                                width: 60,
                                height: 60,
                                child: Image.asset(
                                  MediaRes.userImage,
                                  fit: BoxFit.cover,
                                ),
                              ),
                              Padding(
                                padding: const EdgeInsets.only(left: 20),
                                child: Column(
                                  crossAxisAlignment: CrossAxisAlignment.start,
                                  children: [
                                    Text(
                                      user1.name,
                                      style: const TextStyle(
                                        color: Colours.blackColour,
                                        fontWeight: FontWeight.w800,
                                        fontSize: 20,
                                      ),
                                    ),
                                    Text(
                                      user1.time,
                                      style: const TextStyle(
                                        color: Colours.secondaryColourDisabled,
                                        fontWeight: FontWeight.w600,
                                      ),
                                    ),
                                  ],
                                ),
                              ),
                            ],
                          ),
                          const SizedBox(
                            height: 20,
                          ),
                          Text(
                            user1.review,
                            style: const TextStyle(
                              color: Colours.blackColour,
                              fontWeight: FontWeight.w600,
                            ),
                          )
                        ],
                      ),
                    ),
                  ],
                ),
              ),
            ],
          ),
        )
      ])
    ]));
  }
}
Leave a Comment