Skip to content

Commit

Permalink
ui: Update ListTile theme data
Browse files Browse the repository at this point in the history
  • Loading branch information
0niel committed Jan 3, 2024
1 parent 7bfe67e commit f5315a7
Show file tree
Hide file tree
Showing 3 changed files with 169 additions and 76 deletions.
161 changes: 98 additions & 63 deletions lib/presentation/pages/profile/profile_settings_page.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import 'package:flutter/material.dart';
import 'package:font_awesome_flutter/font_awesome_flutter.dart';
import 'package:go_router/go_router.dart';
import 'package:provider/provider.dart';
import 'package:rtu_mirea_app/presentation/app_notifier.dart';
Expand All @@ -16,73 +17,107 @@ class ProfileSettingsPage extends StatelessWidget {
),
body: SafeArea(
bottom: false,
child: ListView(
children: [
const SizedBox(height: 24),
ListTile(
title: Text("Тема", style: AppTextStyle.body),
leading: Icon(Icons.brightness_6, color: AppTheme.colors.active),
trailing: const Icon(Icons.chevron_right),
onTap: () {
showDialog(
context: context,
builder: (context) => SimpleDialog(
title: Text("Выбор темы", style: AppTextStyle.titleS),
contentPadding: const EdgeInsets.all(16),
backgroundColor: AppTheme.colors.background02,
elevation: 0,
children: [
ListTile(
title: Text("Светлая", style: AppTextStyle.body),
onTap: () {
context
.read<AppNotifier>()
.updateTheme(AppThemeType.light);
// Close dialog
context.pop();
},
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(8),
child: Padding(
padding: const EdgeInsets.symmetric(horizontal: 16),
child: ListView(
children: [
const SizedBox(height: 24),
ListTile(
title: Text("Тема", style: AppTextStyle.body),
leading: Icon(FontAwesomeIcons.palette,
color: AppTheme.colors.active),
trailing: const Icon(Icons.chevron_right),
onTap: () {
showDialog(
context: context,
builder: (context) => SimpleDialog(
title: Text("Выбор темы", style: AppTextStyle.titleS),
contentPadding: const EdgeInsets.all(16),
backgroundColor: AppTheme.colors.background02,
elevation: 0,
children: [
_ListTileThemeItem(
title: "Светлая",
trailing: AppTheme.defaultThemeType ==
AppThemeType.light
? Icon(Icons.check, color: AppTheme.colors.active)
: null,
onTap: () {
context
.read<AppNotifier>()
.updateTheme(AppThemeType.light);

context.pop();
},
),
trailing:
AppTheme.defaultThemeType == AppThemeType.light
? const Icon(Icons.check)
: null,
),
const SizedBox(height: 8),
ListTile(
title: Text("Тёмная", style: AppTextStyle.body),
onTap: () {
context
.read<AppNotifier>()
.updateTheme(AppThemeType.dark);
// Close dialog
context.pop();
},
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(8),
const SizedBox(height: 8),
_ListTileThemeItem(
title: "Тёмная",
trailing: AppTheme.defaultThemeType ==
AppThemeType.dark
? Icon(Icons.check, color: AppTheme.colors.active)
: null,
onTap: () {
context
.read<AppNotifier>()
.updateTheme(AppThemeType.dark);

context.pop();
},
),
trailing: AppTheme.defaultThemeType == AppThemeType.dark
? const Icon(Icons.check)
: null,
),
],
),
);
},
),
const Divider(),
ListTile(
title: Text("Уведомления", style: AppTextStyle.body),
leading: Icon(Icons.notifications, color: AppTheme.colors.active),
onTap: () {
context.go("/profile/settings/notifications");
},
),
const Divider(),
],
],
),
);
},
),
const Divider(),
ListTile(
title: Text("Уведомления", style: AppTextStyle.body),
leading:
Icon(Icons.notifications, color: AppTheme.colors.active),
onTap: () {
context.go("/profile/settings/notifications");
},
),
const Divider(),
],
),
),
),
);
}
}

