Skip to content

Commit 0bd8ef6

Browse files
committed
use text value from .arb file all over app
1 parent cf49c86 commit 0bd8ef6

32 files changed

+624
-512
lines changed
Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,16 @@
11
import 'package:bloc/bloc.dart';
22
import 'package:equatable/equatable.dart';
3-
import 'package:flood_mobile/Pages/onboarding_main_screen/data/onboard_page_data.dart';
43
import 'package:flutter/material.dart';
54

65
part 'on_boarding_page_color_event.dart';
76
part 'on_boarding_page_color_state.dart';
87

98
class OnBoardingPageColorBloc
109
extends Bloc<OnBoardingPageColorEvent, OnBoardingPageColorState> {
11-
Color color = onboardData[0].accentColor;
12-
OnBoardingPageColorBloc() : super(OnBoardingPageColorInitial()) {
10+
OnBoardingPageColorBloc() : super(OnBoardingPageColorState.initial()) {
1311
on<SetColorEvent>((event, emit) {
14-
// Update the color variable with the new color
15-
color = event.color;
1612
// Emit a ColorUpdated state with the new color
17-
emit(ColorUpdated(color: event.color));
13+
emit(state.copyWith(color: event.color));
1814
});
1915
}
2016
}

lib/Blocs/onboarding_main_page_bloc/on_boarding_page_color_state.dart

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,15 @@
11
part of 'on_boarding_page_color_bloc.dart';
22

3-
abstract class OnBoardingPageColorState extends Equatable {
4-
const OnBoardingPageColorState();
5-
6-
@override
7-
List<Object> get props => [];
8-
}
3+
class OnBoardingPageColorState extends Equatable {
4+
final Color color;
95

10-
class OnBoardingPageColorInitial extends OnBoardingPageColorState {}
6+
OnBoardingPageColorState({required this.color});
117

12-
class ColorUpdated extends OnBoardingPageColorState {
13-
final Color color;
8+
factory OnBoardingPageColorState.initial() =>
9+
OnBoardingPageColorState(color: Color(0xff39C481));
1410

15-
ColorUpdated({required this.color});
11+
OnBoardingPageColorState copyWith({required Color? color}) =>
12+
OnBoardingPageColorState(color: color ?? this.color);
1613

1714
@override
1815
List<Object> get props => [color];

lib/Pages/about_screen/about_screen.dart

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import 'package:flood_mobile/l10n/l10n.dart';
12
import 'package:flutter/material.dart';
23
import 'package:flood_mobile/Blocs/theme_bloc/theme_bloc.dart';
34
import 'package:flutter_svg/flutter_svg.dart';
@@ -65,7 +66,7 @@ class _AboutScreenState extends State<AboutScreen> {
6566
crossAxisAlignment: CrossAxisAlignment.start,
6667
children: [
6768
Text(
68-
'Flood is a monitoring service for various torrent clients. It\'s a Node.js service that communicates with your favorite torrent client and serves a decent mobile UI for administration. This project is based on the original Flood project.',
69+
context.l10n.app_info,
6970
key: Key('App info text key'),
7071
style: TextStyle(
7172
color: ThemeBloc.theme(widget.themeIndex)
@@ -78,7 +79,7 @@ class _AboutScreenState extends State<AboutScreen> {
7879
height: 20,
7980
),
8081
Text(
81-
'Feedback',
82+
context.l10n.feedback_heading,
8283
style: TextStyle(
8384
color: ThemeBloc.theme(widget.themeIndex)
8485
.textTheme
@@ -91,7 +92,7 @@ class _AboutScreenState extends State<AboutScreen> {
9192
height: 10,
9293
),
9394
Text(
94-
'If you have a specific issue or bug, please file a GitHub issue. Please join the Flood Discord server to discuss feature requests and implementation details.',
95+
context.l10n.feedback_text,
9596
key: Key('Feedback text key'),
9697
style: TextStyle(
9798
color: ThemeBloc.theme(widget.themeIndex)
@@ -104,7 +105,7 @@ class _AboutScreenState extends State<AboutScreen> {
104105
height: 20,
105106
),
106107
Text(
107-
'More Information',
108+
context.l10n.more_info_text,
108109
style: TextStyle(
109110
color: ThemeBloc.theme(widget.themeIndex)
110111
.textTheme
@@ -117,7 +118,7 @@ class _AboutScreenState extends State<AboutScreen> {
117118
height: 10,
118119
),
119120
Text(
120-
'Check out the Wiki for more information.',
121+
context.l10n.check_out_info,
121122
key: Key('More info text key'),
122123
style: TextStyle(
123124
color: ThemeBloc.theme(widget.themeIndex)

lib/Pages/home_screen/home_screen.dart

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import 'package:flood_mobile/Pages/widgets/toast_component.dart';
1010
import 'package:flood_mobile/Blocs/home_screen_bloc/home_screen_bloc.dart';
1111
import 'package:flood_mobile/Blocs/multiple_select_torrent_bloc/multiple_select_torrent_bloc.dart';
1212
import 'package:flood_mobile/Blocs/theme_bloc/theme_bloc.dart';
13+
import 'package:flood_mobile/l10n/l10n.dart';
1314
import 'package:flutter/material.dart' hide Badge;
1415
import 'package:flutter/scheduler.dart';
1516
import 'package:flutter_bloc/flutter_bloc.dart';
@@ -156,7 +157,6 @@ class _HomeScreenState extends State<HomeScreen> {
156157
screenCurrent = SettingsScreen(themeIndex: themeIndex);
157158
break;
158159
case 4:
159-
print(position);
160160
screenCurrent = AboutScreen(themeIndex: themeIndex);
161161
break;
162162
}
@@ -175,7 +175,8 @@ class _HomeScreenState extends State<HomeScreen> {
175175
BlocProvider.of<MultipleSelectTorrentBloc>(context,
176176
listen: false);
177177
return WillPopScope(
178-
onWillPop: () => onBackPressed(timeBackPressed),
178+
onWillPop: () =>
179+
onBackPressed(timeBackPressed, context),
179180
child: Scaffold(
180181
appBar: AppBar(
181182
key: Key('AppBar $themeIndex'),
@@ -285,13 +286,14 @@ class _HomeScreenState extends State<HomeScreen> {
285286
}
286287
}
287288

288-
Future<bool> onBackPressed(DateTime timeBackPressed) async {
289+
Future<bool> onBackPressed(
290+
DateTime timeBackPressed, BuildContext context) async {
289291
final differnce = DateTime.now().difference(timeBackPressed);
290292
final isExitWarning = differnce >= Duration(seconds: 2);
291293
timeBackPressed = DateTime.now();
292294

293295
if (isExitWarning) {
294-
Toasts.showExitWarningToast(msg: 'Press back button again to exit');
296+
Toasts.showExitWarningToast(msg: context.l10n.home_screen_back_press_toast);
295297
return false;
296298
} else {
297299
Fluttertoast.cancel();

lib/Pages/home_screen/widgets/add_torrent_file.dart

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import 'dart:convert';
22
import 'package:flood_mobile/Api/torrent_api.dart';
33
import 'package:flood_mobile/Blocs/client_settings_bloc/client_settings_bloc.dart';
4+
import 'package:flood_mobile/l10n/l10n.dart';
45
import 'package:flutter/material.dart';
56
import 'package:flood_mobile/Blocs/theme_bloc/theme_bloc.dart';
67
import 'package:flutter_bloc/flutter_bloc.dart';
@@ -48,7 +49,7 @@ class _AddAutoTorrentState extends State<AddAutoTorrent> {
4849
Padding(
4950
padding: const EdgeInsets.only(right: 20, left: 20, bottom: 5),
5051
child: Text(
51-
"Selected Torrent File",
52+
context.l10n.selected_torrent_file,
5253
style: TextStyle(
5354
fontSize: 15,
5455
fontWeight: FontWeight.bold,
@@ -128,8 +129,8 @@ class _AddAutoTorrentState extends State<AddAutoTorrent> {
128129
.bodyLarge
129130
?.color,
130131
),
131-
labelText: 'Destination',
132-
hintText: 'Destination',
132+
labelText: context.l10n.textfield_destination_torrent,
133+
hintText: context.l10n.textfield_destination_torrent,
133134
labelStyle: TextStyle(
134135
fontFamily: 'Montserrat',
135136
color: ThemeBloc.theme(widget.themeIndex)
@@ -153,7 +154,7 @@ class _AddAutoTorrentState extends State<AddAutoTorrent> {
153154
borderRadius: BorderRadius.circular(8),
154155
),
155156
title: Text(
156-
'Use as Base Path',
157+
context.l10n.torrents_destination_base_path,
157158
style: TextStyle(fontSize: 14),
158159
),
159160
value: useAdBasePath,
@@ -172,7 +173,7 @@ class _AddAutoTorrentState extends State<AddAutoTorrent> {
172173
borderRadius: BorderRadius.circular(8),
173174
),
174175
title: Text(
175-
'Sequential Download',
176+
context.l10n.torrents_destination_sequential,
176177
style: TextStyle(fontSize: 14),
177178
),
178179
value: sequentialDownload,
@@ -191,7 +192,7 @@ class _AddAutoTorrentState extends State<AddAutoTorrent> {
191192
borderRadius: BorderRadius.circular(8),
192193
),
193194
title: Text(
194-
'Completed',
195+
context.l10n.torrents_destination_completed,
195196
style: TextStyle(fontSize: 14),
196197
),
197198
value: completed,
@@ -231,7 +232,7 @@ class _AddAutoTorrentState extends State<AddAutoTorrent> {
231232
),
232233
child: Center(
233234
child: Text(
234-
"Add Torrent",
235+
context.l10n.add_torrent_button,
235236
style: TextStyle(
236237
color: Colors.white,
237238
fontSize: 16,

lib/Pages/home_screen/widgets/logout_alert.dart

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import 'package:flood_mobile/l10n/l10n.dart';
12
import 'package:flutter/material.dart';
23
import 'package:flood_mobile/Blocs/theme_bloc/theme_bloc.dart';
34

@@ -23,7 +24,7 @@ class LogOutAlert extends StatelessWidget {
2324
),
2425
contentPadding: EdgeInsets.all(20),
2526
content: Text(
26-
'Are you sure you want to\n Log out ?',
27+
context.l10n.logout_confirm,
2728
textAlign: TextAlign.center,
2829
style: TextStyle(
2930
color: ThemeBloc.theme(themeIndex).textTheme.bodyLarge?.color,
@@ -52,7 +53,7 @@ class LogOutAlert extends StatelessWidget {
5253
Navigator.of(context, rootNavigator: true).pop();
5354
},
5455
child: Text(
55-
'No',
56+
context.l10n.button_no,
5657
style: TextStyle(
5758
color: Colors.white,
5859
),
@@ -74,7 +75,7 @@ class LogOutAlert extends StatelessWidget {
7475
),
7576
onPressed: logoutOnClick,
7677
child: Text(
77-
'Yes',
78+
context.l10n.button_yes,
7879
style: TextStyle(
7980
color: Colors.white,
8081
),

lib/Pages/home_screen/widgets/menu_widget.dart

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import 'package:flood_mobile/Blocs/theme_bloc/theme_bloc.dart';
22
import 'package:flood_mobile/Blocs/user_detail_bloc/user_detail_bloc.dart';
3+
import 'package:flood_mobile/l10n/l10n.dart';
34
import 'package:flutter/material.dart' hide Badge;
45
import 'package:flutter_bloc/flutter_bloc.dart';
56
import 'package:flutter_svg/svg.dart';
@@ -89,7 +90,7 @@ class _MenuState extends State<Menu> {
8990
widget.updatePosition(0);
9091
controller.toggle();
9192
},
92-
title: 'Torrents',
93+
title: context.l10n.menu_torrent_lable,
9394
themeIndex: widget.themeIndex,
9495
),
9596
NavDrawerListTile(
@@ -99,7 +100,7 @@ class _MenuState extends State<Menu> {
99100
widget.updatePosition(2);
100101
controller.toggle();
101102
},
102-
title: 'Settings',
103+
title: context.l10n.menu_settings_lable,
103104
themeIndex: widget.themeIndex,
104105
),
105106
NavDrawerListTile(
@@ -129,7 +130,7 @@ class _MenuState extends State<Menu> {
129130
),
130131
);
131132
},
132-
title: 'Logout',
133+
title: context.l10n.menu_logout_lable,
133134
themeIndex: widget.themeIndex,
134135
),
135136
NavDrawerListTile(
@@ -140,7 +141,7 @@ class _MenuState extends State<Menu> {
140141
'https://github.com/CCExtractor/Flood_Mobile#usage--screenshots',
141142
));
142143
},
143-
title: 'GitHub',
144+
title: context.l10n.menu_github_lable,
144145
themeIndex: widget.themeIndex,
145146
),
146147
NavDrawerListTile(
@@ -150,7 +151,7 @@ class _MenuState extends State<Menu> {
150151
widget.updatePosition(4);
151152
controller.toggle();
152153
},
153-
title: 'About',
154+
title: context.l10n.menu_about_lable,
154155
themeIndex: widget.themeIndex,
155156
),
156157
],

lib/Pages/home_screen/widgets/notification_popup_dialogue_container.dart

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import 'package:flood_mobile/Api/notifications_api.dart';
22
import 'package:flood_mobile/Model/notification_model.dart';
3+
import 'package:flood_mobile/l10n/l10n.dart';
34
import 'package:flutter/material.dart';
45
import 'package:flutter_bloc/flutter_bloc.dart';
56
import 'package:flood_mobile/Blocs/home_screen_bloc/home_screen_bloc.dart';
@@ -21,7 +22,7 @@ class NotificationPopupDialogueContainer extends StatelessWidget {
2122
color: ThemeBloc.theme(themeIndex).primaryColor,
2223
width: 300,
2324
child: Text(
24-
'No notifications to display',
25+
context.l10n.notification_no_notification,
2526
style: TextStyle(
2627
color:
2728
ThemeBloc.theme(themeIndex).textTheme.bodyLarge?.color,
@@ -46,16 +47,14 @@ class NotificationPopupDialogueContainer extends StatelessWidget {
4647
Divider(),
4748
TextButton(
4849
onPressed: () {
49-
// setState(() {
5050
NotificationApi.clearNotification(
5151
context: context);
52-
// });
5352
},
5453
style: TextButton.styleFrom(
5554
fixedSize: Size(200, 50),
5655
),
5756
child: Text(
58-
'Clear All',
57+
context.l10n.notification_clear_all,
5958
style: TextStyle(
6059
color: ThemeBloc.theme(themeIndex)
6160
.textTheme

lib/Pages/home_screen/widgets/popup_menu_buttons.dart

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import 'package:flood_mobile/Pages/widgets/delete_torrent_sheet.dart';
44
import 'package:flood_mobile/Blocs/home_screen_bloc/home_screen_bloc.dart';
55
import 'package:flood_mobile/Blocs/multiple_select_torrent_bloc/multiple_select_torrent_bloc.dart';
66
import 'package:flood_mobile/Blocs/theme_bloc/theme_bloc.dart';
7+
import 'package:flood_mobile/l10n/l10n.dart';
78
import 'package:flutter/material.dart';
89
import 'package:flutter_bloc/flutter_bloc.dart';
910

@@ -33,7 +34,7 @@ class _PopupMenuButtonsState extends State<PopupMenuButtons> {
3334
selectedTorrent.state.selectedTorrentList.toList().forEach((element) {
3435
hash.add(element.hash);
3536
});
36-
if (value == 'Select All') {
37+
if (value == context.l10n.multi_torrents_actions_select_all) {
3738
selectedTorrent.add(RemoveAllItemsFromListEvent());
3839
selectedTorrent.add(RemoveAllIndexFromListEvent());
3940
selectedTorrent.add(AddAllItemsToListEvent(
@@ -50,15 +51,15 @@ class _PopupMenuButtonsState extends State<PopupMenuButtons> {
5051
}
5152
selectedTorrent.add(AddAllIndexToListEvent(index: index));
5253
}
53-
if (value == 'Start') {
54+
if (value == context.l10n.multi_torrents_actions_start) {
5455
TorrentApi.startTorrent(hashes: hash, context: context);
5556
selectedTorrent.add(ChangeSelectionModeEvent());
5657
}
57-
if (value == 'Pause') {
58+
if (value == context.l10n.multi_torrents_actions_pause) {
5859
TorrentApi.stopTorrent(hashes: hash, context: context);
5960
selectedTorrent.add(ChangeSelectionModeEvent());
6061
}
61-
if (value == 'Delete') {
62+
if (value == context.l10n.multi_torrents_actions_delete) {
6263
deleteTorrent(
6364
context: context,
6465
indexes: selectedTorrent.state.selectedTorrentIndex,
@@ -67,7 +68,7 @@ class _PopupMenuButtonsState extends State<PopupMenuButtons> {
6768
);
6869
selectedTorrent.add(ChangeSelectionModeEvent());
6970
}
70-
if (value == "Set Tags") {
71+
if (value == context.l10n.multi_torrents_actions_set_tags) {
7172
showDialog(
7273
context: context,
7374
builder: (context) => AddTagDialogue(
@@ -85,11 +86,11 @@ class _PopupMenuButtonsState extends State<PopupMenuButtons> {
8586
},
8687
itemBuilder: (BuildContext context) {
8788
return {
88-
'Select All',
89-
'Start',
90-
'Pause',
91-
'Delete',
92-
'Set Tags',
89+
context.l10n.multi_torrents_actions_select_all,
90+
context.l10n.multi_torrents_actions_start,
91+
context.l10n.multi_torrents_actions_pause,
92+
context.l10n.multi_torrents_actions_delete,
93+
context.l10n.multi_torrents_actions_set_tags,
9394
}.map((String choice) {
9495
return PopupMenuItem<String>(
9596
value: choice,

0 commit comments

Comments
 (0)