Skip to content

Commit

Permalink
Small modifications, fixed some exceptions, some route issues
Browse files Browse the repository at this point in the history
  • Loading branch information
nisiddharth committed Nov 15, 2021
1 parent 5524de4 commit 3acb715
Show file tree
Hide file tree
Showing 4 changed files with 67 additions and 78 deletions.
47 changes: 28 additions & 19 deletions lib/homepage.dart
Original file line number Diff line number Diff line change
Expand Up @@ -22,28 +22,37 @@ class _HomePageState extends State<HomePage> {
// the App.build method, and use it to set our appbar title.
title: Text(widget.title),
),
body: Container(
margin: const EdgeInsets.all(12),
child: StaggeredGridView.countBuilder(
crossAxisCount: 2,
crossAxisSpacing: 10,
mainAxisSpacing: 12,
itemCount: cardList.length,
itemBuilder: (context, index) {
return cardList[index];
},
staggeredTileBuilder: (index) {
return StaggeredTile.count(1, index.isEven ? 1.2 : 1.8);
}),
),
body: StaggeredGridView.countBuilder(
padding: const EdgeInsets.all(12),
crossAxisCount: 2,
crossAxisSpacing: 10,
mainAxisSpacing: 12,
itemCount: cardList.length,
itemBuilder: (context, index) {
return cardList[index];
},
staggeredTileBuilder: (index) {
return StaggeredTile.count(1, index.isEven ? 1.2 : 1.8);
}),
);
}

List<HomeCard> cardList = [
const HomeCard(title: "Flashlight", color: Colors.redAccent, icon: Icons.flashlight_on),
const HomeCard(title: "Compass", color: Colors.blueGrey, icon: Icons.explore),
const HomeCard(title: "Weather", color: Colors.lightGreen, icon: Icons.wb_sunny),
const HomeCard( title: "MOD Calculator", color: Colors.deepOrangeAccent, icon: Icons.calculate),
const HomeCard( title: "YouTube Downloader", color: Colors.deepPurple, icon: Icons.download),
const HomeCard(
title: "Flashlight",
color: Colors.redAccent,
icon: Icons.flashlight_on),
const HomeCard(
title: "Compass", color: Colors.blueGrey, icon: Icons.explore),
const HomeCard(
title: "Weather", color: Colors.lightGreen, icon: Icons.wb_sunny),
const HomeCard(
title: "MOD Calculator",
color: Colors.deepOrangeAccent,
icon: Icons.calculate),
const HomeCard(
title: "YouTube Downloader",
color: Colors.deepPurple,
icon: Icons.download),
];
}
88 changes: 34 additions & 54 deletions lib/utility_screens/compass.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,52 +7,6 @@ import 'package:permission_handler/permission_handler.dart';
import 'package:upyogaarth/main.dart';
import 'package:sensors_plus/sensors_plus.dart';

class CompassScreenAnimation extends StatelessWidget {
const CompassScreenAnimation({Key? key}) : super(key: key);

@override
Widget build(BuildContext context) {
Future.delayed(Duration.zero, () => showAlert(context));
return Scaffold(
appBar: AppBar(
title: const Text("Compass"),
),
body: const Center(
child: Text("demo text"),
),
);
}

void showAlert(BuildContext context) {
Widget okButton = TextButton(
child: Text("OK"),
onPressed: () {
Navigator.of(context, rootNavigator: true).pop();
Navigator.push(context,
MaterialPageRoute(builder: (context) => const CompassScreen()));
},
);

showDialog(
context: context,
builder: (BuildContext buildContext) => AlertDialog(
title: Text(
'Compass Calibration',
textAlign: TextAlign.center,
),
contentPadding: const EdgeInsets.fromLTRB(0, 24, 0, 0),
content: Container(
child: Image.asset(
'assets/calibrate.gif',
height: 300.0,
width: 300.0,
),
),
actions: [okButton],
));
}
}

