Skip to content

Commit

Permalink
Refactoring: use of AppTextThemeExtension
Browse files Browse the repository at this point in the history
  • Loading branch information
J-Pabon committed Aug 11, 2023
1 parent 51332dc commit 7f79e18
Show file tree
Hide file tree
Showing 33 changed files with 834 additions and 1,080 deletions.
10 changes: 5 additions & 5 deletions lib/app/mixins/repo_actions_mixin.dart
Original file line number Diff line number Diff line change
Expand Up @@ -540,15 +540,15 @@ mixin RepositoryActionsMixin on AppLogger {
context: context,
title: S.current.titleSaveChanges,
body: [
Text(message)
Text(message, style: context.theme.appTextStyle.bodyMedium)
],
actions: [
TextButton(
child: Text(positiveButtonText),
onPressed: () => Navigator.of(context).pop(true)),
child: Text(S.current.actionCancel.toUpperCase()),
onPressed: () => Navigator.of(context).pop(false)),
TextButton(
child: Text(S.current.actionCancel),
onPressed: () => Navigator.of(context).pop(false))
child: Text(positiveButtonText.toUpperCase()),
onPressed: () => Navigator.of(context).pop(true))
]);

return saveChanges;
Expand Down
21 changes: 4 additions & 17 deletions lib/app/pages/accept_eq_values_terms_privacy_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -21,21 +21,6 @@ class AcceptEqualitieValuesTermsPrivacyPage extends StatefulWidget {

class _AcceptEqualitieValuesTermsPrivacyPageState
extends State<AcceptEqualitieValuesTermsPrivacyPage> {
TextStyle? introTextStyle;
TextStyle? bodyTextStyle;
TextStyle? byTextStyle;

@override
void didChangeDependencies() {
super.didChangeDependencies();

introTextStyle = Theme.of(context).textTheme.titleMedium;
bodyTextStyle = Theme.of(context).textTheme.bodyMedium;
byTextStyle = TextStyle(
fontSize: (bodyTextStyle?.fontSize ?? 10.0) * 0.8,
color: Colors.black54);
}

@override
Widget build(BuildContext context) => Scaffold(
appBar: PlatformValues.isMobileDevice
Expand Down Expand Up @@ -66,14 +51,16 @@ class _AcceptEqualitieValuesTermsPrivacyPageState
width: MediaQuery.of(context).size.width * 0.6),
Padding(
padding: EdgeInsets.only(bottom: 10.0),
child: Text(S.current.messageBy, style: byTextStyle)),
child: Text(S.current.messageBy,
style: context.theme.appTextStyle.bodyMicro
.copyWith(color: Colors.black54))),
Image.asset(Constants.eQLogo,
width: MediaQuery.of(context).size.width * 0.2)
]);

