Skip to content

Commit

Permalink
refactor: Removed unused strings, code cleaup
Browse files Browse the repository at this point in the history
  • Loading branch information
mateusz-bak committed Apr 12, 2024
1 parent 552499a commit f32b201
Show file tree
Hide file tree
Showing 9 changed files with 51 additions and 59 deletions.
8 changes: 0 additions & 8 deletions assets/translations/en-US.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@
"start_reading": "Start",
"rate_book": "Rate this book",
"skip": "Skip",
"reading_time": "Reading time",
"pages_uppercase": "Pages",
"pages_lowercase": "pages",
"click_to_add_cover": "Click to add cover",
Expand All @@ -63,7 +62,6 @@
"select_finish_date": "Select reading finish date",
"title_cannot_be_empty": "Title cannot be empty",
"author_cannot_be_empty": "Author cannot be empty",
"set_book_status": "Set book status",
"finish_date_before_start": "Finish date cannot be before start date",
"title": "Title",
"author": "Author",
Expand Down Expand Up @@ -99,7 +97,6 @@
"books_challenge": "Finished books challenge",
"pages_challenge": "Finished pages challenge",
"all_years": "All",
"no_finished_books": "No finished books",
"all_books_by_status": "All books by status",
"finished_books_by_month": "Finished books by month",
"finished_pages_by_month": "Finished pages by month",
Expand Down Expand Up @@ -207,7 +204,6 @@
"restore_backup_description_2": "Works for backups not older than from v1.14.2",
"are_you_sure": "Are you sure?",
"restore_backup_alert_content": "This will delete all your current books and challenges!",
"error_getting_book": "Error while getting the book",
"add_books_and_come_back": "Add some books and come here again",
"welcome_1": "Welcome to Openreads",
"welcome_1_description_1": "Openreads will help you keep track of your books.",
Expand Down Expand Up @@ -259,10 +255,6 @@
},
"set_custom_reading_time": "Set custom reading time",
"select_all": "Select all",
"tags": {
"one": "Tag",
"other": "Tags"
},
"general_search": "General",
"no_search_results": "No results found",
"click_to_add_book_manually": "Click here to add the book manually",
Expand Down
5 changes: 0 additions & 5 deletions lib/generated/locale_keys.g.dart
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ abstract class LocaleKeys {
static const start_reading = 'start_reading';
static const rate_book = 'rate_book';
static const skip = 'skip';
static const reading_time = 'reading_time';
static const pages_uppercase = 'pages_uppercase';
static const pages_lowercase = 'pages_lowercase';
static const click_to_add_cover = 'click_to_add_cover';
Expand All @@ -65,7 +64,6 @@ abstract class LocaleKeys {
static const select_finish_date = 'select_finish_date';
static const title_cannot_be_empty = 'title_cannot_be_empty';
static const author_cannot_be_empty = 'author_cannot_be_empty';
static const set_book_status = 'set_book_status';
static const finish_date_before_start = 'finish_date_before_start';
static const title = 'title';
static const author = 'author';
Expand Down Expand Up @@ -100,7 +98,6 @@ abstract class LocaleKeys {
static const books_challenge = 'books_challenge';
static const pages_challenge = 'pages_challenge';
static const all_years = 'all_years';
static const no_finished_books = 'no_finished_books';
static const all_books_by_status = 'all_books_by_status';
static const finished_books_by_month = 'finished_books_by_month';
static const finished_pages_by_month = 'finished_pages_by_month';
Expand Down Expand Up @@ -211,7 +208,6 @@ abstract class LocaleKeys {
static const restore_backup_description_2 = 'restore_backup_description_2';
static const are_you_sure = 'are_you_sure';
static const restore_backup_alert_content = 'restore_backup_alert_content';
static const error_getting_book = 'error_getting_book';
static const add_books_and_come_back = 'add_books_and_come_back';
static const welcome_1 = 'welcome_1';
static const welcome_1_description_1 = 'welcome_1_description_1';
Expand Down Expand Up @@ -257,7 +253,6 @@ abstract class LocaleKeys {
static const set_custom_reading_time = 'set_custom_reading_time';
static const select_all = 'select_all';
static const only_editions_with_covers = 'only_editions_with_covers';
static const tags = 'tags';
static const general_search = 'general_search';
static const no_search_results = 'no_search_results';
static const click_to_add_book_manually = 'click_to_add_book_manually';
Expand Down
13 changes: 10 additions & 3 deletions lib/ui/add_book_screen/add_book_screen.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import 'dart:io';
import 'package:barcode_scan2/gen/protos/protos.pbenum.dart';
import 'package:barcode_scan2/platform_wrapper.dart';
import 'package:barcode_scan2/barcode_scan2.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
Expand Down Expand Up @@ -565,7 +564,15 @@ class _AddBookScreenState extends State<AddBookScreen> {
borderRadius: BorderRadius.circular(cornerRadius),
),
onTap: () async {
var result = await BarcodeScanner.scan();
var result = await BarcodeScanner.scan(
options: ScanOptions(
strings: {
'cancel': LocaleKeys.cancel.tr(),
'flash_on': LocaleKeys.flash_on.tr(),
'flash_off': LocaleKeys.flash_off.tr(),
},
),
);

if (result.type == ResultType.Barcode) {
setState(() {
Expand Down
1 change: 0 additions & 1 deletion lib/ui/search_ol_screen/search_ol_screen.dart.dart
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import 'package:barcode_scan2/barcode_scan2.dart';
import 'package:easy_localization/easy_localization.dart';
import 'package:flutter/material.dart';
import 'package:flutter/rendering.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:infinite_scroll_pagination/infinite_scroll_pagination.dart';
import 'package:loading_animation_widget/loading_animation_widget.dart';
Expand Down
48 changes: 35 additions & 13 deletions lib/ui/similiar_books_screen/similiar_books_screen.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import 'package:easy_localization/easy_localization.dart';
import 'package:flex_color_picker/flex_color_picker.dart';
import 'package:flutter/material.dart';
import 'package:openreads/core/themes/app_theme.dart';
import 'package:openreads/generated/locale_keys.g.dart';
import 'package:openreads/main.dart';
import 'package:openreads/model/book.dart';
Expand Down Expand Up @@ -38,24 +38,22 @@ class _SimiliarBooksScreenState extends State<SimiliarBooksScreen> {
title: Row(
children: [
widget.tag != null
? Text(
'${LocaleKeys.tags.plural(1).capitalize.tr()}: ',
style: const TextStyle(fontSize: 18),
)
? const SizedBox()
: widget.author != null
? Text(
'${LocaleKeys.author.tr()}: ',
style: const TextStyle(fontSize: 18),
)
: const SizedBox(),
Text(
widget.tag != null
? widget.tag!
: widget.author != null
? widget.author!
: '',
style: const TextStyle(fontSize: 18, fontWeight: FontWeight.bold),
),
widget.tag != null
? _buildTag(widget.tag!)
: widget.author != null
? Text(
widget.author!,
style: const TextStyle(
fontSize: 18, fontWeight: FontWeight.bold),
)
: const SizedBox(),
],
),
),
Expand All @@ -81,4 +79,28 @@ class _SimiliarBooksScreenState extends State<SimiliarBooksScreen> {
}),
);
}

Widget _buildTag(String tag) {
return Padding(
padding: const EdgeInsets.symmetric(horizontal: 5),
child: FilterChip(
backgroundColor: Theme.of(context).colorScheme.secondary,
side: BorderSide(
color: dividerColor,
width: 1,
),
label: Text(
tag,
overflow: TextOverflow.fade,
softWrap: true,
maxLines: 5,
style: TextStyle(
color: Theme.of(context).colorScheme.onSecondary,
),
),
clipBehavior: Clip.none,
onSelected: (_) {},
),
);
}
}
16 changes: 0 additions & 16 deletions lib/ui/statistics_screen/widgets/statistics.dart
Original file line number Diff line number Diff line change
Expand Up @@ -158,14 +158,6 @@ class Statistics extends StatelessWidget {
builder: (context, challengeState) {
if (challengeState is SetChallengeState &&
challengeState.yearlyChallenges != null) {
if (state.finishedBooksByMonthAllTypes.isEmpty) {
return Center(
child: Text(
LocaleKeys.no_finished_books.tr(),
),
);
}

final yearlyChallenges = List<YearlyChallenge>.empty(
growable: true,
);
Expand Down Expand Up @@ -233,14 +225,6 @@ class Statistics extends StatelessWidget {
builder: (context, challengeState) {
if (challengeState is SetChallengeState &&
challengeState.yearlyChallenges != null) {
if (state.finishedPagesByMonthAllTypes.isEmpty) {
return Center(
child: Text(
LocaleKeys.no_finished_books.tr(),
),
);
}

final yearlyChallenges = List<YearlyChallenge>.empty(
growable: true,
);
Expand Down
4 changes: 2 additions & 2 deletions lib/ui/welcome_screen/welcome_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -215,8 +215,8 @@ class _WelcomeScreenState extends State<WelcomeScreen> {
controller: _controller,
count: 4,
effect: ExpandingDotsEffect(
activeDotColor: widget.themeData.colorScheme.primary,
dotColor: widget.themeData.colorScheme.surfaceVariant,
activeDotColor: Theme.of(context).colorScheme.primary,
dotColor: Theme.of(context).colorScheme.surfaceVariant,
dotHeight: 12,
dotWidth: 12,
),
Expand Down
6 changes: 3 additions & 3 deletions lib/ui/welcome_screen/widgets/welcome_choice_button.dart
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,15 @@ class WelcomeChoiceButton extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Padding(
padding: const EdgeInsets.only(bottom: 20),
padding: const EdgeInsets.only(bottom: 10),
child: Row(
children: [
Expanded(
child: FilledButton.tonal(
style: ButtonStyle(
backgroundColor: isSkipImporting
? MaterialStateProperty.all(
Theme.of(context).colorScheme.secondary,
Theme.of(context).colorScheme.primary,
)
: MaterialStateProperty.all(
Theme.of(context)
Expand Down Expand Up @@ -64,7 +64,7 @@ class WelcomeChoiceButton extends StatelessWidget {
child: Text(
description,
style: TextStyle(
fontSize: isSkipImporting ? 20 : 18,
fontSize: 16,
fontWeight: isSkipImporting
? FontWeight.bold
: FontWeight.normal,
Expand Down
9 changes: 1 addition & 8 deletions lib/ui/welcome_screen/widgets/welcome_page_choices.dart
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,6 @@ class WelcomePageChoices extends StatelessWidget {
final Function() importBookwyrmCsv;
final Function() skipImportingBooks;

static List<String> choices = [
LocaleKeys.restore_backup.tr(),
LocaleKeys.import_csv.tr(),
LocaleKeys.import_goodreads_csv.tr(),
LocaleKeys.import_bookwyrm_csv.tr(),
LocaleKeys.add_books_and_come_back.tr(),
];

@override
Widget build(BuildContext context) {
return Padding(
Expand Down Expand Up @@ -55,6 +47,7 @@ class WelcomePageChoices extends StatelessWidget {
child: SingleChildScrollView(
child: Column(
children: [
const SizedBox(height: 20),
WelcomeChoiceButton(
description: LocaleKeys.restore_backup.tr(),
onPressed: restoreBackup,
Expand Down

0 comments on commit f32b201

Please sign in to comment.