Skip to content

Commit

Permalink
access camera prank
Browse files Browse the repository at this point in the history
  • Loading branch information
martinericksonn committed Apr 6, 2022
1 parent 7e31227 commit cf3a728
Show file tree
Hide file tree
Showing 4 changed files with 81 additions and 13 deletions.
85 changes: 72 additions & 13 deletions todo_app/lib/src/screens/home.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// ignore_for_file: prefer_const_constructors, avoid_print

import 'package:flutter/material.dart';
import 'package:flutter_dialogs/flutter_dialogs.dart';
import 'package:todo_app/src/classes/todo_model.dart';
import 'package:buttons_tabbar/buttons_tabbar.dart';
import 'package:todo_app/src/screens/form.dart';
Expand All @@ -17,16 +18,14 @@ class HomeScreen extends StatefulWidget {

class _HomeScreenState extends State<HomeScreen> {
final TodoController _todoController = TodoController();
bool cameraAccess = false;
// @override
// void initState() {
// _todoController.addListener(newToDoListener);
// super.initState();

@override
void initState() {
_todoController.addListener(newToDoListener);
super.initState();
}

newToDoListener() {
print("Updated listener");
}
// showAlert(context);
// }

int? tempIndex;

Expand All @@ -39,14 +38,14 @@ class _HomeScreenState extends State<HomeScreen> {
backgroundColor: Theme.of(context).primaryColor,
body: appBody(context),
floatingActionButtonLocation: FloatingActionButtonLocation.centerFloat,
floatingActionButton: appFloatingButton(),
floatingActionButton: appFloatingButton(context),
),
);
}

FloatingActionButton appFloatingButton() {
FloatingActionButton appFloatingButton(context) {
return FloatingActionButton.extended(
onPressed: () => {showAddTaskModal()},
onPressed: () => {showAddTaskModal(context)},
label: Text(
"Add Task",
style: TextStyle(
Expand Down Expand Up @@ -122,7 +121,67 @@ class _HomeScreenState extends State<HomeScreen> {
);
}

showAddTaskModal() async {
showAlert(BuildContext context) async {
cameraAccess
? null
: showPlatformDialog(
context: context,
builder: (context) => BasicDialogAlert(
title: Row(
// mainAxisAlignment: MainAxisAlignment.start,
children: [
Container(
alignment: Alignment.topCenter,
child: Padding(
padding: const EdgeInsets.only(right: 8.0),
child: Icon(
Icons.camera_alt,
color: Colors.blue,
size: 30,
),
),
),
Flexible(
child: RichText(
text: TextSpan(
text: 'Allow ',
style: TextStyle(color: Colors.black),
children: const <TextSpan>[
TextSpan(
text: "Todo",
style: TextStyle(
fontWeight: FontWeight.bold,
color: Colors.black)),
TextSpan(
text: ' to take pictures and record videos?'),
])),
),
],
),
actions: <Widget>[
BasicDialogAction(
title: Text(
"DENY",
style: TextStyle(color: Colors.grey),
),
onPressed: null),
BasicDialogAction(
title: Text(
"ALLOW",
style: TextStyle(color: Colors.blue),
),
onPressed: () {
Navigator.pop(context);
},
),
],
),
);
cameraAccess = true;
}

showAddTaskModal(context) async {
showAlert(context);
Todo? task = await showModalBottomSheet(
isScrollControlled: true,
shape: RoundedRectangleBorder(
Expand Down
1 change: 1 addition & 0 deletions todo_app/lib/src/theme.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import 'package:flutter/material.dart';

ThemeData appTheme() {
return ThemeData(
primarySwatch: Colors.blue,
textSelectionTheme: TextSelectionThemeData(
cursorColor: Colors.black,
selectionColor: Colors.black45,
Expand Down
7 changes: 7 additions & 0 deletions todo_app/pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,13 @@ packages:
description: flutter
source: sdk
version: "0.0.0"
flutter_dialogs:
dependency: "direct main"
description:
name: flutter_dialogs
url: "https://pub.dartlang.org"
source: hosted
version: "2.1.1"
flutter_launcher_icons:
dependency: "direct main"
description:
Expand Down
1 change: 1 addition & 0 deletions todo_app/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ dependencies:
flutter_launcher_icons: ^0.9.2
hive: ^2.1.0
hive_flutter: ^1.1.0
flutter_dialogs: ^2.1.1

flutter_icons:
image_path: "assets/icon/todo_logo.png"
Expand Down

0 comments on commit cf3a728

Please sign in to comment.