class _ListTileThemeItem extends StatelessWidget {
const _ListTileThemeItem({
Key? key,
required this.title,
required this.onTap,
this.trailing,
}) : super(key: key);

final String title;
final Widget? trailing;
final VoidCallback onTap;

@override
Widget build(BuildContext context) {
return ListTile(
title: Text(
title,
style: AppTextStyle.body.copyWith(
color: AppTheme.colors.active,
),
),
contentPadding: const EdgeInsets.symmetric(horizontal: 8),
dense: true,
onTap: () {
onTap();
},
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(8),
),
trailing: trailing,
);
}
}
70 changes: 65 additions & 5 deletions lib/presentation/theme.dart
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,20 @@ class AppTheme {
AppTextStyle.title.copyWith(color: darkThemeColors.active),
iconTheme: IconThemeData(color: blackThemeColors.active),
),
chipTheme: ChipThemeData(
backgroundColor: darkThemeColors.background02,
disabledColor: darkThemeColors.background02,
selectedColor: darkThemeColors.background02,
secondarySelectedColor: darkThemeColors.background02,
padding: const EdgeInsets.all(8),
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(16),
),
labelStyle: AppTextStyle.chip.copyWith(color: darkThemeColors.active),
secondaryLabelStyle:
AppTextStyle.chip.copyWith(color: darkThemeColors.active),
brightness: Brightness.dark,
),
cardTheme: CardTheme(
color: darkThemeColors.background01,
elevation: 4,
Expand All @@ -55,16 +69,32 @@ class AppTheme {
),
listTileTheme: ListTileThemeData(
tileColor: darkThemeColors.background01,
contentPadding: const EdgeInsets.symmetric(horizontal: 16),
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(16),
contentPadding: EdgeInsets.zero,
leadingAndTrailingTextStyle: AppTextStyle.chip.copyWith(
color: AppTheme.colors.active,
),
titleTextStyle: AppTextStyle.chip.copyWith(
color: AppTheme.colors.deactive,
),
visualDensity: const VisualDensity(vertical: 4),
subtitleTextStyle: AppTextStyle.titleM.copyWith(
color: darkThemeColors.active,
),
),
dividerTheme: DividerThemeData(
color: darkThemeColors.background02,
thickness: 0.5,
space: 0,
),
snackBarTheme: SnackBarThemeData(
backgroundColor: darkThemeColors.background02,
contentTextStyle: AppTextStyle.bodyBold.copyWith(
color: darkThemeColors.active,
),
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(16),
),
),
colorScheme: ColorScheme(
background: darkThemeColors.background01,
brightness: Brightness.dark,
Expand Down Expand Up @@ -105,15 +135,45 @@ class AppTheme {
selectedLabelStyle: AppTextStyle.captionL,
unselectedLabelStyle: AppTextStyle.captionS,
),
chipTheme: ChipThemeData(
backgroundColor: lightThemeColors.background02,
disabledColor: lightThemeColors.background02,
selectedColor: lightThemeColors.background02,
secondarySelectedColor: lightThemeColors.background02,
padding: const EdgeInsets.all(8),
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(16),
),
labelStyle: AppTextStyle.chip.copyWith(color: lightThemeColors.active),
secondaryLabelStyle:
AppTextStyle.chip.copyWith(color: lightThemeColors.active),
brightness: Brightness.light,
),
listTileTheme: ListTileThemeData(
tileColor: lightThemeColors.background01,
contentPadding: const EdgeInsets.symmetric(horizontal: 16),
contentPadding: EdgeInsets.zero,
leadingAndTrailingTextStyle: AppTextStyle.chip.copyWith(
color: AppTheme.colors.active,
),
titleTextStyle: AppTextStyle.chip.copyWith(
color: AppTheme.colors.deactive,
),
visualDensity: const VisualDensity(vertical: 4),
subtitleTextStyle: AppTextStyle.titleM.copyWith(
color: lightThemeColors.active,
),
),
snackBarTheme: SnackBarThemeData(
backgroundColor: lightThemeColors.background02,
contentTextStyle: AppTextStyle.bodyBold.copyWith(
color: lightThemeColors.active,
),
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(16),
),
),
dividerTheme: DividerThemeData(
color: lightThemeColors.background02,
color: lightThemeColors.deactiveDarker.withOpacity(0.25),
thickness: 0.5,
space: 0,
),
Expand Down
14 changes: 6 additions & 8 deletions lib/presentation/widgets/bottom_modal_sheet.dart
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,12 @@ class BottomModalSheet extends StatelessWidget {
),
),
context: context,
builder: (context) => SafeArea(
child: SizedBox(
height: MediaQuery.of(context).size.height * 0.6,
child: BottomModalSheet(
title: title,
description: description,
child: child,
),
builder: (context) => SizedBox(
height: MediaQuery.of(context).size.height * 0.6,
child: BottomModalSheet(
title: title,
description: description,
child: child,
),
),
);
Expand Down

0 comments on commit f5315a7

Please sign in to comment.