|
| 1 | +import 'package:flutter/material.dart'; |
| 2 | +import 'package:help_me_design/appwrite_service/auth_service.dart'; |
| 3 | +import 'package:help_me_design/theme/my_colors.dart'; |
| 4 | +import 'package:help_me_design/theme/my_design_system.dart'; |
| 5 | +import 'package:help_me_design/theme/my_theme.dart'; |
| 6 | +import 'package:help_me_design/views/widgets/button_tap_effect.dart'; |
| 7 | +import 'package:provider/provider.dart'; |
| 8 | + |
| 9 | +import '../../../../constants/text_constants.dart'; |
| 10 | +import '../../../widgets/container_pattern_painter.dart'; |
| 11 | +import '../widgets/tab_view_hero_card.dart'; |
| 12 | + |
| 13 | +class SettingsTab extends StatelessWidget { |
| 14 | + const SettingsTab({Key? key}) : super(key: key); |
| 15 | + |
| 16 | + @override |
| 17 | + Widget build(BuildContext context) { |
| 18 | + var themeData = Theme.of(context); |
| 19 | + var authService = Provider.of<AuthService>(context, listen: false); |
| 20 | + var themeMangerProvider = Provider.of<ThemeManager>(context, listen: false); |
| 21 | + return Container( |
| 22 | + // width: 200, |
| 23 | + // height: 200, |
| 24 | + // color: Colors.deepPurple, |
| 25 | + child: SingleChildScrollView( |
| 26 | + child: Column( |
| 27 | + children: [ |
| 28 | + TabViewHeroCard( |
| 29 | + // title: MyTextConstants.docsTabHeadline, |
| 30 | + title: "Settings.", |
| 31 | + shortDescription: "Setting, Profile, About", |
| 32 | + posterImage: 'https://i.ibb.co/SNVPkKM/original-dd50f8430ab324b03b6af592e73ca6c7-removebg-preview.png', |
| 33 | + bgPattern: ContainerSquarePatternTwoPainter(44, context), |
| 34 | + ), |
| 35 | + SizedBox(height: MySpaceSystem.spaceX2), |
| 36 | + Column( |
| 37 | + crossAxisAlignment: CrossAxisAlignment.start, |
| 38 | + children: [ |
| 39 | + // Profile Section |
| 40 | + SectionDividerWithTitle( |
| 41 | + title: 'Profile', |
| 42 | + bodyWidget: Row( |
| 43 | + mainAxisAlignment: MainAxisAlignment.spaceBetween, |
| 44 | + children: [ |
| 45 | + Row( |
| 46 | + children: [ |
| 47 | + const Icon(Icons.person_4, color: DesignSystemColors.secondaryColorDark, size: 78), |
| 48 | + const SizedBox(width: MySpaceSystem.spaceX), |
| 49 | + Column( |
| 50 | + mainAxisAlignment: MainAxisAlignment.start, |
| 51 | + crossAxisAlignment: CrossAxisAlignment.start, |
| 52 | + children: [ |
| 53 | + Text("Default Name", style: MyTextTypeSystem.titleMediumDark), |
| 54 | + const SizedBox(height: MySpaceSystem.spaceX), |
| 55 | + Text(authService.currentUser.email, style: MyTextTypeSystem.titleLargeDark), |
| 56 | + ], |
| 57 | + ), |
| 58 | + ], |
| 59 | + ), |
| 60 | + ButtonTapEffect( |
| 61 | + onTap: () {}, |
| 62 | + child: Container( |
| 63 | + height: 64, |
| 64 | + decoration: BoxDecoration( |
| 65 | + boxShadow: cardShadow, |
| 66 | + color: DesignSystemColors.secondaryColorDark, |
| 67 | + borderRadius: BorderRadius.circular(8), |
| 68 | + ), |
| 69 | + padding: EdgeInsets.symmetric(horizontal: MySpaceSystem.spaceX2), |
| 70 | + child: Row( |
| 71 | + crossAxisAlignment: CrossAxisAlignment.center, |
| 72 | + children: [ |
| 73 | + SizedBox(width: MySpaceSystem.spaceX1), |
| 74 | + Text("Logout", style: MyTextTypeSystem.titleMedium), |
| 75 | + SizedBox(width: MySpaceSystem.spaceX1), |
| 76 | + const Icon(Icons.logout_rounded, color: DesignSystemColors.secondaryColor, size: 34), |
| 77 | + ], |
| 78 | + ), |
| 79 | + ), |
| 80 | + ), |
| 81 | + ], |
| 82 | + ), |
| 83 | + ), |
| 84 | + SizedBox(height: MySpaceSystem.spaceX4), |
| 85 | + SectionDividerWithTitle( |
| 86 | + title: 'Theme', |
| 87 | + bodyWidget: Row( |
| 88 | + mainAxisAlignment: MainAxisAlignment.start, |
| 89 | + children: [ |
| 90 | + ThemeModeCard( |
| 91 | + isActive: themeData.brightness == Brightness.dark ? true : false, |
| 92 | + title: 'Dark Mode', |
| 93 | + mode: 'dark', |
| 94 | + activeBorderColor: DesignSystemColors.secondaryColor, |
| 95 | + modeColor: DesignSystemColors.secondaryColorDark, |
| 96 | + onTap: () { |
| 97 | + themeMangerProvider.changeThemeMode(ThemeMode.dark); |
| 98 | + }, |
| 99 | + ), |
| 100 | + SizedBox(width: MySpaceSystem.spaceX3), |
| 101 | + ThemeModeCard( |
| 102 | + isActive: themeData.brightness == Brightness.light ? true : false, |
| 103 | + title: 'Light Mode', |
| 104 | + mode: 'light', |
| 105 | + activeBorderColor: DesignSystemColors.secondaryColorDark, |
| 106 | + modeColor: DesignSystemColors.secondaryColor, |
| 107 | + onTap: () { |
| 108 | + themeMangerProvider.changeThemeMode(ThemeMode.light); |
| 109 | + }, |
| 110 | + ), |
| 111 | + ], |
| 112 | + ), |
| 113 | + ), |
| 114 | + SizedBox(height: MySpaceSystem.spaceX3), |
| 115 | + ], |
| 116 | + ) |
| 117 | + ], |
| 118 | + ), |
| 119 | + ), |
| 120 | + ); |
| 121 | + } |
| 122 | +} |
| 123 | + |
| 124 | +class ThemeModeCard extends StatelessWidget { |
| 125 | + const ThemeModeCard({ |
| 126 | + super.key, |
| 127 | + required this.title, |
| 128 | + required this.mode, |
| 129 | + required this.isActive, |
| 130 | + required this.activeBorderColor, |
| 131 | + required this.modeColor, |
| 132 | + required this.onTap, |
| 133 | + }); |
| 134 | + |
| 135 | + final String title; |
| 136 | + final String mode; |
| 137 | + final bool isActive; |
| 138 | + final Color activeBorderColor; |
| 139 | + final Color modeColor; |
| 140 | + final VoidCallback onTap; |
| 141 | + |
| 142 | + @override |
| 143 | + Widget build(BuildContext context) { |
| 144 | + return ButtonTapEffect( |
| 145 | + onTap: onTap, |
| 146 | + child: Container( |
| 147 | + height: 200, |
| 148 | + width: 200, |
| 149 | + decoration: BoxDecoration( |
| 150 | + boxShadow: cardShadow, |
| 151 | + color: modeColor, |
| 152 | + borderRadius: BorderRadius.circular(10), |
| 153 | + border: Border.all(width: 2, color: isActive ? activeBorderColor : modeColor), |
| 154 | + ), |
| 155 | + padding: EdgeInsets.all(MySpaceSystem.spaceX2), |
| 156 | + child: Column( |
| 157 | + crossAxisAlignment: CrossAxisAlignment.center, |
| 158 | + mainAxisAlignment: MainAxisAlignment.start, |
| 159 | + children: [ |
| 160 | + ClipRRect( |
| 161 | + borderRadius: const BorderRadius.only(topLeft: Radius.circular(4), topRight: Radius.circular(4)), |
| 162 | + child: Image.asset(mode == 'dark' ? 'assets/images/dark.png' : 'assets/images/light.png'), |
| 163 | + ), |
| 164 | + SizedBox(height: MySpaceSystem.spaceX3), |
| 165 | + Text(title, style: mode == 'dark' ? MyTextTypeSystem.titleLarge : MyTextTypeSystem.titleLargeDark), |
| 166 | + SizedBox(height: MySpaceSystem.spaceX1), |
| 167 | + ], |
| 168 | + ), |
| 169 | + ), |
| 170 | + ); |
| 171 | + } |
| 172 | +} |
| 173 | + |
| 174 | +class SectionDividerWithTitle extends StatelessWidget { |
| 175 | + const SectionDividerWithTitle({Key? key, required this.title, required this.bodyWidget}) : super(key: key); |
| 176 | + |
| 177 | + final String title; |
| 178 | + final Widget bodyWidget; |
| 179 | + |
| 180 | + @override |
| 181 | + Widget build(BuildContext context) { |
| 182 | + return Padding( |
| 183 | + padding: EdgeInsets.only(left: MySpaceSystem.spaceX3), |
| 184 | + child: Column( |
| 185 | + crossAxisAlignment: CrossAxisAlignment.start, |
| 186 | + children: [ |
| 187 | + Text( |
| 188 | + title, |
| 189 | + style: MyTextTypeSystem.titleXXLargeDark, |
| 190 | + ), |
| 191 | + SizedBox(height: MySpaceSystem.spaceX1), |
| 192 | + const Divider(height: 1, thickness: 1, color: DesignSystemColors.secondaryColorDark), |
| 193 | + SizedBox(height: MySpaceSystem.spaceX1), |
| 194 | + SizedBox(height: MySpaceSystem.spaceX3), |
| 195 | + bodyWidget, |
| 196 | + ], |
| 197 | + ), |
| 198 | + ); |
| 199 | + } |
| 200 | +} |
0 commit comments