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
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
...
...
@@ -91,7 +91,7 @@
<action
selector=
"showPanel:"
destination=
"BYZ-38-t0r"
eventType=
"touchUpInside"
id=
"jam-Ds-LOJ"
/>
</connections>
</button>
<view
contentMode=
"scaleToFill"
translatesAutoresizingMaskIntoConstraints=
"NO"
id=
"Ul6-yG-7a1"
>
<view
contentMode=
"scaleToFill"
translatesAutoresizingMaskIntoConstraints=
"NO"
id=
"Ul6-yG-7a1"
userLabel=
"buttonBoard"
>
<rect
key=
"frame"
x=
"0.0"
y=
"631"
width=
"414"
height=
"231"
/>
<subviews>
<button
opaque=
"NO"
contentMode=
"scaleToFill"
contentHorizontalAlignment=
"center"
contentVerticalAlignment=
"center"
lineBreakMode=
"middleTruncation"
translatesAutoresizingMaskIntoConstraints=
"NO"
id=
"eST-58-iE6"
>
...
...
@@ -254,6 +254,62 @@
<constraint
firstItem=
"PtM-de-bTT"
firstAttribute=
"leading"
secondItem=
"wyh-ZZ-B5n"
secondAttribute=
"leading"
id=
"l3P-nK-5Hp"
/>
</constraints>
</view>
<view
hidden=
"YES"
contentMode=
"scaleToFill"
translatesAutoresizingMaskIntoConstraints=
"NO"
id=
"22D-EX-aoe"
>
<rect
key=
"frame"
x=
"0.0"
y=
"0.0"
width=
"414"
height=
"896"
/>
<subviews>
<view
contentMode=
"scaleToFill"
translatesAutoresizingMaskIntoConstraints=
"NO"
id=
"AI5-gW-mDn"
>
<rect
key=
"frame"
x=
"60"
y=
"358"
width=
"294"
height=
"180.5"
/>
<subviews>
<label
opaque=
"NO"
userInteractionEnabled=
"NO"
contentMode=
"left"
horizontalHuggingPriority=
"251"
verticalHuggingPriority=
"251"
text=
"Label"
textAlignment=
"center"
lineBreakMode=
"tailTruncation"
baselineAdjustment=
"alignBaselines"
adjustsFontSizeToFit=
"NO"
translatesAutoresizingMaskIntoConstraints=
"NO"
id=
"Cwa-eM-zJh"
>
<rect
key=
"frame"
x=
"0.0"
y=
"24"
width=
"294"
height=
"23"
/>
<fontDescription
key=
"fontDescription"
type=
"system"
weight=
"semibold"
pointSize=
"19"
/>
<nil
key=
"textColor"
/>
<nil
key=
"highlightedColor"
/>
</label>
<label
opaque=
"NO"
userInteractionEnabled=
"NO"
contentMode=
"left"
horizontalHuggingPriority=
"251"
verticalHuggingPriority=
"251"
text=
"Label"
lineBreakMode=
"tailTruncation"
numberOfLines=
"0"
baselineAdjustment=
"alignBaselines"
adjustsFontSizeToFit=
"NO"
translatesAutoresizingMaskIntoConstraints=
"NO"
id=
"LGs-i4-o3S"
>
<rect
key=
"frame"
x=
"16"
y=
"71"
width=
"262"
height=
"21.5"
/>
<fontDescription
key=
"fontDescription"
type=
"system"
weight=
"medium"
pointSize=
"18"
/>
<nil
key=
"textColor"
/>
<nil
key=
"highlightedColor"
/>
</label>
<button
opaque=
"NO"
contentMode=
"scaleToFill"
contentHorizontalAlignment=
"center"
contentVerticalAlignment=
"center"
lineBreakMode=
"middleTruncation"
translatesAutoresizingMaskIntoConstraints=
"NO"
id=
"tzj-jo-egI"
>
<rect
key=
"frame"
x=
"35"
y=
"116.5"
width=
"224"
height=
"40"
/>
<constraints>
<constraint
firstAttribute=
"width"
secondItem=
"tzj-jo-egI"
secondAttribute=
"height"
multiplier=
"5.58974"
id=
"1d7-Ih-q0T"
/>
<constraint
firstAttribute=
"height"
constant=
"40"
id=
"b7T-6N-TMX"
/>
</constraints>
<fontDescription
key=
"fontDescription"
type=
"system"
weight=
"heavy"
pointSize=
"15"
/>
<inset
key=
"imageEdgeInsets"
minX=
"0.0"
minY=
"0.0"
maxX=
"2.2250738585072014e-308"
maxY=
"0.0"
/>
<state
key=
"normal"
title=
"Commencez maintenant"
backgroundImage=
"light-btn-bg"
>
<color
key=
"titleColor"
red=
"0.9459709181"
green=
"1"
blue=
"0.97093926880000003"
alpha=
"1"
colorSpace=
"custom"
customColorSpace=
"sRGB"
/>
</state>
<connections>
<action
selector=
"dismissPermissimPanel:"
destination=
"BYZ-38-t0r"
eventType=
"touchUpInside"
id=
"JeK-e2-Qpc"
/>
</connections>
</button>
</subviews>
<color
key=
"backgroundColor"
systemColor=
"systemBackgroundColor"
/>
<constraints>
<constraint
firstItem=
"LGs-i4-o3S"
firstAttribute=
"leading"
secondItem=
"AI5-gW-mDn"
secondAttribute=
"leading"
constant=
"16"
id=
"4DR-TA-9dU"
/>
<constraint
firstItem=
"tzj-jo-egI"
firstAttribute=
"width"
secondItem=
"tzj-jo-egI"
secondAttribute=
"height"
multiplier=
"5.58974"
id=
"EvE-mH-r19"
/>
<constraint
firstAttribute=
"trailing"
secondItem=
"Cwa-eM-zJh"
secondAttribute=
"trailing"
id=
"KRz-rd-9P5"
/>
<constraint
firstAttribute=
"trailing"
secondItem=
"LGs-i4-o3S"
secondAttribute=
"trailing"
constant=
"16"
id=
"M89-GN-cYm"
/>
<constraint
firstItem=
"tzj-jo-egI"
firstAttribute=
"centerX"
secondItem=
"AI5-gW-mDn"
secondAttribute=
"centerX"
id=
"O9X-mn-Hoc"
/>
<constraint
firstItem=
"tzj-jo-egI"
firstAttribute=
"top"
secondItem=
"LGs-i4-o3S"
secondAttribute=
"bottom"
constant=
"24"
id=
"OWS-Dn-zzi"
/>
<constraint
firstItem=
"Cwa-eM-zJh"
firstAttribute=
"leading"
secondItem=
"AI5-gW-mDn"
secondAttribute=
"leading"
id=
"Tw6-bA-0pz"
/>
<constraint
firstItem=
"Cwa-eM-zJh"
firstAttribute=
"top"
secondItem=
"AI5-gW-mDn"
secondAttribute=
"top"
constant=
"24"
id=
"YUm-OG-UVX"
/>
<constraint
firstAttribute=
"bottom"
secondItem=
"tzj-jo-egI"
secondAttribute=
"bottom"
constant=
"24"
id=
"uo6-ib-g4K"
/>
<constraint
firstItem=
"LGs-i4-o3S"
firstAttribute=
"top"
secondItem=
"Cwa-eM-zJh"
secondAttribute=
"bottom"
constant=
"24"
id=
"v6V-GT-0Hn"
/>
</constraints>
</view>
</subviews>
<color
key=
"backgroundColor"
systemColor=
"separatorColor"
/>
<constraints>
<constraint
firstAttribute=
"trailing"
secondItem=
"AI5-gW-mDn"
secondAttribute=
"trailing"
constant=
"60"
id=
"Hzz-F3-efa"
/>
<constraint
firstItem=
"AI5-gW-mDn"
firstAttribute=
"centerY"
secondItem=
"22D-EX-aoe"
secondAttribute=
"centerY"
id=
"dBs-XB-TlK"
/>
<constraint
firstItem=
"AI5-gW-mDn"
firstAttribute=
"leading"
secondItem=
"22D-EX-aoe"
secondAttribute=
"leading"
constant=
"60"
id=
"rLt-Lw-Lgz"
/>
</constraints>
</view>
</subviews>
<viewLayoutGuide
key=
"safeArea"
id=
"6Tk-OE-BBY"
/>
<color
key=
"backgroundColor"
systemColor=
"systemBackgroundColor"
/>
...
...
@@ -261,12 +317,16 @@
<constraint
firstItem=
"Ul6-yG-7a1"
firstAttribute=
"leading"
secondItem=
"6Tk-OE-BBY"
secondAttribute=
"leading"
id=
"3Gx-Ua-Pdc"
/>
<constraint
firstItem=
"6Tk-OE-BBY"
firstAttribute=
"trailing"
secondItem=
"wyh-ZZ-B5n"
secondAttribute=
"trailing"
constant=
"2"
id=
"8Fr-PB-8eU"
/>
<constraint
firstItem=
"w7E-9g-1V7"
firstAttribute=
"bottom"
secondItem=
"xYn-g0-EZC"
secondAttribute=
"bottom"
id=
"8tJ-bL-QXk"
/>
<constraint
firstItem=
"22D-EX-aoe"
firstAttribute=
"leading"
secondItem=
"8bC-Xf-vdC"
secondAttribute=
"leading"
id=
"DFB-ox-nFD"
/>
<constraint
firstItem=
"d65-2N-aD0"
firstAttribute=
"centerX"
secondItem=
"s7D-fE-2f9"
secondAttribute=
"centerX"
id=
"EdN-AA-PdS"
/>
<constraint
firstItem=
"xYn-g0-EZC"
firstAttribute=
"top"
secondItem=
"8bC-Xf-vdC"
secondAttribute=
"top"
id=
"Gsl-L7-Aq7"
/>
<constraint
firstAttribute=
"bottom"
secondItem=
"22D-EX-aoe"
secondAttribute=
"bottom"
id=
"HV1-jc-i0Y"
/>
<constraint
firstAttribute=
"trailing"
secondItem=
"xYn-g0-EZC"
secondAttribute=
"trailing"
id=
"K45-YL-0d0"
/>
<constraint
firstItem=
"s7D-fE-2f9"
firstAttribute=
"top"
secondItem=
"6Tk-OE-BBY"
secondAttribute=
"top"
id=
"OYj-Kc-2a3"
/>
<constraint
firstItem=
"w7E-9g-1V7"
firstAttribute=
"centerX"
secondItem=
"8bC-Xf-vdC"
secondAttribute=
"centerX"
id=
"REr-Ze-Id0"
/>
<constraint
firstItem=
"Ul6-yG-7a1"
firstAttribute=
"top"
secondItem=
"xYn-g0-EZC"
secondAttribute=
"bottom"
id=
"ROx-Yy-5fK"
/>
<constraint
firstAttribute=
"trailing"
secondItem=
"22D-EX-aoe"
secondAttribute=
"trailing"
id=
"baf-Ob-dTg"
/>
<constraint
firstItem=
"22D-EX-aoe"
firstAttribute=
"top"
secondItem=
"8bC-Xf-vdC"
secondAttribute=
"top"
id=
"gk1-Ue-dda"
/>
<constraint
firstItem=
"6Tk-OE-BBY"
firstAttribute=
"trailing"
secondItem=
"Ul6-yG-7a1"
secondAttribute=
"trailing"
id=
"i9C-my-t9E"
/>
<constraint
firstItem=
"xYn-g0-EZC"
firstAttribute=
"leading"
secondItem=
"8bC-Xf-vdC"
secondAttribute=
"leading"
id=
"k7e-sc-yFt"
/>
<constraint
firstItem=
"6Tk-OE-BBY"
firstAttribute=
"bottom"
secondItem=
"Ul6-yG-7a1"
secondAttribute=
"bottom"
id=
"mAd-oX-kjt"
/>
...
...
@@ -277,6 +337,11 @@
<navigationItem
key=
"navigationItem"
id=
"6kL-xH-Sf2"
/>
<connections>
<outlet
property=
"panelV"
destination=
"PtM-de-bTT"
id=
"Yyw-J0-d9K"
/>
<outlet
property=
"permisionPopupV"
destination=
"22D-EX-aoe"
id=
"mFa-Co-pUi"
/>
<outlet
property=
"permissionOKBtn"
destination=
"tzj-jo-egI"
id=
"34J-jc-5gN"
/>
<outlet
property=
"permissionPanel"
destination=
"AI5-gW-mDn"
id=
"IdV-BZ-E0U"
/>
<outlet
property=
"permissionText"
destination=
"LGs-i4-o3S"
id=
"o4l-Pn-4AF"
/>
<outlet
property=
"permissionTitle"
destination=
"Cwa-eM-zJh"
id=
"Ycd-Pp-k7z"
/>
<outlet
property=
"popupView"
destination=
"wyh-ZZ-B5n"
id=
"d1k-8B-Qfn"
/>
<outlet
property=
"startBtn"
destination=
"eST-58-iE6"
id=
"xlz-KM-eCt"
/>
<outlet
property=
"stepL1"
destination=
"1Ki-U8-ZmO"
id=
"CCh-wm-aah"
/>
...
...
BreastFeedingDemo/ViewController.swift
View file @
c311ada7
...
...
@@ -18,6 +18,11 @@ class ViewController: UIViewController {
@IBOutlet
weak
var
panelV
:
UIStackView
!
@IBOutlet
weak
var
popupView
:
UIView
!
@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
?
lazy
var
vm
:
ViewModel
=
.
init
()
var
isFirstLoad
:
Bool
=
true
...
...
@@ -27,8 +32,14 @@ class ViewController: UIViewController {
stepL1
.
text
=
vm
.
landingPageStep1
stepL2
.
text
=
vm
.
landingPageStep2
stepL3
.
text
=
vm
.
landingPageStep3
permissionText
.
text
=
vm
.
cameraText1
permissionTitle
.
text
=
vm
.
cameraText
permissionOKBtn
.
setTitle
(
vm
.
cameraButtonText
,
for
:
.
normal
)
startBtn
.
setTitle
(
vm
.
landingPageStart
,
for
:
.
normal
)
panelV
.
layer
.
cornerRadius
=
8
permissionPanel
.
layer
.
cornerRadius
=
8
permissionPanel
.
clipsToBounds
=
true
panelV
.
clipsToBounds
=
true
}
...
...
@@ -40,6 +51,10 @@ class ViewController: UIViewController {
updateUI
()
popupView
.
isHidden
=
true
AVCaptureDevice
.
requestAccess
(
for
:
.
video
,
completionHandler
:
{
accessGranted
in
guard
accessGranted
==
true
else
{
return
}
})
if
let
flutterEngine
=
(
UIApplication
.
shared
.
delegate
as?
AppDelegate
)?
.
flutterEngine
{
methodChannel
=
FlutterMethodChannel
(
name
:
"com.wmdigit.breastcoachai.native"
,
binaryMessenger
:
flutterEngine
.
binaryMessenger
)
...
...
@@ -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
?)
{
let
alertVC
=
UIAlertController
(
title
:
text
,
message
:
nil
,
preferredStyle
:
.
alert
)
alertVC
.
addAction
(
UIAlertAction
(
title
:
"OK"
,
style
:
.
cancel
))
...
...
@@ -87,6 +114,9 @@ class ViewController: UIViewController {
}
@IBAction
func
tapStart
(
_
sender
:
Any
)
{
if
!
checkCameraPermission
()
{
return
}
if
!
isFirstLoad
{
methodChannel
?
.
invokeMethod
(
"reload"
,
arguments
:
nil
)
}
...
...
@@ -115,6 +145,10 @@ class ViewController: UIViewController {
}
}
@IBAction
func
dismissPermissimPanel
(
_
sender
:
Any
)
{
permisionPopupV
.
isHidden
=
true
}
@IBAction
func
selectLanguage
(
_
sender
:
UIButton
)
{
switch
sender
.
tag
{
case
1000
:
...
...
BreastFeedingDemo/ViewModel.swift
View file @
c311ada7
...
...
@@ -31,6 +31,9 @@ class ViewModel {
var
landingPageStart
:
String
?
var
congratulation
:
String
?
var
completeBtn
:
String
?
var
cameraText
:
String
?
var
cameraText1
:
String
?
var
cameraButtonText
:
String
?
var
languagePack
:
[
String
:
Any
]
{
let
languageFile
=
language
.
rawValue
.
appending
(
".json"
)
...
...
@@ -69,6 +72,9 @@ class ViewModel {
landingPageStart
=
"Start Now"
congratulation
=
"Congratulations!"
completeBtn
=
"OK"
cameraText
=
"Camera not detected"
cameraText1
=
"Camera disabled. Please grant camera permission first!"
cameraButtonText
=
"OK"
case
.
français
:
landingPageTitle
=
"Coach AI en posture d'allaitement"
landingPageStep1
=
"Placez votre appareil sur une surface stable"
...
...
@@ -77,6 +83,9 @@ class ViewModel {
landingPageStart
=
"Commencez maintenant"
congratulation
=
"Toutes nos félicitations!"
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
:
landingPageTitle
=
"Asistente de AI de postura de lactancia"
landingPageStep1
=
"Coloque su dispositivo en una superficie estable"
...
...
@@ -85,6 +94,9 @@ class ViewModel {
landingPageStart
=
"Empezar ahora"
congratulation
=
"¡Felicidades!"
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