class CompassScreen extends StatefulWidget {
const CompassScreen({
Key? key,
Expand All @@ -76,7 +30,7 @@ class _CompassScreenState extends State<CompassScreen> {
@override
void initState() {
super.initState();
timer = Timer.periodic(Duration(seconds: 2), (Timer t) => compassValue());
timer = Timer.periodic(const Duration(seconds: 2), (Timer t) => compassValue());
_fetchPermissionStatus();

_streamSubscriptions.add(
Expand All @@ -98,6 +52,7 @@ class _CompassScreenState extends State<CompassScreen> {
},
),
);
Future.delayed(Duration.zero, () => showAlert(context));
}

void updateCompassValues() {
Expand Down Expand Up @@ -210,48 +165,48 @@ class _CompassScreenState extends State<CompassScreen> {
const SizedBox(height: 5),
Text(
headCamtoString(_lastRead!) + '°',
style: TextStyle(fontSize: 12.0),
style: const TextStyle(fontSize: 12.0),
textAlign: TextAlign.start,
),
const SizedBox(height: 5),
Text(
acctoString(_lastRead!) + '°',
style: TextStyle(fontSize: 12.0),
style: const TextStyle(fontSize: 12.0),
textAlign: TextAlign.start,
),
//to be edited from here
const SizedBox(height: 5),
Text(
azitoString() + '°',
style: TextStyle(fontSize: 12.0),
style: const TextStyle(fontSize: 12.0),
textAlign: TextAlign.start,
),
const SizedBox(height: 5),
Text(
pitchtoString() + '°',
style: TextStyle(fontSize: 12.0),
style: const TextStyle(fontSize: 12.0),
textAlign: TextAlign.start,
),
const SizedBox(height: 5),
Text(
rolltoString() + '°',
style: TextStyle(fontSize: 12.0),
style: const TextStyle(fontSize: 12.0),
textAlign: TextAlign.start,
),
],
const SizedBox(height: 5),
if (_lastReadAt == null) ...[
Text(
'Last Read At: $_lastReadAt',
style: TextStyle(fontSize: 20.0),
style: const TextStyle(fontSize: 20.0),
textAlign: TextAlign.start,
),
] else ...[
Text(
DateFormat.yMd().format(_lastReadAt!) +
'\n' +
DateFormat.jms().format(_lastReadAt!),
style: TextStyle(fontSize: 12.0),
style: const TextStyle(fontSize: 12.0),
textAlign: TextAlign.start,
)
]
Expand Down Expand Up @@ -386,4 +341,29 @@ class _CompassScreenState extends State<CompassScreen> {
timer.cancel();
super.dispose();
}

void showAlert(BuildContext context) {
Widget okButton = TextButton(
child: const Text("OK"),
onPressed: () {
Navigator.of(context).pop();
},
);

showDialog(
context: context,
builder: (BuildContext buildContext) => AlertDialog(
title: const Text(
'Compass Calibration',
textAlign: TextAlign.center,
),
contentPadding: const EdgeInsets.fromLTRB(0, 24, 0, 0),
content: Image.asset(
'assets/calibrate.gif',
height: 300.0,
width: 300.0,
),
actions: [okButton],
));
}
}
2 changes: 1 addition & 1 deletion lib/widgets/homecard.dart
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ class _HomeCardState extends State<HomeCard> {
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => const CompassScreenAnimation()));
builder: (context) => const CompassScreen()));
break;
case "Weather":
Navigator.push(context,
Expand Down
8 changes: 4 additions & 4 deletions pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ packages:
name: async
url: "https://pub.dartlang.org"
source: hosted
version: "2.6.1"
version: "2.8.1"
boolean_selector:
dependency: transitive
description:
Expand All @@ -28,7 +28,7 @@ packages:
name: charcode
url: "https://pub.dartlang.org"
source: hosted
version: "1.2.0"
version: "1.3.1"
clock:
dependency: transitive
description:
Expand Down Expand Up @@ -176,7 +176,7 @@ packages:
name: meta
url: "https://pub.dartlang.org"
source: hosted
version: "1.3.0"
version: "1.7.0"
path:
dependency: transitive
description:
Expand Down Expand Up @@ -279,7 +279,7 @@ packages:
name: test_api
url: "https://pub.dartlang.org"
source: hosted
version: "0.3.0"
version: "0.4.2"
torch_light:
dependency: "direct main"
description:
Expand Down

0 comments on commit 3acb715

Please sign in to comment.