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
d33dac7c
Commit
d33dac7c
authored
Sep 26, 2022
by
jzhang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
启动flutter以及权限申请逻辑重构
parent
9bfb76fe
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
67 additions
and
46 deletions
+67
-46
project.pbxproj
BreastFeedingDemo.xcodeproj/project.pbxproj
+0
-8
Main.storyboard
BreastFeedingDemo/Base.lproj/Main.storyboard
+3
-0
DemoViewController.swift
BreastFeedingDemo/DemoViewController.swift
+61
-0
PermissionAlertVC.swift
BreastFeedingDemo/PermissionAlertVC.swift
+3
-0
PermissionAlertView.swift
BreastFeedingDemo/PermissionAlertView.swift
+0
-10
PermissionAlertView.xib
BreastFeedingDemo/PermissionAlertView.xib
+0
-28
No files found.
BreastFeedingDemo.xcodeproj/project.pbxproj
View file @
d33dac7c
...
...
@@ -45,8 +45,6 @@
EA14360828E0CA3100FFBE72
/* LanguageCell.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
EA14360628E0CA3100FFBE72
/* LanguageCell.swift */
;
};
EA14360928E0CA3100FFBE72
/* LanguageCell.xib in Resources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
EA14360728E0CA3100FFBE72
/* LanguageCell.xib */
;
};
EAD8102728E207A4002A86C9
/* MyTools.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
EAD8102628E207A4002A86C9
/* MyTools.swift */
;
};
EAD8102928E207EF002A86C9
/* PermissionAlertView.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
EAD8102828E207EF002A86C9
/* PermissionAlertView.swift */
;
};
EAD8102B28E207FA002A86C9
/* PermissionAlertView.xib in Resources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
EAD8102A28E207FA002A86C9
/* PermissionAlertView.xib */
;
};
EAD8102D28E20A54002A86C9
/* PermissionAlertVC.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
EAD8102C28E20A54002A86C9
/* PermissionAlertVC.swift */
;
};
/* End PBXBuildFile section */
...
...
@@ -106,8 +104,6 @@
EA14360628E0CA3100FFBE72
/* LanguageCell.swift */
=
{
isa
=
PBXFileReference
;
lastKnownFileType
=
sourcecode.swift
;
path
=
LanguageCell.swift
;
sourceTree
=
"<group>"
;
};
EA14360728E0CA3100FFBE72
/* LanguageCell.xib */
=
{
isa
=
PBXFileReference
;
lastKnownFileType
=
file.xib
;
path
=
LanguageCell.xib
;
sourceTree
=
"<group>"
;
};
EAD8102628E207A4002A86C9
/* MyTools.swift */
=
{
isa
=
PBXFileReference
;
lastKnownFileType
=
sourcecode.swift
;
path
=
MyTools.swift
;
sourceTree
=
"<group>"
;
};
EAD8102828E207EF002A86C9
/* PermissionAlertView.swift */
=
{
isa
=
PBXFileReference
;
lastKnownFileType
=
sourcecode.swift
;
path
=
PermissionAlertView.swift
;
sourceTree
=
"<group>"
;
};
EAD8102A28E207FA002A86C9
/* PermissionAlertView.xib */
=
{
isa
=
PBXFileReference
;
lastKnownFileType
=
file.xib
;
path
=
PermissionAlertView.xib
;
sourceTree
=
"<group>"
;
};
EAD8102C28E20A54002A86C9
/* PermissionAlertVC.swift */
=
{
isa
=
PBXFileReference
;
lastKnownFileType
=
sourcecode.swift
;
path
=
PermissionAlertVC.swift
;
sourceTree
=
"<group>"
;
};
/* End PBXFileReference section */
...
...
@@ -171,8 +167,6 @@
694B85BB2848EB4C009BEDE1
/* AppDelegate.swift */
,
694B85BD2848EB4C009BEDE1
/* SceneDelegate.swift */
,
694B85BF2848EB4C009BEDE1
/* ViewController.swift */
,
EAD8102828E207EF002A86C9
/* PermissionAlertView.swift */
,
EAD8102A28E207FA002A86C9
/* PermissionAlertView.xib */
,
EA14360428E0BF1900FFBE72
/* DemoViewController.swift */
,
EAD8102C28E20A54002A86C9
/* PermissionAlertVC.swift */
,
EAD8102628E207A4002A86C9
/* MyTools.swift */
,
...
...
@@ -289,7 +283,6 @@
692EC421284C8D6F0043E3EA
/* french.json in Resources */
,
694B85C52848EB4E009BEDE1
/* Assets.xcassets in Resources */
,
EA14360928E0CA3100FFBE72
/* LanguageCell.xib in Resources */
,
EAD8102B28E207FA002A86C9
/* PermissionAlertView.xib in Resources */
,
694B85C32848EB4C009BEDE1
/* Main.storyboard in Resources */
,
692EC423284C8D6F0043E3EA
/* spanish.json in Resources */
,
692EC422284C8D6F0043E3EA
/* english.json in Resources */
,
...
...
@@ -345,7 +338,6 @@
isa
=
PBXSourcesBuildPhase
;
buildActionMask
=
2147483647
;
files
=
(
EAD8102928E207EF002A86C9
/* PermissionAlertView.swift in Sources */
,
694B85C02848EB4C009BEDE1
/* ViewController.swift in Sources */
,
694B85BC2848EB4C009BEDE1
/* AppDelegate.swift in Sources */
,
697B07ED284F2E5C0051FC23
/* CompleteVC.swift in Sources */
,
...
...
BreastFeedingDemo/Base.lproj/Main.storyboard
View file @
d33dac7c
...
...
@@ -580,6 +580,9 @@
<constraint
firstItem=
"aC7-1b-hqa"
firstAttribute=
"leading"
secondItem=
"flX-LQ-FEL"
secondAttribute=
"leading"
id=
"pnm-Hz-GPp"
/>
<constraint
firstItem=
"KCh-Z8-bas"
firstAttribute=
"top"
secondItem=
"flX-LQ-FEL"
secondAttribute=
"top"
id=
"rid-UA-09I"
/>
</constraints>
<connections>
<action
selector=
"cradleHold:"
destination=
"XVX-uo-beN"
eventType=
"touchUpInside"
id=
"jfz-WQ-34i"
/>
</connections>
</view>
<view
contentMode=
"scaleToFill"
translatesAutoresizingMaskIntoConstraints=
"NO"
id=
"NG1-gm-Ffn"
customClass=
"UIControl"
>
<rect
key=
"frame"
x=
"0.0"
y=
"210.5"
width=
"382"
height=
"194.5"
/>
...
...
BreastFeedingDemo/DemoViewController.swift
View file @
d33dac7c
...
...
@@ -20,12 +20,16 @@ class DemoViewController: UIViewController {
@IBOutlet
var
stepL2
:
UILabel
!
@IBOutlet
var
stepL3
:
UILabel
!
var
methodChannel
:
FlutterMethodChannel
?
var
isFirstLoad
:
Bool
=
true
override
func
viewDidLoad
()
{
super
.
viewDidLoad
()
overrideUserInterfaceStyle
=
.
light
UIApplication
.
shared
.
isIdleTimerDisabled
=
true
navigationController
?
.
setNavigationBarHidden
(
true
,
animated
:
false
)
updateUI
()
flutterInitialize
()
}
fileprivate
func
updateUI
()
{
...
...
@@ -67,6 +71,63 @@ class DemoViewController: UIViewController {
return
false
}
}
fileprivate
func
flutterInitialize
()
{
if
let
flutterEngine
=
(
UIApplication
.
shared
.
delegate
as?
AppDelegate
)?
.
flutterEngine
{
methodChannel
=
FlutterMethodChannel
(
name
:
"com.wmdigit.breastcoachai.native"
,
binaryMessenger
:
flutterEngine
.
binaryMessenger
)
methodChannel
?
.
setMethodCallHandler
{
[
weak
self
]
(
call
:
FlutterMethodCall
,
result
:
@escaping
FlutterResult
)
in
if
let
strongSelf
=
self
{
switch
call
.
method
{
case
"init"
:
result
(
strongSelf
.
vm
.
flutterArguments
)
case
"teachingEnd"
:
strongSelf
.
methodChannel
?
.
invokeMethod
(
"dispose"
,
arguments
:
nil
)
// ["totalDuration": 3, "reasonText": Concern about my personal privacy, "status": incomplete, "incompleteReasonCode": 2]
let
argument
:
[
String
:
Any
]
=
try!
JSONSerialization
.
jsonObject
(
with
:
(
call
.
arguments
as!
String
)
.
data
(
using
:
.
utf8
)
!
)
as!
[
String
:
Any
]
// let totalDuration: Int = argument["totalDuration"] as! Int
// let reasonText: String = argument["reasonText"] as! String
// let incompleteReasonCode: Int = argument["incompleteReasonCode"] as! Int
let
status
:
String
=
argument
[
"status"
]
as!
String
if
status
==
"incomplete"
{
// strongSelf.showError(reasonText)
}
else
if
status
==
"complete"
{
strongSelf
.
toCompleteVC
()
return
}
strongSelf
.
navigationController
?
.
popViewController
(
animated
:
true
)
default
:
// Unrecognized method name
print
(
"Unrecognized method name:
\(
call
.
method
)
"
)
}
}
}
}
}
func
toCompleteVC
()
{
let
sb
=
UIStoryboard
(
name
:
"Main"
,
bundle
:
nil
)
let
vc
=
sb
.
instantiateViewController
(
withIdentifier
:
"CompleteVC"
)
as!
CompleteVC
vc
.
vm
=
vm
navigationController
?
.
pushViewController
(
vc
,
animated
:
true
)
}
@IBAction
func
cradleHold
(
_
:
Any
)
{
if
checkCameraPermission
()
==
false
{
return
}
if
!
isFirstLoad
{
methodChannel
?
.
invokeMethod
(
"reload"
,
arguments
:
nil
)
}
isFirstLoad
=
false
if
let
flutterEngine
=
(
UIApplication
.
shared
.
delegate
as?
AppDelegate
)?
.
flutterEngine
{
let
scanVC
=
FlutterViewController
(
engine
:
flutterEngine
,
nibName
:
nil
,
bundle
:
nil
)
scanVC
.
modalPresentationStyle
=
.
overFullScreen
navigationController
?
.
pushViewController
(
scanVC
,
animated
:
true
)
}
}
}
extension
DemoViewController
{
...
...
BreastFeedingDemo/PermissionAlertVC.swift
View file @
d33dac7c
...
...
@@ -29,6 +29,9 @@ class PermissionAlertVC: UIViewController {
@IBAction
func
dismissAction
(
_
:
Any
)
{
dismiss
(
animated
:
true
)
if
let
appSettingsURL
=
URL
(
string
:
UIApplication
.
openSettingsURLString
)
{
UIApplication
.
shared
.
open
(
appSettingsURL
)
}
}
/*
...
...
BreastFeedingDemo/PermissionAlertView.swift
deleted
100644 → 0
View file @
9bfb76fe
//
// PermissionAlertView.swift
// BreastFeedingDemo
//
// Created by jzhang on 2022/9/27.
//
import
UIKit
class
PermissionAlertView
:
UIView
,
XibLoadable
{}
BreastFeedingDemo/PermissionAlertView.xib
deleted
100644 → 0
View file @
9bfb76fe
<?xml version="1.0" encoding="UTF-8"?>
<document
type=
"com.apple.InterfaceBuilder3.CocoaTouch.XIB"
version=
"3.0"
toolsVersion=
"20037"
targetRuntime=
"iOS.CocoaTouch"
propertyAccessControl=
"none"
useAutolayout=
"YES"
useTraitCollections=
"YES"
useSafeAreas=
"YES"
colorMatched=
"YES"
>
<device
id=
"retina6_1"
orientation=
"portrait"
appearance=
"light"
/>
<dependencies>
<deployment
identifier=
"iOS"
/>
<plugIn
identifier=
"com.apple.InterfaceBuilder.IBCocoaTouchPlugin"
version=
"20020"
/>
<capability
name=
"Safe area layout guides"
minToolsVersion=
"9.0"
/>
<capability
name=
"System colors in document resources"
minToolsVersion=
"11.0"
/>
<capability
name=
"documents saved in the Xcode 8 format"
minToolsVersion=
"8.0"
/>
</dependencies>
<objects>
<placeholder
placeholderIdentifier=
"IBFilesOwner"
id=
"-1"
userLabel=
"File's Owner"
/>
<placeholder
placeholderIdentifier=
"IBFirstResponder"
id=
"-2"
customClass=
"UIResponder"
/>
<view
contentMode=
"scaleToFill"
id=
"iN0-l3-epB"
customClass=
"PermissionAlertView"
customModule=
"BreastFeedingDemo"
customModuleProvider=
"target"
>
<rect
key=
"frame"
x=
"0.0"
y=
"0.0"
width=
"414"
height=
"250"
/>
<autoresizingMask
key=
"autoresizingMask"
widthSizable=
"YES"
heightSizable=
"YES"
/>
<viewLayoutGuide
key=
"safeArea"
id=
"vUN-kp-3ea"
/>
<color
key=
"backgroundColor"
systemColor=
"systemBackgroundColor"
/>
<freeformSimulatedSizeMetrics
key=
"simulatedDestinationMetrics"
/>
<point
key=
"canvasLocation"
x=
"131.8840579710145"
y=
"308.03571428571428"
/>
</view>
</objects>
<resources>
<systemColor
name=
"systemBackgroundColor"
>
<color
white=
"1"
alpha=
"1"
colorSpace=
"custom"
customColorSpace=
"genericGamma22GrayColorSpace"
/>
</systemColor>
</resources>
</document>
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