Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
B
BreastFeedingAI-Demo-iOS
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
张杰
BreastFeedingAI-Demo-iOS
Commits
c311ada7
Commit
c311ada7
authored
Jun 10, 2022
by
jzhang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
权限
parent
c01964de
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
112 additions
and
1 deletion
+112
-1
Main.storyboard
BreastFeedingDemo/Base.lproj/Main.storyboard
+66
-1
ViewController.swift
BreastFeedingDemo/ViewController.swift
+34
-0
ViewModel.swift
BreastFeedingDemo/ViewModel.swift
+12
-0
No files found.
BreastFeedingDemo/Base.lproj/Main.storyboard
View file @
c311ada7
This diff is collapsed.
Click to expand it.
BreastFeedingDemo/ViewController.swift
View file @
c311ada7
...
@@ -18,6 +18,11 @@ class ViewController: UIViewController {
...
@@ -18,6 +18,11 @@ class ViewController: UIViewController {
@IBOutlet
weak
var
panelV
:
UIStackView
!
@IBOutlet
weak
var
panelV
:
UIStackView
!
@IBOutlet
weak
var
popupView
:
UIView
!
@IBOutlet
weak
var
popupView
:
UIView
!
@IBOutlet
weak
var
switchBtn
:
UIButton
!
@IBOutlet
weak
var
switchBtn
:
UIButton
!
@IBOutlet
weak
var
permisionPopupV
:
UIView
!
@IBOutlet
weak
var
permissionTitle
:
UILabel
!
@IBOutlet
weak
var
permissionText
:
UILabel
!
@IBOutlet
weak
var
permissionOKBtn
:
UIButton
!
@IBOutlet
weak
var
permissionPanel
:
UIView
!
var
methodChannel
:
FlutterMethodChannel
?
var
methodChannel
:
FlutterMethodChannel
?
lazy
var
vm
:
ViewModel
=
.
init
()
lazy
var
vm
:
ViewModel
=
.
init
()
var
isFirstLoad
:
Bool
=
true
var
isFirstLoad
:
Bool
=
true
...
@@ -27,8 +32,14 @@ class ViewController: UIViewController {
...
@@ -27,8 +32,14 @@ class ViewController: UIViewController {
stepL1
.
text
=
vm
.
landingPageStep1
stepL1
.
text
=
vm
.
landingPageStep1
stepL2
.
text
=
vm
.
landingPageStep2
stepL2
.
text
=
vm
.
landingPageStep2
stepL3
.
text
=
vm
.
landingPageStep3
stepL3
.
text
=
vm
.
landingPageStep3
permissionText
.
text
=
vm
.
cameraText1
permissionTitle
.
text
=
vm
.
cameraText
permissionOKBtn
.
setTitle
(
vm
.
cameraButtonText
,
for
:
.
normal
)
startBtn
.
setTitle
(
vm
.
landingPageStart
,
for
:
.
normal
)
startBtn
.
setTitle
(
vm
.
landingPageStart
,
for
:
.
normal
)
panelV
.
layer
.
cornerRadius
=
8
panelV
.
layer
.
cornerRadius
=
8
permissionPanel
.
layer
.
cornerRadius
=
8
permissionPanel
.
clipsToBounds
=
true
panelV
.
clipsToBounds
=
true
panelV
.
clipsToBounds
=
true
}
}
...
@@ -40,6 +51,10 @@ class ViewController: UIViewController {
...
@@ -40,6 +51,10 @@ class ViewController: UIViewController {
updateUI
()
updateUI
()
popupView
.
isHidden
=
true
popupView
.
isHidden
=
true
AVCaptureDevice
.
requestAccess
(
for
:
.
video
,
completionHandler
:
{
accessGranted
in
guard
accessGranted
==
true
else
{
return
}
})
if
let
flutterEngine
=
(
UIApplication
.
shared
.
delegate
as?
AppDelegate
)?
.
flutterEngine
{
if
let
flutterEngine
=
(
UIApplication
.
shared
.
delegate
as?
AppDelegate
)?
.
flutterEngine
{
methodChannel
=
FlutterMethodChannel
(
name
:
"com.wmdigit.breastcoachai.native"
,
methodChannel
=
FlutterMethodChannel
(
name
:
"com.wmdigit.breastcoachai.native"
,
binaryMessenger
:
flutterEngine
.
binaryMessenger
)
binaryMessenger
:
flutterEngine
.
binaryMessenger
)
...
@@ -73,6 +88,18 @@ class ViewController: UIViewController {
...
@@ -73,6 +88,18 @@ class ViewController: UIViewController {
}
}
}
}
func
checkCameraPermission
()
->
Bool
{
let
cameraAuthorizationStatus
=
AVCaptureDevice
.
authorizationStatus
(
for
:
.
video
)
switch
cameraAuthorizationStatus
{
case
.
authorized
:
return
true
default
:
permisionPopupV
.
isHidden
=
false
return
false
}
}
func
showError
(
_
text
:
String
?)
{
func
showError
(
_
text
:
String
?)
{
let
alertVC
=
UIAlertController
(
title
:
text
,
message
:
nil
,
preferredStyle
:
.
alert
)
let
alertVC
=
UIAlertController
(
title
:
text
,
message
:
nil
,
preferredStyle
:
.
alert
)
alertVC
.
addAction
(
UIAlertAction
(
title
:
"OK"
,
style
:
.
cancel
))
alertVC
.
addAction
(
UIAlertAction
(
title
:
"OK"
,
style
:
.
cancel
))
...
@@ -87,6 +114,9 @@ class ViewController: UIViewController {
...
@@ -87,6 +114,9 @@ class ViewController: UIViewController {
}
}
@IBAction
func
tapStart
(
_
sender
:
Any
)
{
@IBAction
func
tapStart
(
_
sender
:
Any
)
{
if
!
checkCameraPermission
()
{
return
}
if
!
isFirstLoad
{
if
!
isFirstLoad
{
methodChannel
?
.
invokeMethod
(
"reload"
,
arguments
:
nil
)
methodChannel
?
.
invokeMethod
(
"reload"
,
arguments
:
nil
)
}
}
...
@@ -115,6 +145,10 @@ class ViewController: UIViewController {
...
@@ -115,6 +145,10 @@ class ViewController: UIViewController {
}
}
}
}
@IBAction
func
dismissPermissimPanel
(
_
sender
:
Any
)
{
permisionPopupV
.
isHidden
=
true
}
@IBAction
func
selectLanguage
(
_
sender
:
UIButton
)
{
@IBAction
func
selectLanguage
(
_
sender
:
UIButton
)
{
switch
sender
.
tag
{
switch
sender
.
tag
{
case
1000
:
case
1000
:
...
...
BreastFeedingDemo/ViewModel.swift
View file @
c311ada7
...
@@ -31,6 +31,9 @@ class ViewModel {
...
@@ -31,6 +31,9 @@ class ViewModel {
var
landingPageStart
:
String
?
var
landingPageStart
:
String
?
var
congratulation
:
String
?
var
congratulation
:
String
?
var
completeBtn
:
String
?
var
completeBtn
:
String
?
var
cameraText
:
String
?
var
cameraText1
:
String
?
var
cameraButtonText
:
String
?
var
languagePack
:
[
String
:
Any
]
{
var
languagePack
:
[
String
:
Any
]
{
let
languageFile
=
language
.
rawValue
.
appending
(
".json"
)
let
languageFile
=
language
.
rawValue
.
appending
(
".json"
)
...
@@ -69,6 +72,9 @@ class ViewModel {
...
@@ -69,6 +72,9 @@ class ViewModel {
landingPageStart
=
"Start Now"
landingPageStart
=
"Start Now"
congratulation
=
"Congratulations!"
congratulation
=
"Congratulations!"
completeBtn
=
"OK"
completeBtn
=
"OK"
cameraText
=
"Camera not detected"
cameraText1
=
"Camera disabled. Please grant camera permission first!"
cameraButtonText
=
"OK"
case
.
français
:
case
.
français
:
landingPageTitle
=
"Coach AI en posture d'allaitement"
landingPageTitle
=
"Coach AI en posture d'allaitement"
landingPageStep1
=
"Placez votre appareil sur une surface stable"
landingPageStep1
=
"Placez votre appareil sur une surface stable"
...
@@ -77,6 +83,9 @@ class ViewModel {
...
@@ -77,6 +83,9 @@ class ViewModel {
landingPageStart
=
"Commencez maintenant"
landingPageStart
=
"Commencez maintenant"
congratulation
=
"Toutes nos félicitations!"
congratulation
=
"Toutes nos félicitations!"
completeBtn
=
"OK"
completeBtn
=
"OK"
cameraText
=
"Caméra non détectée"
cameraText1
=
"Caméra désactivée. Veuillez d'abord accorder l'autorisation de la caméra !"
cameraButtonText
=
"OK"
case
.
español
:
case
.
español
:
landingPageTitle
=
"Asistente de AI de postura de lactancia"
landingPageTitle
=
"Asistente de AI de postura de lactancia"
landingPageStep1
=
"Coloque su dispositivo en una superficie estable"
landingPageStep1
=
"Coloque su dispositivo en una superficie estable"
...
@@ -85,6 +94,9 @@ class ViewModel {
...
@@ -85,6 +94,9 @@ class ViewModel {
landingPageStart
=
"Empezar ahora"
landingPageStart
=
"Empezar ahora"
congratulation
=
"¡Felicidades!"
congratulation
=
"¡Felicidades!"
completeBtn
=
"DE ACUERDO"
completeBtn
=
"DE ACUERDO"
cameraText
=
"Cámara no detectada"
cameraText1
=
"Cámara desactivada. ¡Por favor, conceda permiso a la cámara primero!"
cameraButtonText
=
"DE ACUERDO"
}
}
}
}
}
}
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