Skip to content

Commit

Permalink
Added Vibrations
Browse files Browse the repository at this point in the history
  • Loading branch information
insfirred committed Jun 24, 2022
1 parent 3d02183 commit 0b493f7
Show file tree
Hide file tree
Showing 5 changed files with 79 additions and 8 deletions.
25 changes: 25 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "inshorts_clone",
"request": "launch",
"type": "dart"
},
{
"name": "inshorts_clone (profile mode)",
"request": "launch",
"type": "dart",
"flutterMode": "profile"
},
{
"name": "inshorts_clone (release mode)",
"request": "launch",
"type": "dart",
"flutterMode": "release"
}
]
}
1 change: 1 addition & 0 deletions android/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,5 @@
android:value="2" />
</application>
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.VIBRATE"/>
</manifest>
26 changes: 18 additions & 8 deletions lib/Screens/newsList.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import 'package:flutter/material.dart';
import 'package:intl/intl.dart';
import 'package:http/http.dart' as http;
import 'package:fluttertoast/fluttertoast.dart';
import 'package:vibration/vibration.dart';

import '../HomeScreen.dart';
import './showImage.dart';
Expand Down Expand Up @@ -38,7 +39,6 @@ class _NewsListState extends State<NewsList> with AutomaticKeepAliveClientMixin<
return PageView.builder(
onPageChanged: (page){
HomeScreen.newsIndex = page;
print(HomeScreen.newsIndex);
},
scrollDirection: Axis.vertical,
itemCount: widget.jsonData["articles"].length,
Expand All @@ -47,8 +47,9 @@ class _NewsListState extends State<NewsList> with AutomaticKeepAliveClientMixin<
mainAxisAlignment: MainAxisAlignment.center,
children: [
InkWell(
onTap: () =>
Navigator.push(context, SizeTransition3(ShowImage("${widget.jsonData["articles"][index]["urlToImage"]}"))),
onTap: (){
Navigator.push(context, SizeTransition3(ShowImage("${widget.jsonData["articles"][index]["urlToImage"]}")));
},
child: SizedBox(
height: MediaQuery.of(context).size.height / 3,
child: ( widget.jsonData["articles"][index]["urlToImage"] != null )
Expand All @@ -67,10 +68,19 @@ class _NewsListState extends State<NewsList> with AutomaticKeepAliveClientMixin<
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
widget.jsonData["articles"][index]["title"],
style: TextStyle(fontSize: 25),
textAlign: TextAlign.justify),
GestureDetector(
onLongPress: (){
Vibration.vibrate(duration: 100);
Fluttertoast.showToast(
msg: "Added to Bookmarks",
backgroundColor: Color.fromARGB(255, 65, 63, 63)
);
},
child: Text(
widget.jsonData["articles"][index]["title"],
style: TextStyle(fontSize: 25,fontWeight: FontWeight.bold),
textAlign: TextAlign.justify),
),
const SizedBox(height: 10),
Text(
(widget.jsonData["articles"][index]["content"] != null)
Expand Down
33 changes: 33 additions & 0 deletions pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,18 @@ packages:
description: flutter
source: sdk
version: "0.0.0"
flutter_web_plugins:
dependency: transitive
description: flutter
source: sdk
version: "0.0.0"
fluttertoast:
dependency: "direct main"
description:
name: fluttertoast
url: "https://pub.dartlang.org"
source: hosted
version: "8.0.9"
font_awesome_flutter:
dependency: "direct main"
description:
Expand Down Expand Up @@ -102,6 +114,13 @@ packages:
url: "https://pub.dartlang.org"
source: hosted
version: "0.17.0"
js:
dependency: transitive
description:
name: js
url: "https://pub.dartlang.org"
source: hosted
version: "0.6.4"
lints:
dependency: transitive
description:
Expand Down Expand Up @@ -205,6 +224,20 @@ packages:
url: "https://pub.dartlang.org"
source: hosted
version: "2.1.2"
vibration:
dependency: "direct main"
description:
name: vibration
url: "https://pub.dartlang.org"
source: hosted
version: "1.7.3"
vibration_web:
dependency: transitive
description:
name: vibration_web
url: "https://pub.dartlang.org"
source: hosted
version: "1.6.2"
webview_flutter:
dependency: "direct main"
description:
Expand Down
2 changes: 2 additions & 0 deletions pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ dependencies:
intl: ^0.17.0
font_awesome_flutter: ^10.1.0
webview_flutter: ^3.0.4
fluttertoast: ^8.0.9
vibration: ^1.7.3

dev_dependencies:
flutter_test:
Expand Down

0 comments on commit 0b493f7

Please sign in to comment.