Untitled

mail@pastecode.io avatar
unknown
dart
24 days ago
11 kB
0
Indexable
Never
import 'package:easy_localization/easy_localization.dart';
import 'package:flutter/material.dart';
import 'package:flutter_svg/flutter_svg.dart';
import 'package:provider/provider.dart';
import 'package:providerbase/core/constants/assets.dart';
import 'package:providerbase/core/constants/strings.dart';
import 'package:providerbase/core/shared_widget/main_app_bar.dart';
import 'package:providerbase/presentation/notifiers/theme/theme_notifier.dart';
import 'package:providerbase/presentation/pages/student_profile_page/widgets/informations_tab_widget.dart';
import 'package:providerbase/presentation/props/main_app_bar_props/main_app_bar_props.dart';
import 'package:providerbase/presentation/resources/color_manager.dart';
import 'package:providerbase/presentation/resources/font_manager.dart';

class StudentProfilePage extends StatefulWidget {
  const StudentProfilePage({super.key});

  @override
  State<StudentProfilePage> createState() => _StudentProfilePageState();
}

class _StudentProfilePageState extends State<StudentProfilePage>
    with SingleTickerProviderStateMixin {
  late TabController _tabController;

  @override
  void initState() {
    _tabController = TabController(length: 4, vsync: this);
    super.initState();
  }

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

  @override
  Widget build(BuildContext context) {
    ThemeNotifier themeNotifier = Provider.of<ThemeNotifier>(
      context,
      listen: true,
    );
    TextTheme textTheme = themeNotifier.getTheme().textTheme;
    return Scaffold(
      appBar: _appBarWidget(),
      body: SingleChildScrollView(
        child: Padding(
          padding: const EdgeInsets.only(top: 30),
          child: Column(
            children: [
              _userPhotoAndNameWidget(context, textTheme),
              _messageTransferBalance(context, textTheme),
              _tabBarWidget(themeNotifier),
            ],
          ),
        ),
      ),
    );
  }

  PreferredSizeWidget _appBarWidget() => MainAppBar(
      props: MainAppBarProps(
          title: Strings.profilePage.tr(),
          centerTitle: true,
          trailing: SizedBox.shrink()));

  Widget _userPhotoAndNameWidget(BuildContext context, TextTheme textTheme) =>
      Center(
        child: Column(
          children: [
            ClipRRect(
              borderRadius: BorderRadius.circular(12),
              child: Image.asset(
                Assets.userTestAvatar2,
                height: MediaQuery.sizeOf(context).height / 10,
              ),
            ),
            Padding(
              padding: const EdgeInsets.only(top: 15, bottom: 5),
              child: Text(
                'محمد علي صالح',
                style: textTheme.displaySmall?.copyWith(
                    fontSize: FontSize.s18,
                    color: ColorManager.black,
                    fontWeight: FontWeight.w800),
              ),
            ),
            Text(
              'السادس إعدادي',
              style: textTheme.displaySmall?.copyWith(
                  fontSize: FontSize.s13,
                  color: ColorManager.black,
                  fontWeight: FontWeight.w500),
            )
          ],
        ),
      );

  Widget _messageTransferBalance(BuildContext context, TextTheme textTheme) =>
      Padding(
        padding: const EdgeInsets.only(top: 15, right: 30, left: 30),
        child: Row(
          mainAxisAlignment: MainAxisAlignment.center,
          children: [
            InkWell(
              onTap: () {},
              borderRadius: BorderRadius.circular(4),
              child: Container(
                width: MediaQuery.sizeOf(context).width / 4.5,
                height: 32,
                constraints: BoxConstraints(maxWidth: 170),
                decoration: BoxDecoration(
                  color: ColorManager.main.withOpacity(.1),
                  borderRadius: BorderRadius.circular(4),
                ),
                child: Center(
                  child: Wrap(
                    spacing: 3.5,
                    children: [
                      SvgPicture.asset(Assets.chatIcon),
                      Text(
                        Strings.chatting.tr(),
                        style: textTheme.displaySmall?.copyWith(
                          color: ColorManager.main,
                          fontSize: FontSize.s12,
                          fontWeight: FontWeight.w500,
                        ),
                      )
                    ],
                  ),
                ),
              ),
            ),
            Padding(
              padding: const EdgeInsets.only(right: 10),
              child: InkWell(
                onTap: () {},
                borderRadius: BorderRadius.circular(4),
                child: Container(
                  width: MediaQuery.sizeOf(context).width / 3.6,
                  height: 32,
                  constraints: BoxConstraints(maxWidth: 200),
                  decoration: BoxDecoration(
                    color: ColorManager.goldColor.withOpacity(.1),
                    borderRadius: BorderRadius.circular(4),
                  ),
                  child: Center(
                    child: Wrap(
                      spacing: 3.5,
                      children: [
                        SvgPicture.asset(Assets.transferBalanceIcon),
                        Text(
                          Strings.transferBalance.tr(),
                          style: textTheme.displaySmall?.copyWith(
                            color: ColorManager.goldColor,
                            fontSize: FontSize.s12,
                            fontWeight: FontWeight.w500,
                          ),
                        )
                      ],
                    ),
                  ),
                ),
              ),
            )
          ],
        ),
      );

  TextStyle defaultTabTextTheme(
    ThemeNotifier themeNotifier,
  ) =>
      themeNotifier.getTheme().textTheme.headlineSmall!.copyWith(
          color: ColorManager.main,
          fontSize: FontSize.s14,
          fontWeight: FontWeight.w800);

  Widget _tabBarWidget(ThemeNotifier themeNotifier) => Padding(
        padding: const EdgeInsets.only(top: 12, left: 10, right: 10),
        child: Column(
          mainAxisSize: MainAxisSize.min,
          children: <Widget>[
            TabBar(
              controller: _tabController,
              labelPadding: EdgeInsets.zero,
              dividerColor: Colors.transparent,
              indicator: UnderlineTabIndicator(
                borderSide: BorderSide(width: 2.0, color: ColorManager.main),
              ),
              indicatorPadding: EdgeInsets.only(bottom: 2),
              indicatorSize: TabBarIndicatorSize.tab,
              tabs: [
                Tab(
                  child: Row(
                    mainAxisAlignment: MainAxisAlignment.center,
                    children: [
                      SvgPicture.asset(_tabController.index == 0
                          ? Assets.postSelectedIcon
                          : Assets.postUnselectedIcon),
                      Visibility(
                          visible: _tabController.index == 0,
                          child: Padding(
                            padding: const EdgeInsets.only(right: 4),
                            child: Text(Strings.posts.tr(),
                                style: defaultTabTextTheme(themeNotifier)),
                          )),
                    ],
                  ),
                ),
                Tab(
                  child: Row(
                    mainAxisAlignment: MainAxisAlignment.center,
                    children: [
                      SvgPicture.asset(
                        _tabController.index == 1
                            ? Assets.reelsSelectedIcon
                            : Assets.reelsUnselectedIcon,
                      ),
                      Visibility(
                          visible: _tabController.index == 1,
                          child: Padding(
                            padding: const EdgeInsets.only(right: 4),
                            child: Text(Strings.reels.tr(),
                                style: defaultTabTextTheme(themeNotifier)),
                          )),
                    ],
                  ),
                ),
                Tab(
                  child: Row(
                    mainAxisAlignment: MainAxisAlignment.center,
                    children: [
                      SvgPicture.asset(_tabController.index == 2
                          ? Assets.informationSelectedIcon
                          : Assets.informationUnselectedIcon),
                      Visibility(
                          visible: _tabController.index == 2,
                          child: Padding(
                            padding: const EdgeInsets.only(right: 4),
                            child: Text(Strings.informations.tr(),
                                style: defaultTabTextTheme(themeNotifier)),
                          )),
                    ],
                  ),
                ),
                Tab(
                  child: Row(
                    mainAxisAlignment: MainAxisAlignment.center,
                    children: [
                      SvgPicture.asset(_tabController.index == 3
                          ? Assets.coursesSelectedIcon
                          : Assets.coursesUnselectedIcon),
                      Visibility(
                          visible: _tabController.index == 3,
                          child: Padding(
                            padding: const EdgeInsets.only(right: 4),
                            child: Text(
                              Strings.courses.tr(),
                              style: defaultTabTextTheme(themeNotifier),
                            ),
                          )),
                    ],
                  ),
                ),
              ],
              onTap: (index) {
                setState(() {
                  _tabController.index = index;
                });
              },
            ),
            Container(
              height: 4,
              decoration: BoxDecoration(
                boxShadow: [
                  BoxShadow(
                    color: ColorManager.grey3.withOpacity(0.12),
                    spreadRadius: 0,
                    blurRadius: 4,
                    offset: Offset(0, 4),
                  ),
                ],
              ),
            ),
            Column(
              children: [
                // posts tab
                if (_tabController.index == 0)
                  SizedBox.shrink()
                else if (_tabController.index == 1)
                  // reels tap
                  SizedBox.shrink()
                else if (_tabController.index == 2)
                  // informations tab
                  InformationsTabWidget()
                else if (_tabController.index == 3)
                  // courses tab
                  SizedBox.shrink(),
              ],
            ),
          ],
        ),
      );
}
Leave a Comment