Skip to content

Commit

Permalink
Added mic button functionality back
Browse files Browse the repository at this point in the history
  • Loading branch information
yashovardhan99 committed Jun 7, 2019
1 parent 46e9814 commit b76680e
Showing 1 changed file with 33 additions and 37 deletions.
70 changes: 33 additions & 37 deletions lib/pages/home_page.dart
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import 'dart:math' as math;

import 'package:audio_recorder2/audio_recorder2.dart';
import 'package:eva_icons_flutter/eva_icons_flutter.dart';
import 'package:flutter/material.dart';
import 'package:simple_permissions/simple_permissions.dart';
import 'package:font_awesome_flutter/font_awesome_flutter.dart';
import 'package:eva_icons_flutter/eva_icons_flutter.dart';
import 'dart:math' as math;
import 'package:simple_permissions/simple_permissions.dart';

class HomePage extends StatefulWidget {
@override
Expand Down Expand Up @@ -77,17 +78,38 @@ class _HomePageState extends State<HomePage>
icons[index],
),
backgroundColor: Colors.deepPurpleAccent,
onPressed: () {
onPressed: () async {
if(index==0) {
// Redirect to Gihub Repo/Organization
} else if(index == 1) {
// Redirect to Team Page
Navigator.of(context).pushNamed('/team_page');
} else {
// Recording through mic
setState(() {

});
bool hasPermissions = await AudioRecorder2.hasPermissions;
if (hasPermissions) {
Navigator.of(context).pushNamed("/mic");
}
else {
bool audioPermission = await SimplePermissions
.checkPermission(
Permission.RecordAudio);
bool storagePermission = await SimplePermissions
.checkPermission(
Permission.WriteExternalStorage);
if (!audioPermission) {
await SimplePermissions.requestPermission(
Permission.RecordAudio);
}
if (!storagePermission) {
await SimplePermissions.requestPermission(
Permission.WriteExternalStorage);
}
hasPermissions = await AudioRecorder2.hasPermissions;
if (hasPermissions) {
Navigator.of(context).pushNamed("/mic");
}
}
}
},
),
Expand All @@ -103,10 +125,12 @@ class _HomePageState extends State<HomePage>
builder: (BuildContext context, Widget child) {
return Transform(
transform:
Matrix4.rotationZ(_controller.value * 0.5 * math.pi),
Matrix4.rotationZ(_controller.value * 0.5 * math.pi),
alignment: FractionalOffset.center,
child: Icon(
_controller.isDismissed ? EvaIcons.activityOutline : EvaIcons.closeCircleOutline,),
_controller.isDismissed
? EvaIcons.activityOutline
: EvaIcons.closeCircleOutline,),
);
},
),
Expand All @@ -122,34 +146,6 @@ class _HomePageState extends State<HomePage>
),
),
),
// FloatingActionButton(
// heroTag: "mic",
// onPressed: () async {
// bool hasPermissions = await AudioRecorder2.hasPermissions;
// if(hasPermissions) {
// Navigator.of(context).pushNamed("/mic");
// }
// else {
// bool audioPermission = await SimplePermissions.checkPermission(
// Permission.RecordAudio);
// bool storagePermission = await SimplePermissions.checkPermission(
// Permission.WriteExternalStorage);
// if (!audioPermission) {
// await SimplePermissions.requestPermission(Permission.RecordAudio);
// }
// if (!storagePermission) {
// await SimplePermissions.requestPermission(
// Permission.WriteExternalStorage);
// }
// hasPermissions = await AudioRecorder2.hasPermissions;
// if (hasPermissions) {
// Navigator.of(context).pushNamed("/mic");
// }
// }
// },
// backgroundColor: Colors.deepPurpleAccent,
// child: Icon(Icons.mic_none,color: Colors.white,),
// ),
bottomNavigationBar: BottomAppBar(
shape: CircularNotchedRectangle(),
child: Row(
Expand Down

0 comments on commit b76680e

Please sign in to comment.