diff --git a/lib/components/add_bottom_sheet.dart b/lib/components/add_bottom_sheet.dart new file mode 100644 index 0000000..6e27ba4 --- /dev/null +++ b/lib/components/add_bottom_sheet.dart @@ -0,0 +1,94 @@ +import 'package:flutter/material.dart'; +import 'package:flutter/services.dart'; +import 'package:provider/provider.dart'; +import 'package:rutorrentflutter/models/mode.dart'; +import 'data_input.dart'; + +class AddBottomSheet extends StatelessWidget { + final Function apiRequest; + final String dialogHint; + final TextEditingController urlTextController = TextEditingController(); + final FocusNode urlFocus = FocusNode(); + AddBottomSheet({@required this.apiRequest, @required this.dialogHint}); + @override + Widget build(BuildContext context) { + double wp = MediaQuery.of(context).size.width; + double hp = MediaQuery.of(context).size.height; + return Container( + height: 300, + child: Column( + crossAxisAlignment: CrossAxisAlignment.center, + children: [ + Container( + margin: EdgeInsets.symmetric( + horizontal: wp * 0.35, + ), + height: 5, + color: Color(0xffE8E8E8), + ), + SizedBox( + height: 20, + ), + Text( + 'Add link', + style: TextStyle( + fontSize: 14, + color: Provider.of(context).isLightMode + ? Colors.black54 + : Colors.white), + ), + SizedBox( + height: 30, + ), + Container( + width: double.infinity, + padding: const EdgeInsets.symmetric(horizontal: 32), + child: DataInput( + borderColor: Provider.of(context).isLightMode + ? Theme.of(context).primaryColor + : Colors.white, + textEditingController: urlTextController, + hintText: dialogHint, + focus: urlFocus, + suffixIconButton: IconButton( + color: Provider.of(context).isLightMode + ? Theme.of(context).primaryColor + : Colors.white, + onPressed: () async { + ClipboardData data = await Clipboard.getData('text/plain'); + if (data != null) + urlTextController.text = data.text.toString(); + if (urlFocus.hasFocus) urlFocus.unfocus(); + }, + icon: Icon(Icons.content_paste), + ), + ), + ), + Container( + padding: const EdgeInsets.symmetric(vertical: 16, horizontal: 36), + width: double.infinity, + child: RaisedButton( + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(5.0), + side: BorderSide(color: Theme.of(context).primaryColor), + ), + color: Theme.of(context).primaryColor, + child: Padding( + padding: + const EdgeInsets.symmetric(horizontal: 28, vertical: 16), + child: Text( + 'Start Download', + style: TextStyle(color: Colors.white, fontSize: 18), + ), + ), + onPressed: () { + apiRequest(urlTextController.text); + Navigator.pop(context); + }, + ), + ), + ], + ), + ); + } +} diff --git a/lib/screens/main_screen.dart b/lib/screens/main_screen.dart index 0ec6d22..3172079 100644 --- a/lib/screens/main_screen.dart +++ b/lib/screens/main_screen.dart @@ -2,6 +2,7 @@ import 'dart:async'; import 'package:package_info/package_info.dart'; import 'package:provider/provider.dart'; import 'package:rutorrentflutter/api/api_requests.dart'; +import 'package:rutorrentflutter/components/add_bottom_sheet.dart'; import 'package:rutorrentflutter/components/disk_space_block.dart'; import 'package:rutorrentflutter/components/add_dialog.dart'; import 'package:rutorrentflutter/models/settings.dart'; @@ -270,21 +271,24 @@ class _MainScreenState extends State { children: [ Text( 'Build Number : 1', - style: TextStyle(fontSize: 14,fontWeight: FontWeight.w600), + style: TextStyle( + fontSize: 14, fontWeight: FontWeight.w600), ), SizedBox( height: 15, ), Text( 'Release Date : 30.09.20', - style: TextStyle(fontSize: 14,fontWeight: FontWeight.w600), + style: TextStyle( + fontSize: 14, fontWeight: FontWeight.w600), ), SizedBox( height: 15, ), Text( 'Package Name : ${packageInfo.packageName}', - style: TextStyle(fontSize: 14,fontWeight: FontWeight.w600), + style: TextStyle( + fontSize: 14, fontWeight: FontWeight.w600), ), ], ); @@ -339,26 +343,45 @@ class _MainScreenState extends State { ), onPressed: () { if (_currentIndex == 0) { - showDialog( + showModalBottomSheet( context: context, - builder: (context) { - return AddDialog( - dialogHint: 'Enter Torrent Url', + builder: (BuildContext bc) { + return AddBottomSheet( apiRequest: (url) { ApiRequests.addTorrent(api, url); - }); + }, + dialogHint: 'Enter Torrent Url'); }); + // showDialog( + // context: context, + // builder: (context) { + // return AddDialog( + // dialogHint: 'Enter Torrent Url', + // apiRequest: (url) { + // ApiRequests.addTorrent(api, url); + // }); + // }); } else { - showDialog( + showModalBottomSheet( context: context, - builder: (context) { - return AddDialog( - dialogHint: 'Enter Rss Url', + builder: (BuildContext bc) { + return AddBottomSheet( apiRequest: (url) async { await ApiRequests.addRSS(api, url); setState(() {}); - }); + }, + dialogHint: 'Enter Rss Url'); }); + // showDialog( + // context: context, + // builder: (context) { + // return AddDialog( + // dialogHint: 'Enter Rss Url', + // apiRequest: (url) async { + // await ApiRequests.addRSS(api, url); + // setState(() {}); + // }); + // }); } }), ); diff --git a/pubspec.lock b/pubspec.lock index bca492a..14a65ea 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -1,27 +1,13 @@ # Generated by pub # See https://dart.dev/tools/pub/glossary#lockfile packages: - archive: - dependency: transitive - description: - name: archive - url: "https://pub.dartlang.org" - source: hosted - version: "2.0.13" - args: - dependency: transitive - description: - name: args - url: "https://pub.dartlang.org" - source: hosted - version: "1.6.0" async: dependency: transitive description: name: async url: "https://pub.dartlang.org" source: hosted - version: "2.4.1" + version: "2.4.2" boolean_selector: dependency: transitive description: @@ -29,6 +15,13 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "2.0.0" + characters: + dependency: transitive + description: + name: characters + url: "https://pub.dartlang.org" + source: hosted + version: "1.0.0" charcode: dependency: transitive description: @@ -36,13 +29,20 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "1.1.3" + clock: + dependency: transitive + description: + name: clock + url: "https://pub.dartlang.org" + source: hosted + version: "1.0.1" collection: dependency: transitive description: name: collection url: "https://pub.dartlang.org" source: hosted - version: "1.14.12" + version: "1.14.13" convert: dependency: transitive description: @@ -50,13 +50,6 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "2.1.1" - crypto: - dependency: transitive - description: - name: crypto - url: "https://pub.dartlang.org" - source: hosted - version: "2.1.4" cryptoutils: dependency: transitive description: @@ -78,6 +71,13 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "3.0.9" + fake_async: + dependency: transitive + description: + name: fake_async + url: "https://pub.dartlang.org" + source: hosted + version: "1.1.0" ffi: dependency: transitive description: @@ -191,13 +191,6 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "3.1.4" - image: - dependency: transitive - description: - name: image - url: "https://pub.dartlang.org" - source: hosted - version: "2.1.12" intl: dependency: "direct main" description: @@ -211,7 +204,7 @@ packages: name: matcher url: "https://pub.dartlang.org" source: hosted - version: "0.12.6" + version: "0.12.8" meta: dependency: transitive description: @@ -260,7 +253,7 @@ packages: name: path url: "https://pub.dartlang.org" source: hosted - version: "1.6.4" + version: "1.7.0" path_provider: dependency: "direct main" description: @@ -331,13 +324,6 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "4.1.3" - quiver: - dependency: transitive - description: - name: quiver - url: "https://pub.dartlang.org" - source: hosted - version: "2.1.3" shared_preferences: dependency: "direct main" description: @@ -398,7 +384,7 @@ packages: name: stack_trace url: "https://pub.dartlang.org" source: hosted - version: "1.9.3" + version: "1.9.5" stream_channel: dependency: transitive description: @@ -426,14 +412,14 @@ packages: name: test_api url: "https://pub.dartlang.org" source: hosted - version: "0.2.15" + version: "0.2.17" typed_data: dependency: transitive description: name: typed_data url: "https://pub.dartlang.org" source: hosted - version: "1.1.6" + version: "1.2.0" vector_math: dependency: transitive description: @@ -456,5 +442,5 @@ packages: source: hosted version: "3.6.1" sdks: - dart: ">=2.7.0 <3.0.0" + dart: ">=2.9.0-14.0.dev <3.0.0" flutter: ">=1.16.0 <2.0.0"