import 'package:flutter/material.dart';
import 'package:initial_folder/providers/my_course_provider.dart';
import 'package:initial_folder/providers/order_provider.dart';
import 'package:initial_folder/providers/page_provider.dart';
import 'package:initial_folder/providers/payments_provider.dart';
import 'package:initial_folder/screens/home/components/body_comp/latest_course.dart';
import 'package:initial_folder/screens/home/components/home_page.dart';
import 'package:initial_folder/screens/home/home_screen.dart';
// import 'package:initial_folder/models/course_model.dart';
import 'package:initial_folder/size_config.dart';
import 'package:initial_folder/theme.dart';
import 'package:initial_folder/widgets/login_regist/default_button.dart';
import 'package:provider/provider.dart';

class NotSuccessPaidCourse extends StatelessWidget {
  const NotSuccessPaidCourse({
    Key? key,
    this.title,
    this.id,
    this.thumbnail,
    this.instructor,
  }) : super(key: key);

  final String? instructor, id, thumbnail, title;
  @override
  Widget build(BuildContext context) {
    PageProvider pageProvider = Provider.of<PageProvider>(context);

    var orders = Provider.of<OrderProvider>(context).orders;
    return Scaffold(
      appBar: AppBar(
        leadingWidth: 14,
      ),
      body: ListView(
        children: [
          SizedBox(height: getProportionateScreenHeight(8)),
          Text(
            'TRANSAKSI DIBATALKAN',
            style: secondaryTextStyle.copyWith(
                fontWeight: bold,
                color: primaryColor,
                fontSize: getProportionateScreenWidth(20),
                letterSpacing: 1),
            textAlign: TextAlign.center,
          ),
          SizedBox(
            height: getProportionateScreenHeight(16),
          ),
          // Column(
          //   children: [
          //     Text(
          //       'Order ID',
          //       style: primaryTextStyle.copyWith(
          //         letterSpacing: 0.5,
          //         fontWeight: bold,
          //         fontSize: getProportionateScreenWidth(10),
          //         color: secondaryColor,
          //       ),
          //     ),
          //     Text(
          //       '123',
          //       style: primaryTextStyle.copyWith(
          //         letterSpacing: 0.5,
          //         fontWeight: reguler,
          //         fontSize: getProportionateScreenWidth(12),
          //         color: tenthColor,
          //       ),
          //     ),
          //   ],
          // ),
          // SizedBox(
          //   height: getProportionateScreenHeight(16),
          // ),
          Container(
            margin: EdgeInsets.only(left: 16, right: 16),
            width: SizeConfig.screenWidth,
            height: getProportionateScreenHeight(180),
            child: Column(
              children: [
                Container(
                  width: getProportionateScreenWidth(278),
                  height: getProportionateScreenHeight(156),
                  decoration: BoxDecoration(
                      borderRadius: BorderRadius.circular(5),
                      image: DecorationImage(
                          image: NetworkImage(thumbnail ??
                              // '$baseUrl/uploads/courses_thumbnail/course_thumbnail_default_57.jpg'
                              orders[0].imageUrl),
                          fit: BoxFit.fill)),
                ),
              ],
            ),
          ),
          Container(
            margin: EdgeInsets.only(
              left: getProportionateScreenWidth(16),
              right: getProportionateScreenWidth(16),
              bottom: getProportionateScreenHeight(8),
            ),
            child: Center(
              child: Text(
                title ?? '',
                style: secondaryTextStyle.copyWith(
                    fontSize: 20, letterSpacing: 0.2),
                textAlign: TextAlign.center,
              ),
            ),
          ),
          Container(
            child: Center(
              child: Text(
                instructor == null
                    ? 'Oleh ${orders[0].instructor}'
                    : 'Oleh $instructor ',
                style:
                    primaryTextStyle.copyWith(fontSize: 14, letterSpacing: 0.5),
                textAlign: TextAlign.center,
              ),
            ),
          ),
          Container(
            child: Text(
                orders.length == 1 ? '' : '(${orders.length} kursus lainnya)'),
          ),
          SizedBox(
            height: getProportionateScreenHeight(20),
          ),
          Container(
            margin: EdgeInsets.only(left: 16, right: 16),
            child: DefaultButton(
              text: 'Kembali Ke Home',
              press: () async {
                await Provider.of<MyCourseProvider>(context, listen: false)
                    .getMyCourse();
                pageProvider.currentIndex = 0;
                Navigator.pushAndRemoveUntil(
                    context,
                    MaterialPageRoute(builder: (context) => HomePage()),
                    (route) => false);
              },
            ),
          ),
          SizedBox(
            height: getProportionateScreenHeight(20),
          ),
          LatestCourse(text: "Kursus Terbaru")
        ],
      ),
    );
  }
}
