Skip to content

Commit

Permalink
Impliment new generic setting tile. (#43)
Browse files Browse the repository at this point in the history
  • Loading branch information
micedreams authored Oct 2, 2023
1 parent ef7b71e commit 3097dbe
Show file tree
Hide file tree
Showing 6 changed files with 65 additions and 56 deletions.
20 changes: 9 additions & 11 deletions lib/core/widgets/send_feedback.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import 'package:dairy_app/app/themes/theme_extensions/note_create_page_theme_extensions.dart';
import 'package:dairy_app/core/widgets/settings_tile.dart';

import 'package:flutter/material.dart';
import 'package:url_launcher/url_launcher.dart';
Expand All @@ -10,18 +11,15 @@ class SendFeedBack extends StatelessWidget {
final subject = 'Feedback for DiaryVault';

@override
Widget build(BuildContext context) => InkWell(
Widget build(BuildContext context) => SettingsTile(
onTap: _launchEmailApp,
child: Padding(
padding: const EdgeInsets.symmetric(vertical: 6.0),
child: Text(
"Send feedback",
style: TextStyle(
fontSize: 16.0,
color: Theme.of(context)
.extension<NoteCreatePageThemeExtensions>()!
.mainTextColor,
),
child: Text(
"Send feedback",
style: TextStyle(
fontSize: 16.0,
color: Theme.of(context)
.extension<NoteCreatePageThemeExtensions>()!
.mainTextColor,
),
),
);
Expand Down
27 changes: 27 additions & 0 deletions lib/core/widgets/settings_tile.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import 'package:flutter/material.dart';

class SettingsTile extends StatelessWidget {
const SettingsTile({
required this.child,
this.onTap,
Key? key,
}) : super(key: key);

final Widget child;
final VoidCallback? onTap;

@override
Widget build(BuildContext context) {
final widget = Padding(
padding: const EdgeInsets.symmetric(vertical: 6.0),
child: child,
);

return null == onTap
? widget
: InkWell(
onTap: onTap,
child: widget,
);
}
}
14 changes: 6 additions & 8 deletions lib/core/widgets/share_with_friends.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import 'package:dairy_app/app/themes/theme_extensions/note_create_page_theme_extensions.dart';
import 'package:dairy_app/core/widgets/settings_tile.dart';
import 'package:flutter/material.dart';
import 'package:share_plus/share_plus.dart';

Expand All @@ -15,8 +16,8 @@ class ShareWithFriends extends StatelessWidget {
);
const appDescription =
"Discover diaryVault - a diary app designed to help you capture your thoughts, memories, and moments effortlessly. Available now on the Play Store!";
return GestureDetector(

return SettingsTile(
onTap: (() async {
try {
const playstoreURL =
Expand All @@ -28,12 +29,9 @@ class ShareWithFriends extends StatelessWidget {
);
}
}),
child: Padding(
padding: const EdgeInsets.symmetric(vertical: 6.0),
child: Text(
"Share with Friends",
style: mainTextStyle,
),
child: Text(
"Share with Friends",
style: mainTextStyle,
),
);
}
Expand Down
4 changes: 2 additions & 2 deletions lib/core/widgets/version_number.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import 'package:dairy_app/app/themes/theme_extensions/note_create_page_theme_extensions.dart';
import 'package:dairy_app/core/widgets/settings_tile.dart';
import 'package:flutter/material.dart';
import 'package:package_info_plus/package_info_plus.dart';

Expand All @@ -19,8 +20,7 @@ class VersionNumber extends StatelessWidget {
builder: (context, snapshot) {
final version = snapshot.data?.version ?? '';

return Padding(
padding: const EdgeInsets.symmetric(vertical: 6.0),
return SettingsTile(
child: Row(
children: [
Text(
Expand Down
35 changes: 13 additions & 22 deletions lib/features/auth/presentation/widgets/security_settings.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import 'package:dairy_app/app/themes/theme_extensions/note_create_page_theme_ext
import 'package:dairy_app/app/themes/theme_extensions/settings_page_theme_extensions.dart';
import 'package:dairy_app/core/dependency_injection/injection_container.dart';
import 'package:dairy_app/core/utils/utils.dart';
import 'package:dairy_app/core/widgets/settings_tile.dart';
import 'package:dairy_app/features/auth/core/constants.dart';
import 'package:dairy_app/features/auth/domain/repositories/authentication_repository.dart';
import 'package:dairy_app/features/auth/presentation/bloc/auth_session/auth_session_bloc.dart';
Expand Down Expand Up @@ -51,15 +52,12 @@ class SecuritySettings extends StatelessWidget {
children: [
Material(
color: Colors.transparent,
child: InkWell(
child: Padding(
padding: const EdgeInsets.symmetric(vertical: 6.0),
child: Row(
children: [
Text("Change password",
style: TextStyle(
fontSize: 16.0, color: mainTextColor)),
],
child: SettingsTile(
child: Text(
"Change password",
style: TextStyle(
fontSize: 16.0,
color: mainTextColor,
),
),
onTap: () async {
Expand Down Expand Up @@ -97,19 +95,12 @@ class SecuritySettings extends StatelessWidget {
const SizedBox(height: 10.0),
Material(
color: Colors.transparent,
child: InkWell(
child: Padding(
padding: const EdgeInsets.symmetric(vertical: 6.0),
child: Row(
children: [
Text(
"Change email",
style: TextStyle(
fontSize: 16.0,
color: mainTextColor,
),
),
],
child: SettingsTile(
child: Text(
"Change email",
style: TextStyle(
fontSize: 16.0,
color: mainTextColor,
),
),
onTap: () async {
Expand Down
21 changes: 8 additions & 13 deletions lib/features/auth/presentation/widgets/setup_account.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import 'package:dairy_app/app/themes/theme_extensions/note_create_page_theme_extensions.dart';
import 'package:dairy_app/core/utils/utils.dart';
import 'package:dairy_app/core/widgets/glass_dialog.dart';
import 'package:dairy_app/core/widgets/settings_tile.dart';
import 'package:dairy_app/core/widgets/submit_button.dart';
import 'package:dairy_app/features/auth/core/constants.dart';
import 'package:dairy_app/features/auth/presentation/bloc/auth_form/auth_form_bloc.dart';
Expand Down Expand Up @@ -45,7 +46,7 @@ class _SetupAccountState extends State<SetupAccount> {
if (state.userConfigModel?.userId == GuestUserDetails.guestUserId) {
return Material(
color: Colors.transparent,
child: InkWell(
child: SettingsTile(
onTap: () async {
await showCustomDialog(
context: context,
Expand Down Expand Up @@ -136,23 +137,17 @@ class _SetupAccountState extends State<SetupAccount> {
),
);
},
child: Padding(
padding: const EdgeInsets.symmetric(vertical: 6.0),
child: Row(
children: [
Text(
"Setup your account",
style: TextStyle(
fontSize: 16.0,
color: mainTextColor,
),
),
],
child: Text(
"Setup your account",
style: TextStyle(
fontSize: 16.0,
color: mainTextColor,
),
),
),
);
}

return const SizedBox.shrink();
},
);
Expand Down

0 comments on commit 3097dbe

Please sign in to comment.