Skip to content

Commit

Permalink
Added Bottom sheet (#9)
Browse files Browse the repository at this point in the history
* feat: Added bottom sheet to add torrent

* feat: Added bottom sheet to add rss
  • Loading branch information
pratikbaid3 authored Oct 2, 2020
1 parent 30f5a3f commit 86d5d0f
Show file tree
Hide file tree
Showing 3 changed files with 159 additions and 56 deletions.
94 changes: 94 additions & 0 deletions lib/components/add_bottom_sheet.dart
Original file line number Diff line number Diff line change
@@ -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: <Widget>[
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<Mode>(context).isLightMode
? Colors.black54
: Colors.white),
),
SizedBox(
height: 30,
),
Container(
width: double.infinity,
padding: const EdgeInsets.symmetric(horizontal: 32),
child: DataInput(
borderColor: Provider.of<Mode>(context).isLightMode
? Theme.of(context).primaryColor
: Colors.white,
textEditingController: urlTextController,
hintText: dialogHint,
focus: urlFocus,
suffixIconButton: IconButton(
color: Provider.of<Mode>(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);
},
),
),
],
),
);
}
}
49 changes: 36 additions & 13 deletions lib/screens/main_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -270,21 +271,24 @@ class _MainScreenState extends State<MainScreen> {
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),
),
],
);
Expand Down Expand Up @@ -339,26 +343,45 @@ class _MainScreenState extends State<MainScreen> {
),
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(() {});
// });
// });
}
}),
);
Expand Down
72 changes: 29 additions & 43 deletions pubspec.lock
Original file line number Diff line number Diff line change
@@ -1,62 +1,55 @@
# 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:
name: boolean_selector
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:
name: charcode
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:
name: convert
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:
Expand All @@ -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:
Expand Down Expand Up @@ -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:
Expand All @@ -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:
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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:
Expand All @@ -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"

0 comments on commit 86d5d0f

Please sign in to comment.