Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
C
Crm Attendance
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Dio Maulana
Crm Attendance
Commits
af6dfec2
Commit
af6dfec2
authored
May 31, 2023
by
Dio Maulana
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fixed error camera permission and slicing done
parent
588665f2
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
153 additions
and
10 deletions
+153
-10
main.dart
lib/main.dart
+2
-1
absent_camera.dart
lib/page/absent_camera/absent_camera.dart
+79
-5
error_camera.dart
lib/page/error/error_camera.dart
+38
-0
onboarding.dart
lib/page/onboarding/onboarding.dart
+26
-1
routes.dart
lib/resource/routes.dart
+8
-3
No files found.
lib/main.dart
View file @
af6dfec2
...
...
@@ -7,10 +7,11 @@ bool debug = true;
late
SharedPreferences
prefs
;
String
titleApp
=
'Excelso Attendances'
;
void
main
(
)
{
void
main
(
)
async
{
WidgetsFlutterBinding
.
ensureInitialized
();
setPathUrlStrategy
();
runApp
(
const
MyApp
());
}
...
...
lib/page/absent_camera/absent_camera.dart
View file @
af6dfec2
...
...
@@ -41,6 +41,9 @@ class _AbsentCameraViewState extends State<AbsentCameraView> {
bool
pictureIsTaken
=
false
;
bool
isPhone
=
false
;
// bool isPermissionAccept = true;
// String? errorCamera;
@override
void
initState
()
{
super
.
initState
();
...
...
@@ -62,10 +65,10 @@ class _AbsentCameraViewState extends State<AbsentCameraView> {
getCameraDescrption
().
then
((
value
)
{
cameras
=
value
;
if
(
cameras
!.
length
>
1
)
{
_cameraDescription
=
cameras
!
[
1
]
;
_cameraDescription
=
cameras
!
.
last
;
}
else
{
if
(
cameras
!.
isNotEmpty
)
{
_cameraDescription
=
cameras
!
[
0
]
;
_cameraDescription
=
cameras
!
.
first
;
}
else
{
_cameraDescription
=
null
;
}
...
...
@@ -83,6 +86,25 @@ class _AbsentCameraViewState extends State<AbsentCameraView> {
_initializeControllerFuture
=
_controller
!.
initialize
();
});
}
}).
catchError
((
e
)
{
if
(
e
is
CameraException
)
{
switch
(
e
.
code
)
{
case
'CameraAccessDenied'
:
// setState(() {
// isPermissionAccept = false;
// });
Navigator
.
pushNamedAndRemoveUntil
(
context
,
Routes
.
errorCamera
,
(
route
)
=>
false
);
default
:
// setState(() {
// errorCamera = "$e";
// });
if
(
debug
)
{
// ignore: avoid_print
print
(
"CAMERA PERMISSION PROB ERROR:
$e
"
);
}
}
}
});
}
...
...
@@ -106,6 +128,7 @@ class _AbsentCameraViewState extends State<AbsentCameraView> {
return
Column
(
mainAxisAlignment:
MainAxisAlignment
.
center
,
children:
[
// (isPermissionAccept) ?
(
_initializeControllerFuture
!=
null
)
?
FutureBuilder
(
future:
_initializeControllerFuture
,
...
...
@@ -321,12 +344,12 @@ class _AbsentCameraViewState extends State<AbsentCameraView> {
if
(
cameras
!.
length
>
1
)
{
setState
(()
{
if
(
_cameraDescription
==
cameras
!
[
0
]
)
{
cameras
!
.
first
)
{
_cameraDescription
=
cameras
!
[
1
]
;
cameras
!
.
last
;
}
else
{
_cameraDescription
=
cameras
!
[
0
]
;
cameras
!
.
first
;
}
_controller
=
CameraController
(
...
...
@@ -362,6 +385,57 @@ class _AbsentCameraViewState extends State<AbsentCameraView> {
}),
)
:
const
Center
(
child:
CircularProgressIndicator
())
// : Center(
// child: Padding(
// padding: EdgeInsets.symmetric(
// horizontal: AppPadding.p20,
// ),
// child: Column(
// children: [
// Text(
// "Silakan aktifkan permission kamera pada pengaturan browser anda",
// style: getBoldStyle(
// color: Colors.black,
// fontSize: 16,
// ),
// textAlign: TextAlign.center,
// ),
// (errorCamera != null)
// ? Container(
// margin: const EdgeInsets.only(
// top: 10,
// ),
// child: Text(
// "Error; $errorCamera",
// style: getBoldStyle(
// color: Colors.black,
// fontSize: 16,
// ),
// ),
// )
// : const SizedBox(),
// // const SizedBox(
// // height: 10,
// // ),
// // CustomButton(
// // text: "Aktifkan kamera",
// // onTap: () async {
// // final perm = await html.window.navigator.permissions!
// // .query({"name": "camera"});
// // if (perm.state == "denied") {
// // print("DENIED");
// // await html.window.navigator
// // .getUserMedia(audio: true, video: true);
// // return;
// // }
// // final stream = await html.window.navigator
// // .getUserMedia(video: true);
// // },
// // )
// ],
// ),
// ),
// )
],
);
}
...
...
lib/page/error/error_camera.dart
0 → 100644
View file @
af6dfec2
// ignore_for_file: sized_box_for_whitespace
import
'package:excelso_attendance/helper/widget_responsive.dart'
;
import
'package:excelso_attendance/resource/colors.dart'
;
import
'package:excelso_attendance/resource/style.dart'
;
import
'package:flutter/material.dart'
;
class
ErrorCameraView
extends
StatelessWidget
{
const
ErrorCameraView
({
super
.
key
});
@override
Widget
build
(
BuildContext
context
)
{
return
Scaffold
(
backgroundColor:
ColorManager
.
backgroundColor
,
body:
ScreenResponsive
(
widget:
Container
(
width:
double
.
infinity
,
height:
double
.
infinity
,
child:
Column
(
mainAxisAlignment:
MainAxisAlignment
.
center
,
crossAxisAlignment:
CrossAxisAlignment
.
center
,
children:
[
Text
(
"Silakan aktifkan permission kamera pada pengaturan browser anda"
,
style:
getBoldStyle
(
color:
Colors
.
black
,
fontSize:
16
,
),
textAlign:
TextAlign
.
center
,
),
],
),
),
widthScreen:
MediaQuery
.
of
(
context
).
size
.
width
,
),
);
}
}
lib/page/onboarding/onboarding.dart
View file @
af6dfec2
...
...
@@ -6,10 +6,35 @@ import 'package:excelso_attendance/resource/routes.dart';
import
'package:excelso_attendance/resource/size.dart'
;
import
'package:excelso_attendance/resource/style.dart'
;
import
'package:flutter/material.dart'
;
// ignore: avoid_web_libraries_in_flutter
import
'dart:html'
as
html
;
class
OnBoardingView
extends
State
less
Widget
{
class
OnBoardingView
extends
State
ful
Widget
{
const
OnBoardingView
({
super
.
key
});
@override
State
<
OnBoardingView
>
createState
()
=>
_OnBoardingViewState
();
}
class
_OnBoardingViewState
extends
State
<
OnBoardingView
>
{
@override
void
initState
()
{
super
.
initState
();
getUserPermission
();
// final perm =
// await html.window.navigator.permissions!.query({"name": "camera"});
// if (perm.state == "denied") {
// // ignore: use_build_context_synchronously
// Navigator.pushNamedAndRemoveUntil(
// context, Routes.errorCamera, (route) => false);
// return;
// }
}
void
getUserPermission
()
async
{
await
html
.
window
.
navigator
.
getUserMedia
(
audio:
true
,
video:
true
);
}
@override
Widget
build
(
BuildContext
context
)
{
return
Scaffold
(
...
...
lib/resource/routes.dart
View file @
af6dfec2
...
...
@@ -2,6 +2,7 @@ import 'package:excelso_attendance/helper/arguments/route_args.dart';
import
'package:excelso_attendance/main.dart'
;
import
'package:excelso_attendance/page/absent_camera/absent_camera.dart'
;
import
'package:excelso_attendance/page/absent_success/absent_success.dart'
;
import
'package:excelso_attendance/page/error/error_camera.dart'
;
import
'package:excelso_attendance/page/home/home.dart'
;
import
'package:excelso_attendance/page/onboarding/onboarding.dart'
;
import
'package:flutter/material.dart'
;
...
...
@@ -12,6 +13,7 @@ class Routes {
static
const
String
home
=
"/home"
;
static
const
String
absentCamera
=
"/absent-camera"
;
static
const
String
absentSuccess
=
"/absent-success"
;
static
const
String
errorCamera
=
"/error-camera"
;
}
class
RouteGenerator
{
...
...
@@ -36,6 +38,9 @@ class RouteGenerator {
case
Routes
.
absentSuccess
:
return
pageRouteCustom
(
const
AbsentSuccessView
(),
nameRoute:
Routes
.
absentSuccess
);
case
Routes
.
errorCamera
:
return
pageRouteCustom
(
const
ErrorCameraView
(),
nameRoute:
Routes
.
errorCamera
);
default
:
return
unDefinedRoute
();
}
...
...
@@ -64,15 +69,15 @@ class RouteGenerator {
),
transitionDuration:
Duration
.
zero
,
reverseTransitionDuration:
Duration
.
zero
,
settings:
RouteSettings
(
name:
nameRoute
.
replaceFirst
(
"/"
,
""
),
arguments:
args
),
//
settings: RouteSettings(
//
name: nameRoute.replaceFirst("/", ""), arguments: args),
);
}
else
{
return
PageRouteBuilder
(
pageBuilder:
(
context
,
a
,
b
)
=>
target
,
transitionDuration:
Duration
.
zero
,
reverseTransitionDuration:
Duration
.
zero
,
settings:
RouteSettings
(
name:
nameRoute
.
replaceFirst
(
"/"
,
""
)),
//
settings: RouteSettings(name: nameRoute.replaceFirst("/", "")),
);
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment