diff --git a/.github/workflows/dart.yml b/.github/workflows/dart.yml index a9f98e1..48bc743 100644 --- a/.github/workflows/dart.yml +++ b/.github/workflows/dart.yml @@ -2,9 +2,9 @@ name: Flutter CI on: push: - branches: [ master , develop ] + branches: [master, develop] pull_request: - branches: [ master , develop ] + branches: [master, develop] jobs: build: @@ -14,10 +14,10 @@ jobs: - uses: actions/checkout@v2 - uses: actions/setup-java@v1 with: - java-version: '12.x' + java-version: "12.x" - uses: subosito/flutter-action@v1 with: - flutter-version: '3.10.5' + flutter-version: "3.13.1" - run: flutter pub get - run: flutter gen-l10n --arb-dir=lib/l10n/arb - run: flutter analyze diff --git a/lib/Api/event_handler_api.dart b/lib/Api/event_handler_api.dart index 94abb77..b643413 100644 --- a/lib/Api/event_handler_api.dart +++ b/lib/Api/event_handler_api.dart @@ -2,6 +2,7 @@ import 'dart:collection'; import 'dart:convert'; import 'dart:io'; import 'package:battery_plus/battery_plus.dart'; +import 'package:connectivity_plus/connectivity_plus.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/services.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; @@ -96,6 +97,7 @@ class EventHandlerApi { newTorrentMap, strict: true, ); + //Updating data in provider BlocProvider.of(context, listen: false) .add(SetTorrentListJsonEvent(newTorrentListJson: newTorrentListJson)); @@ -119,7 +121,7 @@ class EventHandlerApi { if (torrentList.length > int.parse(torrentLength) || torrentList.length < int.parse(torrentLength)) { - filterDataRephrasor(torrentList, context); + await filterDataRephrasor(torrentList, context); } //Setting the full list of torrent @@ -128,6 +130,7 @@ class EventHandlerApi { final PowerManagementBloc powerManagementBloc = BlocProvider.of(context, listen: false); + //Exit screen on all download finished if (powerManagementBloc.state.shutDownWhenFinishDownload && isAllDownloadFinished(context)) { @@ -138,7 +141,15 @@ class EventHandlerApi { //Turn off wifi on all download finished if (powerManagementBloc.state.shutDownWifi && isAllDownloadFinished(context)) { - turnOffWiFi(powerManagementBloc.state.shutDownWifi); + await turnOffWiFi(powerManagementBloc.state.shutDownWifi); + } + + //Stop all download on wifi disconnect + if (powerManagementBloc.state.wifiOnlyDownload) { + final connectivityResult = await Connectivity().checkConnectivity(); + if (connectivityResult != ConnectivityResult.wifi) { + await stopAllDownload(context); + } } // Stop all download on low battery @@ -148,14 +159,7 @@ class EventHandlerApi { powerManagementBloc.state.batteryLimitLevel > 0 ? true : false; if (isBatteryLimitSet && currentBatteryLevel <= powerManagementBloc.state.batteryLimitLevel) { - BlocProvider.of(context, listen: false) - .state - .torrentList - .forEach((element) { - if (element.status.contains('downloading')) { - TorrentApi.stopTorrent(hashes: [element.hash], context: context); - } - }); + await stopAllDownload(context); } } @@ -286,6 +290,17 @@ bool isAllDownloadFinished(BuildContext context) { ); } -void turnOffWiFi(bool wifiStatus) async { - WiFiForIoTPlugin.setEnabled(!wifiStatus); +Future turnOffWiFi(bool wifiStatus) async { + await WiFiForIoTPlugin.setEnabled(!wifiStatus); +} + +Future stopAllDownload(BuildContext context) async { + BlocProvider.of(context, listen: false) + .state + .torrentList + .forEach((element) async { + if (element.status.contains('downloading')) { + await TorrentApi.stopTorrent(hashes: [element.hash], context: context); + } + }); } diff --git a/lib/Blocs/language_bloc/language_bloc.dart b/lib/Blocs/language_bloc/language_bloc.dart index 7183591..4f1b273 100644 --- a/lib/Blocs/language_bloc/language_bloc.dart +++ b/lib/Blocs/language_bloc/language_bloc.dart @@ -27,7 +27,8 @@ class LanguageBloc extends Bloc { Future getPreviousLang() async { try { final prefs = await SharedPreferences.getInstance(); - if (prefs.getString('languageCode') != 'null') + if (prefs.containsKey('languageCode') && + prefs.getString('languageCode') != 'null') return Locale(prefs.getString('languageCode')!); else { return null; diff --git a/lib/Blocs/theme_bloc/theme_bloc.dart b/lib/Blocs/theme_bloc/theme_bloc.dart index 311309b..5c06141 100644 --- a/lib/Blocs/theme_bloc/theme_bloc.dart +++ b/lib/Blocs/theme_bloc/theme_bloc.dart @@ -19,9 +19,10 @@ class ThemeBloc extends Bloc { Future getPreviousTheme() async { try { final prefs = await SharedPreferences.getInstance(); - final storedThemeMode = prefs.getString('themeMode'); - - themeMode = _convertStringToThemeMode(storedThemeMode); + if (prefs.containsKey('themeMode')) { + final storedThemeMode = prefs.getString('themeMode'); + themeMode = _convertStringToThemeMode(storedThemeMode); + } } catch (error) { print('Error retrieving theme mode from SharedPreferences: $error'); } diff --git a/lib/Blocs/user_interface_bloc/user_interface_bloc.dart b/lib/Blocs/user_interface_bloc/user_interface_bloc.dart index 75b3f93..3e43311 100644 --- a/lib/Blocs/user_interface_bloc/user_interface_bloc.dart +++ b/lib/Blocs/user_interface_bloc/user_interface_bloc.dart @@ -19,6 +19,7 @@ class UserInterfaceBloc extends Bloc { Emitter emit, ) { UserInterfaceModel model = UserInterfaceModel( + showProgressBar: event.model.showProgressBar, showDateAdded: event.model.showDateAdded, showDateCreated: event.model.showDateCreated, showRatio: event.model.showRatio, @@ -43,6 +44,7 @@ class UserInterfaceBloc extends Bloc { showInitialSeeding: event.model.showInitialSeeding, showSequentialDownload: event.model.showSequentialDownload, showDownloadTorrent: event.model.showDownloadTorrent, + tagPreferenceButtonValue: event.model.tagPreferenceButtonValue, ); saveUserInterfaceModel(model); diff --git a/lib/Blocs/user_interface_bloc/user_interface_state.dart b/lib/Blocs/user_interface_bloc/user_interface_state.dart index 54afe0d..76ef671 100644 --- a/lib/Blocs/user_interface_bloc/user_interface_state.dart +++ b/lib/Blocs/user_interface_bloc/user_interface_state.dart @@ -9,6 +9,7 @@ class UserInterfaceState extends Equatable { factory UserInterfaceState.initial() => UserInterfaceState( model: UserInterfaceModel( + showProgressBar: true, showDateAdded: true, showDateCreated: true, showRatio: false, @@ -33,6 +34,7 @@ class UserInterfaceState extends Equatable { showInitialSeeding: false, showSequentialDownload: false, showDownloadTorrent: false, + tagPreferenceButtonValue: TagPreferenceButtonValue.multiSelection, ), ); diff --git a/lib/Model/user_interface_model.dart b/lib/Model/user_interface_model.dart index e5ebbf6..3be0c27 100644 --- a/lib/Model/user_interface_model.dart +++ b/lib/Model/user_interface_model.dart @@ -1,6 +1,9 @@ import 'package:equatable/equatable.dart'; +enum TagPreferenceButtonValue { singleSelection, multiSelection } + class UserInterfaceModel extends Equatable { + final bool showProgressBar; final bool showDateAdded; final bool showDateCreated; final bool showRatio; @@ -25,8 +28,10 @@ class UserInterfaceModel extends Equatable { final bool showInitialSeeding; final bool showSequentialDownload; final bool showDownloadTorrent; + final TagPreferenceButtonValue tagPreferenceButtonValue; const UserInterfaceModel({ + required this.showProgressBar, required this.showDateAdded, required this.showDateCreated, required this.showRatio, @@ -51,10 +56,12 @@ class UserInterfaceModel extends Equatable { required this.showInitialSeeding, required this.showSequentialDownload, required this.showDownloadTorrent, + required this.tagPreferenceButtonValue, }); factory UserInterfaceModel.fromJson(Map json) { return UserInterfaceModel( + showProgressBar: json['showProgressBar'] as bool, showDateAdded: json['showDateAdded'] as bool, showDateCreated: json['showDateCreated'] as bool, showRatio: json['showRatio'] as bool, @@ -79,11 +86,16 @@ class UserInterfaceModel extends Equatable { showInitialSeeding: json['showInitialSeeding'] as bool, showSequentialDownload: json['showSequentialDownload'] as bool, showDownloadTorrent: json['showDownloadTorrent'] as bool, + tagPreferenceButtonValue: + json['tagPreferenceButtonValue'] == 'singleSelection' + ? TagPreferenceButtonValue.singleSelection + : TagPreferenceButtonValue.multiSelection, ); } Map toJson() { return { + 'showProgressBar': showProgressBar, 'showDateAdded': showDateAdded, 'showDateCreated': showDateCreated, 'showRatio': showRatio, @@ -108,11 +120,16 @@ class UserInterfaceModel extends Equatable { 'showInitialSeeding': showInitialSeeding, 'showSequentialDownload': showSequentialDownload, 'showDownloadTorrent': showDownloadTorrent, + 'tagPreferenceButtonValue': + tagPreferenceButtonValue == TagPreferenceButtonValue.singleSelection + ? 'singleSelection' + : 'multiSelection', }; } @override List get props => [ + showProgressBar, showDateAdded, showDateCreated, showRatio, @@ -136,6 +153,7 @@ class UserInterfaceModel extends Equatable { showPriority, showInitialSeeding, showSequentialDownload, - showDownloadTorrent + showDownloadTorrent, + tagPreferenceButtonValue, ]; } diff --git a/lib/Pages/home_screen/widgets/rss_feed_home_page.dart b/lib/Pages/home_screen/widgets/rss_feed_home_page.dart index f84cc33..487091c 100644 --- a/lib/Pages/home_screen/widgets/rss_feed_home_page.dart +++ b/lib/Pages/home_screen/widgets/rss_feed_home_page.dart @@ -737,7 +737,7 @@ class _RSSFeedHomePageState extends State FeedsApi .listAllFeedsAndRules( context: context); - clearFeedsFields(); + if (isUpdateFeedSelected) { UpdateFeedApi.updateFeed( type: "feed", @@ -758,6 +758,7 @@ class _RSSFeedHomePageState extends State context: context); } + clearFeedsFields(); }); } } else { @@ -1011,7 +1012,7 @@ class _RSSFeedHomePageState extends State Padding( padding: const EdgeInsets - .only( + .only( top: 20), child: Column( crossAxisAlignment: @@ -1019,12 +1020,15 @@ class _RSSFeedHomePageState extends State .start, children: [ Padding( - padding: const EdgeInsets + padding: + const EdgeInsets .only( - right: 20, - left: 20, - bottom: - 5), + right: + 20, + left: + 20, + bottom: + 5), child: Text( l10n.selected_magnet_link, style: TextStyle( @@ -1043,7 +1047,7 @@ class _RSSFeedHomePageState extends State ), Padding( padding: const EdgeInsets - .only( + .only( left: 20.0, right: @@ -1384,7 +1388,7 @@ class _RSSFeedHomePageState extends State ? Padding( padding: const EdgeInsets - .only( + .only( top: 8.0), child: Container( height: 1, diff --git a/lib/Pages/login_screen/login_screen.dart b/lib/Pages/login_screen/login_screen.dart index b1949ee..8ecc71b 100644 --- a/lib/Pages/login_screen/login_screen.dart +++ b/lib/Pages/login_screen/login_screen.dart @@ -31,7 +31,7 @@ class _LoginScreenState extends State { TextEditingController usernameController = new TextEditingController(); TextEditingController passwordController = new TextEditingController(); TextEditingController urlController = - new TextEditingController(text: 'http://localhost:3000'); + new TextEditingController(text: 'https://yourserver.xirvik.com'); final _formKey = GlobalKey(); late int themeIndex; @@ -100,7 +100,7 @@ class _LoginScreenState extends State { labelText: l10n.login_screen_url, prefixIcon: Icons.link, themeIndex: themeIndex, - trailingIconButton: Align( + trailingIconButton1: Align( alignment: Alignment.centerRight, child: IconButton( onPressed: () { @@ -120,6 +120,23 @@ class _LoginScreenState extends State { ), ), ), + trailingIconButton2: Align( + alignment: Alignment.centerRight, + child: Tooltip( + triggerMode: TooltipTriggerMode.tap, + message: + "URL for your Flood instance (local, seedbox...).", + showDuration: Duration(seconds: 3), + child: Icon( + Icons.info_outline, + color: ThemeBloc.theme(themeIndex) + .textTheme + .bodyLarge! + .color!, + size: 20, + ), + ), + ), ), SizedBox( height: hp * 0.01, @@ -141,7 +158,7 @@ class _LoginScreenState extends State { prefixIcon: Icons.lock_outline, themeIndex: themeIndex, obscureText: showPass, - trailingIconButton: Align( + trailingIconButton1: Align( alignment: Alignment.centerRight, child: IconButton( onPressed: () { diff --git a/lib/Pages/login_screen/widgets/login_screen_textfield.dart b/lib/Pages/login_screen/widgets/login_screen_textfield.dart index 9d5e3b1..d6b8e96 100644 --- a/lib/Pages/login_screen/widgets/login_screen_textfield.dart +++ b/lib/Pages/login_screen/widgets/login_screen_textfield.dart @@ -7,7 +7,8 @@ class LoginScreenTextField extends StatelessWidget { final String labelText; final IconData prefixIcon; final bool obscureText; - final Widget? trailingIconButton; + final Widget? trailingIconButton1; + final Widget? trailingIconButton2; final int themeIndex; const LoginScreenTextField({ @@ -15,7 +16,8 @@ class LoginScreenTextField extends StatelessWidget { required this.labelText, required this.prefixIcon, required this.themeIndex, - this.trailingIconButton, + this.trailingIconButton1, + this.trailingIconButton2, this.obscureText = false, Key? key, }) : super(key: key); @@ -73,7 +75,13 @@ class LoginScreenTextField extends StatelessWidget { ), ), ), - trailingIconButton ?? Container() + Row( + mainAxisAlignment: MainAxisAlignment.end, + children: [ + trailingIconButton1 ?? Container(), + trailingIconButton2 ?? Container(), + ], + ) ], ), ); diff --git a/lib/Pages/settings_screen/settings_screen.dart b/lib/Pages/settings_screen/settings_screen.dart index 4dd8bd3..63a7432 100644 --- a/lib/Pages/settings_screen/settings_screen.dart +++ b/lib/Pages/settings_screen/settings_screen.dart @@ -88,6 +88,8 @@ class _SettingsScreenState extends State { // *User Interface Map torrentInfo = {}; Map contextMenuInfo = {}; + TagPreferenceButtonValue tagPreferenceButtonValue = + TagPreferenceButtonValue.multiSelection; @override void didChangeDependencies() { @@ -152,6 +154,7 @@ class _SettingsScreenState extends State { // *User Interface Initialization final AppLocalizations l10n = context.l10n; torrentInfo = { + l10n.show_progress_bar_option: userInterfaceModel.showProgressBar, l10n.torrent_description_date_added: userInterfaceModel.showDateAdded, l10n.torrent_description_date_created: userInterfaceModel.showDateCreated, @@ -186,6 +189,8 @@ class _SettingsScreenState extends State { userInterfaceModel.showSequentialDownload, l10n.torrents_download_torrent: userInterfaceModel.showDownloadTorrent, }; + + tagPreferenceButtonValue = userInterfaceModel.tagPreferenceButtonValue; }); super.didChangeDependencies(); } @@ -200,43 +205,53 @@ class _SettingsScreenState extends State { elevation: 0, backgroundColor: ThemeBloc.theme(widget.themeIndex).primaryColorDark, onPressed: () { - BlocProvider.of(context, listen: false) - .add(UpdateUserInterfaceEvent( + BlocProvider.of(context, listen: false).add( + UpdateUserInterfaceEvent( model: UserInterfaceModel( - showDateAdded: torrentInfo[l10n.torrent_description_date_added]!, - showDateCreated: - torrentInfo[l10n.torrent_description_date_created]!, - showRatio: torrentInfo[l10n.torrent_description_ratio]!, - showLocation: torrentInfo[l10n.torrent_description_location]!, - showTags: torrentInfo[l10n.torrents_add_tags]!, - showTrackers: torrentInfo[l10n.torrent_description_trackers]!, - showTrackersMessage: - torrentInfo[l10n.torrent_description_trackers_message]!, - showDownloadSpeed: - torrentInfo[l10n.torrent_description_download_speed]!, - showUploadSpeed: - torrentInfo[l10n.torrent_description_upload_speed]!, - showPeers: torrentInfo[l10n.torrent_description_peers]!, - showSeeds: torrentInfo[l10n.torrent_description_seeds]!, - showSize: torrentInfo[l10n.torrent_description_size]!, - showType: torrentInfo[l10n.torrent_description_type]!, - showHash: torrentInfo[l10n.torrent_description_hash]!, - showDelete: contextMenuInfo[l10n.multi_torrents_actions_delete]!, - showSetTags: contextMenuInfo[l10n.torrents_set_tags_heading]!, - showCheckHash: contextMenuInfo[l10n.torrent_check_hash]!, - showReannounce: contextMenuInfo[l10n.torrents_reannounce]!, - showSetTrackers: - contextMenuInfo[l10n.torrents_set_trackers_heading]!, - showGenerateMagnetLink: - contextMenuInfo[l10n.torrents_genrate_magnet_link]!, - showPriority: contextMenuInfo[l10n.set_priority_heading]!, - showInitialSeeding: - contextMenuInfo[l10n.torrents_initial_seeding]!, - showSequentialDownload: - contextMenuInfo[l10n.torrents_sequential_download]!, - showDownloadTorrent: - contextMenuInfo[l10n.torrents_download_torrent]!, - ))); + showProgressBar: + torrentInfo[l10n.show_progress_bar_option]!, + showDateAdded: + torrentInfo[l10n.torrent_description_date_added]!, + showDateCreated: + torrentInfo[l10n.torrent_description_date_created]!, + showRatio: torrentInfo[l10n.torrent_description_ratio]!, + showLocation: + torrentInfo[l10n.torrent_description_location]!, + showTags: torrentInfo[l10n.torrents_add_tags]!, + showTrackers: + torrentInfo[l10n.torrent_description_trackers]!, + showTrackersMessage: torrentInfo[ + l10n.torrent_description_trackers_message]!, + showDownloadSpeed: torrentInfo[ + l10n.torrent_description_download_speed]!, + showUploadSpeed: + torrentInfo[l10n.torrent_description_upload_speed]!, + showPeers: torrentInfo[l10n.torrent_description_peers]!, + showSeeds: torrentInfo[l10n.torrent_description_seeds]!, + showSize: torrentInfo[l10n.torrent_description_size]!, + showType: torrentInfo[l10n.torrent_description_type]!, + showHash: torrentInfo[l10n.torrent_description_hash]!, + showDelete: contextMenuInfo[ + l10n.multi_torrents_actions_delete]!, + showSetTags: + contextMenuInfo[l10n.torrents_set_tags_heading]!, + showCheckHash: + contextMenuInfo[l10n.torrent_check_hash]!, + showReannounce: + contextMenuInfo[l10n.torrents_reannounce]!, + showSetTrackers: contextMenuInfo[ + l10n.torrents_set_trackers_heading]!, + showGenerateMagnetLink: + contextMenuInfo[l10n.torrents_genrate_magnet_link]!, + showPriority: + contextMenuInfo[l10n.set_priority_heading]!, + showInitialSeeding: + contextMenuInfo[l10n.torrents_initial_seeding]!, + showSequentialDownload: + contextMenuInfo[l10n.torrents_sequential_download]!, + showDownloadTorrent: + contextMenuInfo[l10n.torrents_download_torrent]!, + tagPreferenceButtonValue: tagPreferenceButtonValue))); ClientSettingsModel clientSettingsModel = BlocProvider.of(context).clientSettings; @@ -428,6 +443,12 @@ class _SettingsScreenState extends State { hp: hp, torrentScreenItems: torrentInfo, contextMenuItems: contextMenuInfo, + selectedRadioButton: tagPreferenceButtonValue, + tagSelectionOnChange: (value) { + setState(() { + tagPreferenceButtonValue = value!; + }); + }, ), // *Power Management Section PowerManagementSection( diff --git a/lib/Pages/settings_screen/widgets/user_interface_section.dart b/lib/Pages/settings_screen/widgets/user_interface_section.dart index ea8e4da..f30796b 100644 --- a/lib/Pages/settings_screen/widgets/user_interface_section.dart +++ b/lib/Pages/settings_screen/widgets/user_interface_section.dart @@ -5,6 +5,7 @@ import 'package:flood_mobile/Blocs/language_bloc/language_bloc.dart'; import 'package:flood_mobile/Blocs/theme_bloc/theme_bloc.dart'; import 'package:flood_mobile/Blocs/user_interface_bloc/user_interface_bloc.dart'; import 'package:flood_mobile/Constants/languages.dart'; +import 'package:flood_mobile/Model/user_interface_model.dart'; import 'package:flood_mobile/Pages/widgets/flood_snackbar.dart'; import 'package:flood_mobile/Pages/widgets/text_size.dart'; import 'package:flood_mobile/l10n/l10n.dart'; @@ -15,6 +16,8 @@ class UserInterfaceSection extends StatefulWidget { final double hp; Map torrentScreenItems; Map contextMenuItems; + final TagPreferenceButtonValue selectedRadioButton; + final void Function(TagPreferenceButtonValue? value) tagSelectionOnChange; UserInterfaceSection({ Key? key, @@ -22,6 +25,8 @@ class UserInterfaceSection extends StatefulWidget { required this.hp, required this.torrentScreenItems, required this.contextMenuItems, + required this.selectedRadioButton, + required this.tagSelectionOnChange, }) : super(key: key); @override @@ -259,6 +264,33 @@ class _UserInterfaceSectionState extends State { itemCount: widget.contextMenuItems.length, ), ), + SizedBox(height: widget.hp * 0.02), + SText( + text: l10n.tag_selection_heading, + themeIndex: widget.themeIndex, + ), + Row( + children: [ + Expanded( + child: RadioListTile( + contentPadding: EdgeInsets.zero, + title: Text(l10n.single_selection_radio_button), + value: TagPreferenceButtonValue.singleSelection, + groupValue: widget.selectedRadioButton, + onChanged: widget.tagSelectionOnChange, + ), + ), + Expanded( + child: RadioListTile( + contentPadding: EdgeInsets.zero, + title: Text(l10n.multi_selection_radio_button), + value: TagPreferenceButtonValue.multiSelection, + groupValue: widget.selectedRadioButton, + onChanged: widget.tagSelectionOnChange, + ), + ), + ], + ) ], ) ], diff --git a/lib/Pages/torrent_screen/widgets/torrent_tile.dart b/lib/Pages/torrent_screen/widgets/torrent_tile.dart index 36eb6d9..4961850 100644 --- a/lib/Pages/torrent_screen/widgets/torrent_tile.dart +++ b/lib/Pages/torrent_screen/widgets/torrent_tile.dart @@ -8,6 +8,7 @@ import 'package:percent_indicator/linear_percent_indicator.dart'; import 'package:flood_mobile/Api/torrent_api.dart'; import 'package:flood_mobile/Blocs/multiple_select_torrent_bloc/multiple_select_torrent_bloc.dart'; import 'package:flood_mobile/Blocs/theme_bloc/theme_bloc.dart'; +import 'package:flood_mobile/Blocs/user_interface_bloc/user_interface_bloc.dart'; import 'package:flood_mobile/Model/torrent_model.dart'; import 'package:flood_mobile/Pages/torrent_screen/widgets/focused_menu_items_list.dart'; import 'package:flood_mobile/Pages/torrent_screen/widgets/torrent_description.dart'; @@ -133,41 +134,51 @@ class _TorrentTileState extends State { child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ - Row( - children: [ - Expanded( - child: LinearPercentIndicator( - key: Key('Linear Progress Indicator'), - padding: EdgeInsets.all(0), - lineHeight: 5.0, - percent: widget.model.percentComplete - .roundToDouble() / - 100, - backgroundColor: - ThemeBloc.theme(widget.themeIndex) - .colorScheme - .secondary - .withAlpha(80), - progressColor: (widget - .model.percentComplete - .toStringAsFixed(1) == - '100.0') - ? ThemeBloc.theme(widget.themeIndex) - .primaryColorDark - : Colors.blue, + if (BlocProvider.of(context, + listen: false) + .state + .model + .showProgressBar) + Row( + children: [ + Expanded( + child: LinearPercentIndicator( + key: Key('Linear Progress Indicator'), + padding: EdgeInsets.all(0), + lineHeight: 5.0, + percent: widget.model.percentComplete + .roundToDouble() / + 100, + backgroundColor: + ThemeBloc.theme(widget.themeIndex) + .colorScheme + .secondary + .withAlpha(80), + progressColor: (widget + .model.percentComplete + .toStringAsFixed(1) == + '100.0') + ? ThemeBloc.theme(widget.themeIndex) + .primaryColorDark + : Colors.blue, + ), ), - ), - SizedBox( - width: 30, - ), - Text(widget.model.percentComplete - .toStringAsFixed(1) + - " %"), - ], - ), - SizedBox( - height: hp * 0.01, - ), + SizedBox( + width: 30, + ), + Text(widget.model.percentComplete + .toStringAsFixed(1) + + " %"), + ], + ), + if (BlocProvider.of(context, + listen: false) + .state + .model + .showProgressBar) + SizedBox( + height: hp * 0.01, + ), Row( children: [ Text( @@ -322,7 +333,7 @@ class _TorrentTileState extends State { ), ], ), - ), + ) ], ); }, diff --git a/lib/Pages/widgets/add_tag_dialogue.dart b/lib/Pages/widgets/add_tag_dialogue.dart index 802b928..a6b5350 100644 --- a/lib/Pages/widgets/add_tag_dialogue.dart +++ b/lib/Pages/widgets/add_tag_dialogue.dart @@ -6,7 +6,9 @@ import 'package:flood_mobile/Api/torrent_api.dart'; import 'package:flood_mobile/Blocs/filter_torrent_bloc/filter_torrent_bloc.dart'; import 'package:flood_mobile/Blocs/home_screen_bloc/home_screen_bloc.dart'; import 'package:flood_mobile/Blocs/theme_bloc/theme_bloc.dart'; +import 'package:flood_mobile/Blocs/user_interface_bloc/user_interface_bloc.dart'; import 'package:flood_mobile/Model/torrent_model.dart'; +import 'package:flood_mobile/Model/user_interface_model.dart'; import 'package:flood_mobile/Pages/widgets/flood_snackbar.dart'; import 'package:flood_mobile/l10n/l10n.dart'; @@ -79,6 +81,11 @@ class _AddTagDialogueState extends State @override Widget build(BuildContext context) { + final tagPreferenceButtonValue = + BlocProvider.of(context, listen: false) + .state + .model + .tagPreferenceButtonValue; final themeBloc = BlocProvider.of(context); final hp = MediaQuery.of(context).size.height; final wp = MediaQuery.of(context).size.width; @@ -208,17 +215,21 @@ class _AddTagDialogueState extends State itemBuilder: (context, index) { if (index < _existingTags.length) { return _getCheckBoxListTile( - _existingTags.keys.elementAt(index), - index, - themeBloc, - _existingTags); + _existingTags.keys.elementAt(index), + index, + themeBloc, + _existingTags, + tagPreferenceButtonValue, + ); } else { index -= _existingTags.length; return _getCheckBoxListTile( - _newEnterdTags.keys.elementAt(index), - index, - themeBloc, - _newEnterdTags); + _newEnterdTags.keys.elementAt(index), + index, + themeBloc, + _newEnterdTags, + tagPreferenceButtonValue, + ); } }, ), @@ -306,7 +317,11 @@ class _AddTagDialogueState extends State } CheckboxListTile _getCheckBoxListTile( - String text, int index, ThemeBloc themeBloc, Map tags) { + String text, + int index, + ThemeBloc themeBloc, + Map tags, + TagPreferenceButtonValue tagPreferenceButtonValue) { return CheckboxListTile( dense: true, title: Text( @@ -333,6 +348,11 @@ class _AddTagDialogueState extends State _textController.text = _inputTagList.join(','); _textController.selection = TextSelection.fromPosition( TextPosition(offset: _textController.text.length)); + if (tagPreferenceButtonValue == + TagPreferenceButtonValue.singleSelection) { + _showdropdown = false; + _animationController.reverse(); + } }); }); } diff --git a/lib/l10n/arb/app_ar.arb b/lib/l10n/arb/app_ar.arb index 8ffd7a3..108cfba 100644 --- a/lib/l10n/arb/app_ar.arb +++ b/lib/l10n/arb/app_ar.arb @@ -321,5 +321,10 @@ "notification_stopped": "تم الإيقاف", "notification_downloading": "جاري التنزيل", "notification_error": "خطأ في التنزيل", - "notification_finished": "تم التنزيل" + "notification_finished": "تم التنزيل", + "login_field_tooltip_message": "عنوان URL للمثيل الخاص بك في Flood (محلي، seedbox...)", + "tag_selection_heading": "تفضيلات محدد الوسوم", + "single_selection_radio_button": "اختيار واحد", + "multi_selection_radio_button": "اختيار متعدد", + "show_progress_bar_option": "عرض شريط التقدم" } \ No newline at end of file diff --git a/lib/l10n/arb/app_cs.arb b/lib/l10n/arb/app_cs.arb index ec8dcdf..53d4836 100644 --- a/lib/l10n/arb/app_cs.arb +++ b/lib/l10n/arb/app_cs.arb @@ -321,5 +321,10 @@ "notification_stopped": "Zastaveno", "notification_downloading": "Stahování", "notification_error": "Chyba při stahování", - "notification_finished": "Stahování dokončeno" + "notification_finished": "Stahování dokončeno", + "login_field_tooltip_message": "URL pro vaši Flood instanci (lokální, seedbox...)", + "tag_selection_heading": "Předvolba výběru značek", + "single_selection_radio_button": "Jednoduchý výběr", + "multi_selection_radio_button": "Více výběrů", + "show_progress_bar_option": "Zobrazovat pruh postupu" } \ No newline at end of file diff --git a/lib/l10n/arb/app_de.arb b/lib/l10n/arb/app_de.arb index 72fc8a4..c149f84 100644 --- a/lib/l10n/arb/app_de.arb +++ b/lib/l10n/arb/app_de.arb @@ -284,6 +284,9 @@ "torrent_screen_items_heading": "Torrent-Bildschirmelemente", "torrents_set_trackers_snackbar": "Tracker erfolgreich festgelegt", "context_menu_items_heading": "Elemente im Kontextmenü", + "tag_selection_heading": "Tag-Auswahlpräferenz", + "single_selection_radio_button": "Einzelne Auswahl", + "multi_selection_radio_button": "Mehrfachauswahl", "notification_resume": "Fortsetzen", "notification_pause": "Pause", "notification_stop": "Stop", @@ -321,5 +324,6 @@ "sort_by_uploaded": "Hochgeladen", "sort_by_upload_speed": "Upload-Geschwindigkeit", "sort_by_file_size": "Dateigröße", - "sort_by_percent_completed": "Prozent abgeschlossen" + "login_field_tooltip_message": "URL für Ihre Flood-Instanz (lokal, seedbox...)", + "sort_by_percent_completed": "Prozent abgeschlossen","show_progress_bar_option": "Fortschrittsbalken anzeigen" } \ No newline at end of file diff --git a/lib/l10n/arb/app_en.arb b/lib/l10n/arb/app_en.arb index ce19477..50fd2f1 100644 --- a/lib/l10n/arb/app_en.arb +++ b/lib/l10n/arb/app_en.arb @@ -335,6 +335,11 @@ "notification_stopped": "Stopped", "notification_downloading": "Downloading", "notification_error": "Download Error", - "notification_finished": "Download Finished" + "notification_finished": "Download Finished", + "login_field_tooltip_message" : "URL for your Flood instance (local, seedbox...).", + "tag_selection_heading": "Tag Selector Preference", + "single_selection_radio_button":"Single Selection", + "multi_selection_radio_button":"Multi Selection", + "show_progress_bar_option":"Show Progress Bar" } \ No newline at end of file diff --git a/lib/l10n/arb/app_es.arb b/lib/l10n/arb/app_es.arb index 681898c..7176af2 100644 --- a/lib/l10n/arb/app_es.arb +++ b/lib/l10n/arb/app_es.arb @@ -321,5 +321,10 @@ "notification_stopped": "Detenido", "notification_downloading": "Descargando", "notification_error": "Error de descarga", - "notification_finished": "Descarga finalizada" + "notification_finished": "Descarga finalizada", + "login_field_tooltip_message": "URL para su instancia de Flood (local, seedbox...)", + "tag_selection_heading": "Preferencia del selector de etiquetas", + "single_selection_radio_button": "Selección única", + "multi_selection_radio_button": "Selección múltiple", + "show_progress_bar_option": "Mostrar barra de progreso" } \ No newline at end of file diff --git a/lib/l10n/arb/app_fi.arb b/lib/l10n/arb/app_fi.arb index c2d4c39..6cc0887 100644 --- a/lib/l10n/arb/app_fi.arb +++ b/lib/l10n/arb/app_fi.arb @@ -321,5 +321,10 @@ "notification_stopped": "Pysähtynyt", "notification_downloading": "Lataaminen", "notification_error": "Latausvirhe", - "notification_finished": "Lataus valmis" + "notification_finished": "Lataus valmis", + "login_field_tooltip_message": "URL Flood-instanssillesi (paikallinen, seedbox...)", + "tag_selection_heading": "Tunnistevalitsimen asetukset", + "single_selection_radio_button": "Yksittäinen valinta", + "multi_selection_radio_button": "Useita valintoja", + "show_progress_bar_option": "Näytä edistymispalkki" } \ No newline at end of file diff --git a/lib/l10n/arb/app_fr.arb b/lib/l10n/arb/app_fr.arb index 5d9f9ed..9ba87d9 100644 --- a/lib/l10n/arb/app_fr.arb +++ b/lib/l10n/arb/app_fr.arb @@ -322,5 +322,10 @@ "notification_stopped": "Arrêté", "notification_downloading": "Téléchargement", "notification_error": "Erreur de téléchargement", - "notification_finished": "Téléchargement terminé" + "notification_finished": "Téléchargement terminé", + "login_field_tooltip_message": "URL pour votre instance de Flood (locale, seedbox...)", + "tag_selection_heading": "Préférence du sélecteur de balises", + "single_selection_radio_button": "Sélection unique", + "multi_selection_radio_button": "Sélection multiple", + "show_progress_bar_option": "Afficher la barre de progression" } \ No newline at end of file diff --git a/lib/l10n/arb/app_hi.arb b/lib/l10n/arb/app_hi.arb index a6e9556..322b14b 100644 --- a/lib/l10n/arb/app_hi.arb +++ b/lib/l10n/arb/app_hi.arb @@ -321,5 +321,10 @@ "notification_stopped": "रुक गया", "notification_downloading": "डाउनलोड हो रहा है", "notification_error": "डाउनलोड त्रुटि", - "notification_finished": "डाउनलोड समाप्त" + "notification_finished": "डाउनलोड समाप्त", + "login_field_tooltip_message": "आपके फ्लड इंस्टेंस के लिए URL (स्थानीय, सीडबॉक्स...)", + "tag_selection_heading": "टैग सिलेक्शन प्राथमिकता", + "single_selection_radio_button": "एकल चयन", + "multi_selection_radio_button": "बहुविकल्पी चयन", + "show_progress_bar_option": "प्रगति संकेतक दिखाएं" } \ No newline at end of file diff --git a/lib/l10n/arb/app_hu.arb b/lib/l10n/arb/app_hu.arb index 3a26f13..1748a38 100644 --- a/lib/l10n/arb/app_hu.arb +++ b/lib/l10n/arb/app_hu.arb @@ -321,5 +321,10 @@ "notification_stopped": "Megállt", "notification_downloading": "Letöltés", "notification_error": "Letöltési hiba", - "notification_finished": "Letöltés kész" + "notification_finished": "Letöltés kész", + "login_field_tooltip_message": "URL a Flood példányához (helyi, seedbox...)", + "tag_selection_heading": "Címkeválasztó előnyben részesítése", + "single_selection_radio_button": "Egyszeres kiválasztás", + "multi_selection_radio_button": "Többszörös kiválasztás", + "show_progress_bar_option": "Folyamatjelző megjelenítése" } \ No newline at end of file diff --git a/lib/l10n/arb/app_it.arb b/lib/l10n/arb/app_it.arb index b9e518f..cec21a2 100644 --- a/lib/l10n/arb/app_it.arb +++ b/lib/l10n/arb/app_it.arb @@ -321,5 +321,10 @@ "notification_stopped": "Fermato", "notification_downloading": "Download", "notification_error": "Errore di download", - "notification_finished": "Download completato" + "notification_finished": "Download completato", + "login_field_tooltip_message": "URL per la tua istanza di Flood (locale, seedbox...)", + "tag_selection_heading": "Preferenza del selettore di tag", + "single_selection_radio_button": "Selezione singola", + "multi_selection_radio_button": "Selezione multipla", + "show_progress_bar_option": "Mostra barra di avanzamento" } \ No newline at end of file diff --git a/lib/l10n/arb/app_ja.arb b/lib/l10n/arb/app_ja.arb index 1ba345f..94508d4 100644 --- a/lib/l10n/arb/app_ja.arb +++ b/lib/l10n/arb/app_ja.arb @@ -322,5 +322,10 @@ "notification_stopped": "停止", "notification_downloading": "ダウンロード中", "notification_error": "ダウンロードエラー", - "notification_finished": "ダウンロード完了" + "notification_finished": "ダウンロード完了", + "login_field_tooltip_message": "Flood インスタンスの URL(ローカル、シードボックス...)", + "tag_selection_heading": "タグセレクターの設定", + "single_selection_radio_button": "単一選択", + "multi_selection_radio_button": "複数選択", + "show_progress_bar_option": "プログレスバーを表示" } \ No newline at end of file diff --git a/lib/l10n/arb/app_ko.arb b/lib/l10n/arb/app_ko.arb index f1a05ae..9c71d19 100644 --- a/lib/l10n/arb/app_ko.arb +++ b/lib/l10n/arb/app_ko.arb @@ -321,5 +321,10 @@ "notification_stopped": "정지됨", "notification_downloading": "다운로드 중", "notification_error": "다운로드 오류", - "notification_finished": "다운로드 완료" + "notification_finished": "다운로드 완료", + "login_field_tooltip_message": "귀하의 Flood 인스턴스 URL (로컬, 시드박스...)", + "tag_selection_heading": "태그 선택기 기본 설정", + "single_selection_radio_button": "단일 선택", + "multi_selection_radio_button": "다중 선택", + "show_progress_bar_option": "진행 상황 표시" } \ No newline at end of file diff --git a/lib/l10n/arb/app_nl.arb b/lib/l10n/arb/app_nl.arb index 4636c39..2ecfe72 100644 --- a/lib/l10n/arb/app_nl.arb +++ b/lib/l10n/arb/app_nl.arb @@ -321,5 +321,10 @@ "notification_stopped": "Gestopt", "notification_downloading": "Downloaden", "notification_error": "Downloadfout", - "notification_finished": "Download voltooid" + "notification_finished": "Download voltooid", + "login_field_tooltip_message": "URL voor uw Flood-instantie (lokaal, seedbox...)", + "tag_selection_heading": "Voorkeur voor tagselectie", + "single_selection_radio_button": "Enkele selectie", + "multi_selection_radio_button": "Meervoudige selectie", + "show_progress_bar_option": "Voortgangsbalk weergeven" } \ No newline at end of file diff --git a/lib/l10n/arb/app_no.arb b/lib/l10n/arb/app_no.arb index ae6ae55..960f846 100644 --- a/lib/l10n/arb/app_no.arb +++ b/lib/l10n/arb/app_no.arb @@ -321,5 +321,10 @@ "notification_stopped": "Stoppet", "notification_downloading": "Laster ned", "notification_error": "Nedlastingsfeil", - "notification_finished": "Nedlasting fullført" + "notification_finished": "Nedlasting fullført", + "login_field_tooltip_message": "URL for din Flood-instans (lokal, seedbox...)", + "tag_selection_heading": "Foretrukket tagvelger", + "single_selection_radio_button": "Enkeltvalg", + "multi_selection_radio_button": "Flervalg", + "show_progress_bar_option": "Vis fremdriftslinje" } \ No newline at end of file diff --git a/lib/l10n/arb/app_pl.arb b/lib/l10n/arb/app_pl.arb index 906b9c3..ed287cf 100644 --- a/lib/l10n/arb/app_pl.arb +++ b/lib/l10n/arb/app_pl.arb @@ -321,5 +321,10 @@ "notification_stopped": "Zatrzymano", "notification_downloading": "Pobieranie", "notification_error": "Błąd pobierania", - "notification_finished": "Pobieranie zakończone" + "notification_finished": "Pobieranie zakończone", + "login_field_tooltip_message": "URL do twojej instancji Flood (lokalnie, seedbox...)", + "tag_selection_heading": "Preferencje wyboru tagów", + "single_selection_radio_button": "Pojedynczy wybór", + "multi_selection_radio_button": "Wielokrotny wybór", + "show_progress_bar_option": "Pokaż pasek postępu" } \ No newline at end of file diff --git a/lib/l10n/arb/app_pt.arb b/lib/l10n/arb/app_pt.arb index cc6e4fe..1ed9ea5 100644 --- a/lib/l10n/arb/app_pt.arb +++ b/lib/l10n/arb/app_pt.arb @@ -321,5 +321,10 @@ "notification_stopped": "Parado", "notification_downloading": "Download", "notification_error": "Erro de download", - "notification_finished": "Download concluído" + "notification_finished": "Download concluído", + "login_field_tooltip_message": "URL para a sua instância do Flood (local, seedbox...)", + "tag_selection_heading": "Preferência do seletor de tags", + "single_selection_radio_button": "Seleção única", + "multi_selection_radio_button": "Seleção múltipla", + "show_progress_bar_option": "Mostrar barra de progresso" } \ No newline at end of file diff --git a/lib/l10n/arb/app_ro.arb b/lib/l10n/arb/app_ro.arb index 57959ef..879a13f 100644 --- a/lib/l10n/arb/app_ro.arb +++ b/lib/l10n/arb/app_ro.arb @@ -321,5 +321,10 @@ "notification_stopped": "Oprit", "notification_downloading": "Descărcare", "notification_error": "Eroare de descărcare", - "notification_finished": "Descărcare finalizată" + "notification_finished": "Descărcare finalizată", + "login_field_tooltip_message": "URL pentru instanța ta Flood (locală, seedbox...)", + "tag_selection_heading": "Preferință pentru selector de etichete", + "single_selection_radio_button": "Selecție unică", + "multi_selection_radio_button": "Selecție multiplă", + "show_progress_bar_option": "Afișează bara de progres" } \ No newline at end of file diff --git a/lib/l10n/arb/app_ru.arb b/lib/l10n/arb/app_ru.arb index 44b4b6a..9c9cef3 100644 --- a/lib/l10n/arb/app_ru.arb +++ b/lib/l10n/arb/app_ru.arb @@ -321,5 +321,10 @@ "sort_by_uploaded": "Wgrane", "sort_by_upload_speed": "Prędkość wysyłania", "sort_by_file_size": "Rozmiar pliku", - "sort_by_percent_completed": "Procent ukończony" + "sort_by_percent_completed": "Procent ukończony", + "login_field_tooltip_message": "URL для вашего экземпляра Flood (локальный, seedbox...)", + "tag_selection_heading": "Предпочтение селектора тегов", + "single_selection_radio_button": "Одиночный выбор", + "multi_selection_radio_button": "Множественный выбор", + "show_progress_bar_option": "Показывать полосу прогресса" } \ No newline at end of file diff --git a/lib/l10n/arb/app_sv.arb b/lib/l10n/arb/app_sv.arb index a83556f..4d86e42 100644 --- a/lib/l10n/arb/app_sv.arb +++ b/lib/l10n/arb/app_sv.arb @@ -322,5 +322,10 @@ "notification_stopped": "Stoppad", "notification_downloading": "Laddar ner", "notification_error": "Nedladdningsfel", - "notification_finished": "Nedladdning klar" + "notification_finished": "Nedladdning klar", + "login_field_tooltip_message": "URL för din Flood-instans (lokal, seedbox...)", + "tag_selection_heading": "Taggväljarinställning", + "single_selection_radio_button": "Enkelval", + "multi_selection_radio_button": "Flerval", + "show_progress_bar_option": "Visa framstegsindikator" } \ No newline at end of file diff --git a/lib/l10n/arb/app_uk.arb b/lib/l10n/arb/app_uk.arb index cc286bc..f01e8fe 100644 --- a/lib/l10n/arb/app_uk.arb +++ b/lib/l10n/arb/app_uk.arb @@ -322,5 +322,10 @@ "notification_stopped": "Зупинено", "notification_downloading": "Завантаження", "notification_error": "Помилка завантаження", - "notification_finished": "Завантаження завершено" + "notification_finished": "Завантаження завершено", + "login_field_tooltip_message": "URL для вашого екземпляра Flood (локальний, seedbox...)", + "tag_selection_heading": "Пріоритет вибору тегів", + "single_selection_radio_button": "Одиночний вибір", + "multi_selection_radio_button": "Множинний вибір", + "show_progress_bar_option": "Показати панель прогресу" } \ No newline at end of file diff --git a/lib/l10n/arb/app_zh.arb b/lib/l10n/arb/app_zh.arb index 061eb4d..311e179 100644 --- a/lib/l10n/arb/app_zh.arb +++ b/lib/l10n/arb/app_zh.arb @@ -322,5 +322,10 @@ "notification_stopped": "已停止", "notification_downloading": "下載中", "notification_error": "下載錯誤", - "notification_finished": "下載完成" + "notification_finished": "下載完成", + "login_field_tooltip_message": "您的 Flood 实例 URL(本地,种子盒...)", + "tag_selection_heading": "标签选择器优先级", + "single_selection_radio_button": "单选", + "multi_selection_radio_button": "多选", + "show_progress_bar_option": "显示进度条" } \ No newline at end of file diff --git a/lib/l10n/l10n.dart b/lib/l10n/l10n.dart index 2c9596a..3e911a9 100644 --- a/lib/l10n/l10n.dart +++ b/lib/l10n/l10n.dart @@ -3,5 +3,5 @@ import 'package:flutter_gen/gen_l10n/app_localizations.dart'; export 'package:flutter_gen/gen_l10n/app_localizations.dart'; extension AppLocalizationsX on BuildContext { - AppLocalizations get l10n => AppLocalizations.of(this); + AppLocalizations get l10n => AppLocalizations.of(this)!; } diff --git a/test/model_test/user_interface_model_test.dart b/test/model_test/user_interface_model_test.dart index 62cb5d1..b57508e 100644 --- a/test/model_test/user_interface_model_test.dart +++ b/test/model_test/user_interface_model_test.dart @@ -5,6 +5,7 @@ void main() { group('UserInterfaceModel', () { test('fromJson should return a valid UserInterfaceModel object', () { final json = { + 'showProgressBar': true, 'showDateAdded': true, 'showDateCreated': false, 'showRatio': true, @@ -33,6 +34,7 @@ void main() { final model = UserInterfaceModel.fromJson(json); + expect(model.showProgressBar, true); expect(model.showDateAdded, true); expect(model.showDateCreated, false); expect(model.showRatio, true); @@ -57,35 +59,39 @@ void main() { expect(model.showInitialSeeding, false); expect(model.showSequentialDownload, true); expect(model.showDownloadTorrent, false); + expect(model.showProgressBar, true); + expect(model.tagPreferenceButtonValue, + TagPreferenceButtonValue.multiSelection); }); test('toJson should return a valid JSON map', () { final model = UserInterfaceModel( - showDateAdded: true, - showDateCreated: false, - showRatio: true, - showLocation: false, - showTags: true, - showTrackers: false, - showTrackersMessage: true, - showDownloadSpeed: false, - showUploadSpeed: true, - showPeers: false, - showSeeds: true, - showSize: false, - showType: true, - showHash: false, - showDelete: true, - showSetTags: false, - showCheckHash: true, - showReannounce: false, - showSetTrackers: true, - showGenerateMagnetLink: false, - showPriority: true, - showInitialSeeding: false, - showSequentialDownload: true, - showDownloadTorrent: false, - ); + showDateAdded: true, + showDateCreated: false, + showRatio: true, + showLocation: false, + showTags: true, + showTrackers: false, + showTrackersMessage: true, + showDownloadSpeed: false, + showUploadSpeed: true, + showPeers: false, + showSeeds: true, + showSize: false, + showType: true, + showHash: false, + showDelete: true, + showSetTags: false, + showCheckHash: true, + showReannounce: false, + showSetTrackers: true, + showGenerateMagnetLink: false, + showPriority: true, + showInitialSeeding: false, + showSequentialDownload: true, + showDownloadTorrent: false, + showProgressBar: true, + tagPreferenceButtonValue: TagPreferenceButtonValue.multiSelection); final json = model.toJson(); @@ -113,6 +119,7 @@ void main() { expect(json['showInitialSeeding'], false); expect(json['showSequentialDownload'], true); expect(json['showDownloadTorrent'], false); + expect(json['showProgressBar'], true); }); }); } diff --git a/test/unit_test/user_interface_bloc_unit_test.dart b/test/unit_test/user_interface_bloc_unit_test.dart index c86f99f..5d2e831 100644 --- a/test/unit_test/user_interface_bloc_unit_test.dart +++ b/test/unit_test/user_interface_bloc_unit_test.dart @@ -29,31 +29,33 @@ void main() { act: (bloc) => bloc.add( UpdateUserInterfaceEvent( model: UserInterfaceModel( - showDateAdded: false, - showDateCreated: true, - showRatio: true, - showLocation: false, - showTags: true, - showTrackers: true, - showTrackersMessage: false, - showDownloadSpeed: true, - showUploadSpeed: false, - showPeers: true, - showSeeds: false, - showSize: true, - showType: false, - showHash: true, - showDelete: false, - showCheckHash: true, - showReannounce: false, - showSetTags: true, - showSetTrackers: false, - showGenerateMagnetLink: true, - showPriority: false, - showInitialSeeding: true, - showSequentialDownload: false, - showDownloadTorrent: true, - ), + showDateAdded: false, + showDateCreated: true, + showRatio: true, + showLocation: false, + showTags: true, + showTrackers: true, + showTrackersMessage: false, + showDownloadSpeed: true, + showUploadSpeed: false, + showPeers: true, + showSeeds: false, + showSize: true, + showType: false, + showHash: true, + showDelete: false, + showCheckHash: true, + showReannounce: false, + showSetTags: true, + showSetTrackers: false, + showGenerateMagnetLink: true, + showPriority: false, + showInitialSeeding: true, + showSequentialDownload: false, + showDownloadTorrent: true, + showProgressBar: true, + tagPreferenceButtonValue: + TagPreferenceButtonValue.singleSelection), ), ), expect: () => [ @@ -83,6 +85,9 @@ void main() { showInitialSeeding: true, showSequentialDownload: false, showDownloadTorrent: true, + showProgressBar: true, + tagPreferenceButtonValue: + TagPreferenceButtonValue.singleSelection, ), ), ], diff --git a/test/widget_test/login_screen_widget_test.dart b/test/widget_test/login_screen_widget_test.dart index 3a26fb2..9f12c23 100644 --- a/test/widget_test/login_screen_widget_test.dart +++ b/test/widget_test/login_screen_widget_test.dart @@ -33,11 +33,16 @@ void main() { expect(find.text('Sign in to your account'), findsOneWidget); expect(find.byKey(Key('Url TextField')), findsOneWidget); expect(find.byIcon(Icons.link), findsOneWidget); + expect(find.byIcon(Icons.info_outline), findsOneWidget); + await tester.tap(find.byIcon(Icons.info_outline)); + await tester.pumpAndSettle(); + expect(find.text('URL for your Flood instance (local, seedbox...).'), + findsOneWidget); expect(find.byIcon(Icons.paste), findsOneWidget); final urlControllerFinder = find.byKey(Key('Url TextField')); var urlController = tester.firstWidget(urlControllerFinder) as LoginScreenTextField; - expect(urlController.controller.text, 'http://localhost:3000'); + expect(urlController.controller.text, 'https://yourserver.xirvik.com'); expect(find.byKey(Key('Username TextField')), findsOneWidget); expect(find.byIcon(Icons.person), findsOneWidget); expect(find.text('Username'), findsOneWidget); diff --git a/test/widget_test/settings_screen_widget_test.dart b/test/widget_test/settings_screen_widget_test.dart index 91ccb80..eca38fb 100644 --- a/test/widget_test/settings_screen_widget_test.dart +++ b/test/widget_test/settings_screen_widget_test.dart @@ -376,10 +376,16 @@ void main() { await tester.tap(find.widgetWithText(ElevatedButton, 'Set')); await tester.pumpAndSettle(); expect(find.text('Language Set Successfully'), findsOneWidget); - await tester.drag(find.text('Torrent Screen Items'), Offset(0.0, -300.0)); + await tester.drag(find.text('Set'), Offset(0.0, -500.0)); await tester.pumpAndSettle(); expect(find.byType(CheckboxListTile), findsNWidgets(10)); expect(find.text('Torrent Screen Items'), findsOneWidget); + expect(find.text('Show Progress Bar'), findsOneWidget); + expect( + tester + .widget(find.byKey(Key('Show Progress Bar'))) + .value, + true); expect(find.text('Date Added'), findsOneWidget); expect(tester.widget(find.byKey(Key('Date Added'))).value, true); @@ -394,9 +400,6 @@ void main() { expect(find.text('Location'), findsOneWidget); expect(tester.widget(find.byKey(Key('Location'))).value, true); - expect(find.text('Tags'), findsOneWidget); - expect( - tester.widget(find.byKey(Key('Tags'))).value, true); await tester.drag(find.text('Context Menu Items'), Offset(0.0, -300.0)); await tester.pumpAndSettle(); expect(find.text('Delete'), findsOneWidget); @@ -415,6 +418,9 @@ void main() { expect( tester.widget(find.byKey(Key('Set Trackers'))).value, false); + expect(find.text('Tag Selector Preference'), findsOneWidget); + expect(find.text('Single Selection'), findsOneWidget); + expect(find.text('Multi Selection'), findsOneWidget); }); testWidgets('Check Power Management Section', (WidgetTester tester) async { diff --git a/test/widget_test/torrent_screen_widget_test.dart b/test/widget_test/torrent_screen_widget_test.dart index cea7a1e..8c29445 100644 --- a/test/widget_test/torrent_screen_widget_test.dart +++ b/test/widget_test/torrent_screen_widget_test.dart @@ -62,31 +62,32 @@ void main() { when(() => mockUserInterfaceBloc.state).thenReturn(UserInterfaceState( model: UserInterfaceModel( - showDateAdded: true, - showDateCreated: true, - showRatio: true, - showLocation: true, - showTags: true, - showTrackers: true, - showTrackersMessage: true, - showDownloadSpeed: true, - showUploadSpeed: true, - showPeers: true, - showSeeds: true, - showSize: true, - showType: true, - showHash: true, - showDelete: true, - showCheckHash: true, - showReannounce: true, - showSetTags: true, - showSetTrackers: true, - showGenerateMagnetLink: true, - showPriority: true, - showInitialSeeding: true, - showSequentialDownload: true, - showDownloadTorrent: true, - ), + showDateAdded: true, + showDateCreated: true, + showRatio: true, + showLocation: true, + showTags: true, + showTrackers: true, + showTrackersMessage: true, + showDownloadSpeed: true, + showUploadSpeed: true, + showPeers: true, + showSeeds: true, + showSize: true, + showType: true, + showHash: true, + showDelete: true, + showCheckHash: true, + showReannounce: true, + showSetTags: true, + showSetTrackers: true, + showGenerateMagnetLink: true, + showPriority: true, + showInitialSeeding: true, + showSequentialDownload: true, + showDownloadTorrent: true, + showProgressBar: true, + tagPreferenceButtonValue: TagPreferenceButtonValue.multiSelection), )); when(() => mockClientSettingsBloc.clientSettings).thenReturn( ClientSettingsModel(