import 'package:driverapp/app-icons/driver_app_icons.dart';
import 'package:driverapp/core/viewModels/authentication_view_model.dart';
import 'package:driverapp/uitl/translations_delegate_base.dart';
import 'package:driverapp/widgets/others/app_scaffold_widget.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:provider/provider.dart';

import '../../root_page.dart';

class SettingPage extends StatelessWidget {
  final String driverName; //_authenticationViewModel.user.userName
  final int driverID;
  AuthenticationViewModel _authenticationViewModel;

  SettingPage({this.driverName, this.driverID});

  @override
  Widget build(BuildContext context) {
    _authenticationViewModel = Provider.of(context);
    return AppScaffold(
      isShowAppBar: true,
      appBarColor: Color(0xFF1DA4AA),
      arrowColor: Colors.white,
      titleColor: Colors.white,
      body: SingleChildScrollView(
        child: Container(
          decoration: BoxDecoration(
            gradient: LinearGradient(
              begin: Alignment(0.0,0.0),
              end: Alignment(-1.5, 0.0), // 10% of the width, so there are ten blinds.
              colors: [const Color(0xFF1DA4AA), const Color(0xFF3EB4AD)],//[const Color(0xff30B7B9), const Color(0xff3AB2AD)], // whitish to gray
              tileMode: TileMode.clamp, // repeats the gradient over the canvas
            ),
          ),
          child: Column(
            children: <Widget>[
              Container(
                width: double.infinity,
                child: Column(
                  children: <Widget>[
                    Container(
                      width: MediaQuery.of(context).size.width,
                      height: MediaQuery.of(context).size.width * 0.7,
                      child: CircleAvatar(
                        radius: 25.5,
                        backgroundColor: Theme.of(context).primaryColor,
                        child: CircleAvatar(
                          backgroundColor: Theme.of(context).primaryColor,
                          maxRadius: 200.0,
                          child: Image.asset(
                            'assets/images/driver.png',
                            height: MediaQuery.of(context).size.width * 1 ,
                            width: MediaQuery.of(context).size.width * 1,
                            fit: BoxFit.contain,
                          ),
                        ),
                      ),
                    ),
                    SizedBox(height: MediaQuery.of(context).size.width *0.05,),
                    Container(
                      child: Text(
                        driverName,
                        style: TextStyle(
                            fontSize: 40,
                            fontWeight: FontWeight.w600,
                            color: Colors.white
                        ),
                      ),
                    ),
                    SizedBox(height: MediaQuery.of(context).size.width *0.05,),
                    Container(
                      child: Text(
                        'ID: ${driverID.toString()}',
                        style: TextStyle(
                            fontSize: 20,
                            color: Colors.white
                        ),
                      ),
                    ),
                  ],
                ),
              ),
              SizedBox(height: MediaQuery.of(context).size.width *0.1,),
              Container(
                margin: EdgeInsets.only(left: 35),
                child: Column(
                  crossAxisAlignment: CrossAxisAlignment.stretch,
                  children: <Widget>[
                    InkWell(
                      onTap: () async {
                        await _authenticationViewModel.logout();
                        Navigator.pushReplacement(
                          context,
                          MaterialPageRoute(builder: (context) => RootPage()),
                        );
                      },
                      child: Column(
                        crossAxisAlignment: CrossAxisAlignment.start,
                        children: <Widget>[
                          Container(
                            margin: EdgeInsets.only(left: 15),
                            child: Row(
                              children: <Widget>[
                                Icon(
                                  DriverApp.logout_icon,
                                  size: 40,
                                  color: Colors.white,
                                ),
                                SizedBox(width: MediaQuery.of(context).size.width *0.05,),
                                Text(
                                  TranslationBase.of(context).logout,
                                  style: TextStyle(
                                      fontWeight: FontWeight.w500,
                                      color: Colors.white,
                                      fontSize: 18
                                  ),
                                ),
                              ],
                            ),
                          ),
                          SizedBox(
                            height: MediaQuery.of(context).size.width *0.05,
                            child: Center(
                              child: Container(
                                margin: EdgeInsetsDirectional.only(start: 0, end: 30),
                                height: 1.0,
                                color: Colors.white,
                              ),
                            ),
                          ),
                        ],
                      ),
                    ),
                    SizedBox(height: MediaQuery.of(context).size.width*0.05,),
                    InkWell(
                      child: Column(
                        crossAxisAlignment: CrossAxisAlignment.start,
                        children: <Widget>[
                          Container(
                            margin: EdgeInsets.only(left: 15),
                            child: Row(
                              children: <Widget>[
                                Icon(
                                  DriverApp.language_icon,
                                  size: 40,
                                  color: Colors.white,
                                ),
                                SizedBox(
                                  width: MediaQuery.of(context).size.width * 0.05,
                                ),
                                Text(
                                  TranslationBase.of(context).languageText,
                                  style: TextStyle(
                                      fontWeight: FontWeight.w500,
                                      color: Colors.white,
                                      fontSize: 18
                                  ),
                                ),
                              ],
                            ),
                          ),
                          SizedBox(
                            height: 10.0,
                            child: Center(
                              child: Container(
                                margin: EdgeInsetsDirectional.only(start: 0, end: 30),
                                height: 1.0,
                                color: Colors.white,
                              ),
                            ),
                          ),
                          SizedBox(height: MediaQuery.of(context).size.width*0.05,),
                        ],
                      ),
                    ),
                    InkWell(
                      child: Column(
                        crossAxisAlignment: CrossAxisAlignment.start,
                        children: <Widget>[
                          Container(
                            margin: EdgeInsets.only(left: 15),
                            child: Row(
                              children: <Widget>[
                                Icon(
                                  DriverApp.settings_icon,
                                  size: 40,
                                  color: Colors.white,
                                ),
                                SizedBox(
                                  width: MediaQuery.of(context).size.width * 0.05,
                                ),
                                Text(
                                  TranslationBase.of(context).settings,
                                  style: TextStyle(
                                      fontWeight: FontWeight.w500,
                                      color: Colors.white,
                                      fontSize: 18
                                  ),
                                ),
                              ],
                            ),
                          ),
                          SizedBox(
                            height: 10.0,
                            child: Center(
                              child: Container(
                                margin: EdgeInsetsDirectional.only(start: 0, end: 30),
                                height: 1.0,
                                color: Colors.white,
                              ),
                            ),
                          ),
                          SizedBox(height: MediaQuery.of(context).size.width*0.05,),
                        ],
                      ),
                    ),
                    InkWell(
                      child: Column(
                        crossAxisAlignment: CrossAxisAlignment.start,
                        children: <Widget>[
                          Container(
                            margin: EdgeInsets.only(left: 15),
                            child: Row(
                              children: <Widget>[
                                Icon(
                                  DriverApp.bell_icon,
                                  size: 40,
                                  color: Colors.white,
                                ),
                                SizedBox(
                                  width: MediaQuery.of(context).size.width * 0.05,
                                ),
                                Text(
                                  TranslationBase.of(context).notification,
                                  style: TextStyle(
                                      fontWeight: FontWeight.w500,
                                      color: Colors.white,
                                      fontSize: 18
                                  ),
                                ),
                              ],
                            ),
                          ),
                          SizedBox(
                            height: 10.0,
                            child: Center(
                              child: Container(
                                margin: EdgeInsetsDirectional.only(start: 0, end: 30),
                                height: 1.0,
                                color: Colors.white,
                              ),
                            ),
                          ),
                          SizedBox(height: MediaQuery.of(context).size.width*0.05,),
                        ],
                      ),
                    ),
                  ],
                ),
              ),
            ],
          ),
        ),
      ),
    );
  }
}