Widget _introTextSpan() => RichText(
textAlign: TextAlign.start,
text: TextSpan(style: bodyTextStyle, children: [
text: TextSpan(style: context.theme.appTextStyle.bodyMedium, children: [
Fields.boldTextSpan(S.current.titleAppTitle),
TextSpan(text: ' ${S.current.messageEqualitieValues}')
]));
Expand Down
22 changes: 6 additions & 16 deletions lib/app/pages/add_repository_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -24,28 +24,17 @@ class _AddRepositoryPageState extends State<AddRepositoryPage> with AppLogger {

final _isDesktop = PlatformValues.isDesktopDevice;

TextStyle? titleStyle;
TextStyle? bodyStyle;
TextStyle? bodySmallStyle;

@override
Widget build(BuildContext context) {
final noReposImageHeight = MediaQuery.of(context).size.height * 0.2;

titleStyle = Theme.of(context).textTheme.titleLarge;
bodyStyle = Theme.of(context).textTheme.bodyMedium;
bodySmallStyle = Theme.of(context)
.textTheme
.bodySmall
?.copyWith(fontWeight: FontWeight.w700);

return Scaffold(
appBar: AppBar(
title: Text(S.current.titleAddRepoToken),
elevation: 0.0,
backgroundColor: Colors.transparent,
foregroundColor: Colors.black87,
titleTextStyle: titleStyle),
titleTextStyle: context.theme.appTextStyle.titleMedium),
body: Form(
key: formKey,
autovalidateMode: AutovalidateMode.disabled,
Expand All @@ -70,15 +59,15 @@ class _AddRepositoryPageState extends State<AddRepositoryPage> with AppLogger {
crossAxisAlignment: WrapCrossAlignment.center,
children: [
Row(children: [
Fields.constrainedText(S.current.messageAddRepoQR,
flex: 0, style: bodyStyle)
Fields.constrainedText(S.current.messageAddRepoQR, flex: 0)
]),
if (_isDesktop)
Row(children: [
Fields.constrainedText(
'(${S.current.messageAvailableOnMobile})',
flex: 0,
style: bodySmallStyle)
style: context.theme.appTextStyle.bodySmall
.copyWith(fontWeight: FontWeight.w700))
])
]),
Dimensions.spacingVerticalDouble,
Expand Down Expand Up @@ -143,7 +132,8 @@ class _AddRepositoryPageState extends State<AddRepositoryPage> with AppLogger {
thickness: 1.0, endIndent: 20.0, color: Colors.black26)),
Text(
S.current.messageOr.toUpperCase(),
style: const TextStyle(fontWeight: FontWeight.w500),
style: context.theme.appTextStyle.bodySmall
.copyWith(fontWeight: FontWeight.bold),
),
const Expanded(
child: Divider(
Expand Down
14 changes: 2 additions & 12 deletions lib/app/pages/onboarding_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -30,20 +30,10 @@ class _OnboardingPageState extends State<OnboardingPage> {

@override
Widget build(BuildContext context) {
final titleFontSize = Theme.of(context).textTheme.titleLarge?.fontSize;
final titleFontWeight = Theme.of(context).textTheme.titleLarge?.fontWeight;
final titleStyle =
TextStyle(fontSize: titleFontSize, fontWeight: titleFontWeight);

final bodyFontSize = Theme.of(context).textTheme.bodyMedium?.fontSize;
final bodyFontWeight = Theme.of(context).textTheme.bodyMedium?.fontWeight;
final bodyStyle =
TextStyle(fontSize: bodyFontSize, fontWeight: bodyFontWeight);

final pageDecoration = PageDecoration(
titleTextStyle: titleStyle,
titleTextStyle: context.theme.appTextStyle.titleLarge,
bodyAlignment: Alignment.center,
bodyTextStyle: bodyStyle,
bodyTextStyle: context.theme.appTextStyle.bodyMedium,
bodyPadding: EdgeInsets.fromLTRB(16.0, 0.0, 16.0, 16.0),
imagePadding: EdgeInsets.zero);

Expand Down
10 changes: 2 additions & 8 deletions lib/app/pages/peer_list.dart
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,7 @@ class PeerList extends StatelessWidget {

@override
Widget build(BuildContext context) {
final microFontSize =
(Theme.of(context).textTheme.bodySmall?.fontSize ?? 0) * 0.8;

bodyMicroStyle = Theme.of(context)
.textTheme
.bodySmall
?.copyWith(fontSize: microFontSize);
bodyMicroStyle = context.theme.appTextStyle.bodyMicro;

return Scaffold(
appBar: AppBar(title: Text(S.current.labelPeers)),
Expand Down Expand Up @@ -47,7 +41,7 @@ class PeerList extends StatelessWidget {
);

TableRow _buildHeaderRow(BuildContext context) {
final style = Theme.of(context).textTheme.titleSmall;
final style = context.theme.appTextStyle.titleSmall;

return TableRow(children: <TableCell>[
_buildCell(Text('IP', style: style)),
Expand Down
46 changes: 19 additions & 27 deletions lib/app/pages/repo_qr_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -16,32 +16,20 @@ class RepositoryQRPage extends StatefulWidget {
}

class _RepositoryQRPageState extends State<RepositoryQRPage> {
TextStyle? titleStyle;
TextStyle? bodyStyle;

@override
Widget build(BuildContext context) {
titleStyle =
Theme.of(context).textTheme.titleLarge?.copyWith(color: Colors.white);
bodyStyle =
Theme.of(context).textTheme.bodyMedium?.copyWith(color: Colors.white);

return Scaffold(
appBar: AppBar(
leading: Fields.actionIcon(
const Icon(Icons.close, color: Colors.white),
onPressed: () => Navigator.of(context).pop()),
elevation: 0.0,
backgroundColor: Colors.transparent),
backgroundColor: Theme.of(context).primaryColorDark,
body: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
_getQRCodeImage(widget.shareLink),
_buildShareMessage()
])));
}
Widget build(BuildContext context) => Scaffold(
appBar: AppBar(
leading: Fields.actionIcon(
const Icon(Icons.close, color: Colors.white),
onPressed: () => Navigator.of(context).pop()),
elevation: 0.0,
backgroundColor: Colors.transparent),
backgroundColor: Theme.of(context).primaryColorDark,
body: Center(
child: Column(mainAxisAlignment: MainAxisAlignment.center, children: [
_getQRCodeImage(widget.shareLink),
_buildShareMessage()
])));

Widget _getQRCodeImage(String tokenLink) {
double qrCodeSize = 0.0;
Expand Down Expand Up @@ -70,10 +58,14 @@ class _RepositoryQRPageState extends State<RepositoryQRPage> {
padding: Dimensions.paddingTop40,
child: Column(children: [
Text(S.current.messageShareWithWR,
textAlign: TextAlign.center, style: titleStyle),
textAlign: TextAlign.center,
style: context.theme.appTextStyle.titleLarge
.copyWith(color: Colors.white)),
Dimensions.spacingVertical,
Text(S.current.messageScanQROrShare,
textAlign: TextAlign.center, style: bodyStyle)
textAlign: TextAlign.center,
style: context.theme.appTextStyle.bodyMedium
.copyWith(color: Colors.white))
]));
}
}
37 changes: 16 additions & 21 deletions lib/app/pages/repository_security_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,6 @@ class _RepositorySecurityState extends State<RepositorySecurity>

final FocusNode _passwordAction = FocusNode(debugLabel: 'password_input');

TextStyle? bodyStyle;

@override
void initState() {
security = SecurityCubit.create(
Expand All @@ -58,27 +56,23 @@ class _RepositorySecurityState extends State<RepositorySecurity>
}

@override
Widget build(BuildContext context) {
bodyStyle = Theme.of(context).textTheme.bodyMedium;

return Scaffold(
appBar: AppBar(title: Text(S.current.titleSecurity), elevation: 0.0),
body: SingleChildScrollView(
child: Container(
child: BlocBuilder<SecurityCubit, SecurityState>(
bloc: security,
builder: (context, state) => Column(children: [
_pasword(state),
Divider(height: 30.0),
_biometrics(state)
])))));
}
Widget build(BuildContext context) => Scaffold(
appBar: AppBar(title: Text(S.current.titleSecurity), elevation: 0.0),
body: SingleChildScrollView(
child: Container(
child: BlocBuilder<SecurityCubit, SecurityState>(
bloc: security,
builder: (context, state) => Column(children: [
_pasword(state),
Divider(height: 30.0),
_biometrics(state)
])))));

Widget _pasword(SecurityState state) {
return Container(
padding: Dimensions.paddingDialog,
child: Column(crossAxisAlignment: CrossAxisAlignment.start, children: [
Text(state.passwordModeTitle, style: bodyStyle),
Text(state.passwordModeTitle),
Dimensions.spacingVerticalDouble,
PasswordValidation(
passwordMode: state.passwordMode,
Expand All @@ -99,8 +93,8 @@ class _RepositorySecurityState extends State<RepositorySecurity>
TextButton(
focusNode: _passwordAction,
child: Text(S.current.actionRemoveLocalPassword,
style:
bodyStyle?.copyWith(color: Constants.dangerColor)),
style: context.theme.appTextStyle.bodyMedium
.copyWith(color: Constants.dangerColor)),
onPressed: () async {
final positiveButtonText = S.current.actionRemove;
final confirmationMessage =
Expand All @@ -118,6 +112,7 @@ class _RepositorySecurityState extends State<RepositorySecurity>
f: _removePassword());
})
]),
Dimensions.spacingVertical,
Row(mainAxisAlignment: MainAxisAlignment.center, children: [
Fields.inPageButton(
onPressed: () async {
Expand Down Expand Up @@ -191,7 +186,7 @@ class _RepositorySecurityState extends State<RepositorySecurity>
secondary:
Icon(Icons.fingerprint_rounded, color: Colors.black),
title: Text(S.current.messageUnlockUsingBiometrics,
style: bodyStyle),
style: context.theme.appTextStyle.bodyMedium),
onChanged: (useBiometrics) async {
final positiveButtonText = S.current.actionAccept;
String confirmationMessage = useBiometrics
Expand Down
Loading

0 comments on commit 7f79e18

Please sign in to comment.