Skip to content

Commit

Permalink
[Presentation] Show icons instead of text in the 'about' section
Browse files Browse the repository at this point in the history
  • Loading branch information
Wolfteam committed Feb 27, 2022
1 parent 1fcb127 commit b862a4b
Show file tree
Hide file tree
Showing 3 changed files with 124 additions and 30 deletions.
4 changes: 2 additions & 2 deletions lib/presentation/custom_build/widgets/character_section.dart
Expand Up @@ -101,7 +101,7 @@ class CharacterSection extends StatelessWidget {
onPressed: () => showDialog(
context: context,
builder: (_) => TextDialog.update(
title: s.title,
hintText: s.title,
value: state.title,
maxLength: CustomBuildBloc.maxTitleLength,
onSave: (newTitle) => context.read<CustomBuildBloc>().add(CustomBuildEvent.titleChanged(newValue: newTitle)),
Expand Down Expand Up @@ -303,7 +303,7 @@ class _NoteRow extends StatelessWidget {
: () => showDialog(
context: context,
builder: (_) => TextDialog.create(
title: s.note,
hintText: s.note,
onSave: (note) => context.read<CustomBuildBloc>().add(CustomBuildEvent.addNote(note: note)),
maxLength: CustomBuildBloc.maxNoteLength,
),
Expand Down
91 changes: 79 additions & 12 deletions lib/presentation/settings/widgets/about_settings_card.dart
@@ -1,12 +1,17 @@
import 'dart:io';

import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:shiori/application/bloc.dart';
import 'package:shiori/domain/app_constants.dart';
import 'package:shiori/generated/l10n.dart';
import 'package:shiori/presentation/donations/donations_bottom_sheet.dart';
import 'package:shiori/presentation/shared/dialogs/changelog_dialog.dart';
import 'package:shiori/presentation/shared/loading.dart';
import 'package:shiori/presentation/shared/shiori_icons.dart';
import 'package:shiori/presentation/shared/styles.dart';
import 'package:shiori/presentation/shared/text_link.dart';
import 'package:url_launcher/url_launcher.dart';

import 'settings_card.dart';

Expand All @@ -15,6 +20,7 @@ class AboutSettingsCard extends StatelessWidget {
Widget build(BuildContext context) {
final s = S.of(context);
final textTheme = Theme.of(context).textTheme;
final showDonationsButton = !kIsWeb && Platform.isAndroid;

return SettingsCard(
child: Column(
Expand Down Expand Up @@ -70,12 +76,63 @@ class AboutSettingsCard extends StatelessWidget {
},
),
Text(s.aboutSummary, textAlign: TextAlign.center),
TextLink.withoutLink(
text: 'Changelog',
onTap: () => showDialog(context: context, builder: (ctx) => const ChangelogDialog()),
Wrap(
alignment: WrapAlignment.center,
crossAxisAlignment: WrapCrossAlignment.center,
children: [
if (showDonationsButton)
Tooltip(
message: s.donations,
child: IconButton(
splashRadius: Styles.mediumButtonSplashRadius,
icon: const Icon(Shiori.heart, color: Colors.red),
onPressed: () => _showDonationsDialog(context),
),
),
Tooltip(
message: s.changelog,
child: IconButton(
splashRadius: Styles.mediumButtonSplashRadius,
icon: const Icon(Icons.list_alt, color: Colors.blueGrey),
onPressed: () => showDialog(context: context, builder: (ctx) => const ChangelogDialog()),
),
),
Tooltip(
message: 'Discord',
child: IconButton(
splashRadius: Styles.mediumButtonSplashRadius,
icon: const Icon(Shiori.discord, color: Color.fromARGB(255, 88, 101, 242)),
onPressed: () => _launchUrl('https://discord.gg/A8SgudQMwP'),
),
),
Tooltip(
message: 'GitHub',
child: IconButton(
splashRadius: Styles.mediumButtonSplashRadius,
icon: const Icon(Shiori.github_circled),
onPressed: () => _launchUrl('$githubPage/issues'),
),
),
Tooltip(
message: s.email,
child: IconButton(
splashRadius: Styles.mediumButtonSplashRadius,
icon: const Icon(Icons.email, color: Colors.blue),
onPressed: () => _launchUrl(
'mailto:miraisoft20@gmail.com?subject=The subject of the email&body=Please write your email in english / spanish',
),
),
),
Tooltip(
message: s.otherApps,
child: IconButton(
splashRadius: Styles.mediumButtonSplashRadius,
icon: const Icon(Shiori.globe_1, color: Colors.green),
onPressed: () => _launchUrl('https://wolfteam.github.io'),
),
),
],
),
TextLink(text: s.discordServer, url: 'https://discord.gg/A8SgudQMwP'),
TextLink(text: s.otherApps, url: 'https://wolfteam.github.io'),
Container(
margin: const EdgeInsets.only(top: 10),
child: Text(
Expand Down Expand Up @@ -115,17 +172,27 @@ class AboutSettingsCard extends StatelessWidget {
margin: const EdgeInsets.only(top: 5),
child: Text(s.supportMsg),
),
const TextLink(text: 'GitHub', url: '$githubPage/issues'),
Container(
margin: const EdgeInsets.only(top: 5),
child: Text('${s.youCanAlsoSendMeAnEmail}:', textAlign: TextAlign.center),
),
const TextLink(text: 'miraisoft20@gmail.com', url: 'mailto:miraisoft20@gmail.com?subject=Subject&body=Hiho'),
],
),
),
],
),
);
}

Future<void> _launchUrl(String url) async {
if (await canLaunch(url)) {
await launch(url);
}
}

Future<void> _showDonationsDialog(BuildContext context) {
return showModalBottomSheet(
context: context,
shape: Styles.modalBottomSheetShape,
isDismissible: true,
isScrollControlled: true,
builder: (ctx) => const DonationsBottomSheet(),
);
}
}
59 changes: 43 additions & 16 deletions lib/presentation/shared/dialogs/text_dialog.dart
Expand Up @@ -5,27 +5,33 @@ import 'package:shiori/generated/l10n.dart';
import 'package:shiori/presentation/shared/extensions/media_query_extensions.dart';

class TextDialog extends StatefulWidget {
final String title;
final String? title;
final String hintText;
final String? value;
final int maxLength;
final Function(String) onSave;
final bool isInEditMode;
final Widget? child;

const TextDialog.create({
Key? key,
required this.title,
this.title,
required this.hintText,
required this.onSave,
required this.maxLength,
this.child,
}) : value = '',
isInEditMode = false,
super(key: key);

const TextDialog.update({
Key? key,
required this.title,
this.title,
required this.hintText,
required this.value,
required this.maxLength,
required this.onSave,
this.child,
}) : isInEditMode = true,
super(key: key);

Expand Down Expand Up @@ -58,24 +64,45 @@ class _TextDialogState extends State<TextDialog> {
final theme = Theme.of(context);
final s = S.of(context);
final mq = MediaQuery.of(context);
final title = widget.title.isNotNullEmptyOrWhitespace
? widget.title!
: widget.isInEditMode
? s.edit
: s.add;

final decoration = InputDecoration(
hintText: widget.hintText,
alignLabelWithHint: true,
labelText: widget.hintText,
errorText: !_isValid && _isDirty ? s.invalidValue : null,
);

return AlertDialog(
scrollable: true,
title: Text(widget.isInEditMode ? s.edit : s.add),
title: Text(title),
content: SizedBox(
width: mq.getWidthForDialogs(),
child: TextField(
maxLength: widget.maxLength,
controller: _textEditingController,
autofocus: true,
maxLengthEnforcement: MaxLengthEnforcement.enforced,
decoration: InputDecoration(
hintText: widget.title,
alignLabelWithHint: true,
labelText: widget.title,
errorText: !_isValid && _isDirty ? s.invalidValue : null,
),
),
child: widget.child == null
? TextField(
maxLength: widget.maxLength,
controller: _textEditingController,
autofocus: true,
maxLengthEnforcement: MaxLengthEnforcement.enforced,
decoration: decoration,
)
: Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
TextField(
maxLength: widget.maxLength,
controller: _textEditingController,
autofocus: true,
maxLengthEnforcement: MaxLengthEnforcement.enforced,
decoration: decoration,
),
widget.child!,
],
),
),
actions: [
OutlinedButton(
Expand Down

0 comments on commit b862a4b

Please sign in to comment.