Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
D
dispatcher_test
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Packages
Packages
Container Registry
Analytics
CI / CD Analytics
Repository Analytics
Value Stream Analytics
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Gavin An
dispatcher_test
Commits
3ffbc5c4
Commit
3ffbc5c4
authored
Nov 07, 2024
by
Gavin An
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
test
parent
2e705874
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
209 additions
and
107 deletions
+209
-107
lib/fire_store_test_page.dart
lib/fire_store_test_page.dart
+72
-0
lib/main.dart
lib/main.dart
+128
-99
lib/speech_to_text_page.dart
lib/speech_to_text_page.dart
+3
-2
pubspec.lock
pubspec.lock
+4
-4
pubspec.yaml
pubspec.yaml
+2
-2
No files found.
lib/fire_store_test_page.dart
0 → 100644
View file @
3ffbc5c4
import
'package:cloud_firestore/cloud_firestore.dart'
;
import
'package:flutter/material.dart'
;
class
FireStoreTestPage
extends
StatefulWidget
{
const
FireStoreTestPage
({
super
.
key
});
@override
State
<
FireStoreTestPage
>
createState
()
=>
_FireStoreTestPageState
();
}
class
_FireStoreTestPageState
extends
State
<
FireStoreTestPage
>
{
final
FirebaseFirestore
store
=
FirebaseFirestore
.
instance
;
late
Stream
<
QuerySnapshot
<
Map
<
String
,
dynamic
>>>
querySnapShot
;
@override
void
initState
()
{
super
.
initState
();
querySnapShot
=
store
.
collection
(
'baecha'
)
// .where('baljuGroupId', whereIn: ['baecha_group_001', 'baecha_group_002'])
.
snapshots
();
}
@override
Widget
build
(
BuildContext
context
)
{
return
StreamBuilder
(
stream:
querySnapShot
,
builder:
(
context
,
snapshot
)
{
if
(!
snapshot
.
hasData
)
{
return
const
CircularProgressIndicator
();
}
List
<
QueryDocumentSnapshot
<
Map
<
String
,
dynamic
>>>
documents
=
snapshot
.
data
!.
docs
;
return
Expanded
(
child:
ListView
.
builder
(
shrinkWrap:
true
,
reverse:
true
,
itemCount:
documents
.
length
,
itemBuilder:
(
context
,
index
)
{
final
item
=
documents
[
index
];
String
id
=
item
.
id
;
String
groupId
=
item
[
'baljuGroupId'
];
String
createDate
=
item
[
'createDate'
];
int
callCnt
=
item
[
'callCnt'
];
int
passCnt
=
item
[
'passCnt'
];
return
Container
(
margin:
const
EdgeInsets
.
all
(
10
),
padding:
const
EdgeInsets
.
symmetric
(
horizontal:
8
,
vertical:
8
),
decoration:
BoxDecoration
(
color:
Colors
.
amber
,
border:
Border
.
all
(
color:
Colors
.
black
,
width:
1
),
borderRadius:
const
BorderRadius
.
all
(
Radius
.
circular
(
20
)),
),
child:
Column
(
mainAxisSize:
MainAxisSize
.
min
,
mainAxisAlignment:
MainAxisAlignment
.
start
,
crossAxisAlignment:
CrossAxisAlignment
.
start
,
children:
[
Text
(
'id:
$id
'
),
Text
(
'groupId:
$groupId
'
),
Text
(
'createDate:
$createDate
'
),
Text
(
'callCnt:
${callCnt.toString()}
'
),
Text
(
'passCnt:
${passCnt.toString()}
'
),
],
),
);
},
),
);
},
);
}
}
lib/main.dart
View file @
3ffbc5c4
import
'dart:math'
;
import
'package:cloud_firestore/cloud_firestore.dart'
;
import
'package:dispatcher_test/fire_store_test_page.dart'
;
import
'package:dispatcher_test/firebase_options.dart'
;
import
'package:dispatcher_test/module/dependency_inject.dart'
;
import
'package:dispatcher_test/notification_page.dart'
;
...
...
@@ -15,6 +16,7 @@ import 'package:flutter/services.dart';
import
'package:flutter_local_notifications/flutter_local_notifications.dart'
;
import
'package:kakao_flutter_sdk_user/kakao_flutter_sdk_user.dart'
;
import
'package:permission_handler/permission_handler.dart'
;
import
'package:uuid/uuid.dart'
;
const
List
<
String
>
sample
=
[
'배고프다'
,
...
...
@@ -77,8 +79,7 @@ Future<void> setupFlutterNotifications() async {
channel
=
const
AndroidNotificationChannel
(
'high_importance_channel'
,
// id
'High Importance Notifications'
,
// title
description:
'This channel is used for important notifications.'
,
// description
description:
'This channel is used for important notifications.'
,
// description
importance:
Importance
.
high
,
);
...
...
@@ -89,8 +90,7 @@ Future<void> setupFlutterNotifications() async {
/// We use this channel in the `AndroidManifest.xml` file to override the
/// default FCM channel to enable heads up notifications.
await
flutterLocalNotificationsPlugin
.
resolvePlatformSpecificImplementation
<
AndroidFlutterLocalNotificationsPlugin
>()
.
resolvePlatformSpecificImplementation
<
AndroidFlutterLocalNotificationsPlugin
>()
?.
createNotificationChannel
(
channel
);
/// Update the iOS foreground notification presentation options to allow
...
...
@@ -108,12 +108,11 @@ void main() async {
dependenciesInitialized
();
await
Firebase
.
initializeApp
(
options:
DefaultFirebaseOptions
.
currentPlatform
);
FirebaseMessaging
.
onBackgroundMessage
(
_firebaseMessagingBackgroundHandler
);
// FirebaseMessaging.onBackgroundMessage(_firebaseMessagingBackgroundHandler);
FirebaseFirestore
.
instance
.
settings
=
const
Settings
(
persistenceEnabled:
true
,
);
// TODO 카카오 Login
// TODO 카카오 Login
init
// KakaoSdk.init(
// nativeAppKey: ''
// );
...
...
@@ -178,111 +177,141 @@ class _MyHomePageState extends State<MyHomePage> {
),
body:
Column
(
children:
[
TextButton
(
style:
const
ButtonStyle
(
backgroundColor:
WidgetStatePropertyAll
(
Colors
.
amber
),
minimumSize:
WidgetStatePropertyAll
(
Size
.
fromHeight
(
30
))),
onPressed:
()
{
Navigator
.
push
(
context
,
MaterialPageRoute
(
builder:
(
context
)
=>
const
SpeechToTextPage
(),
));
},
child:
const
Text
(
'음성입력'
,
style:
TextStyle
(
color:
Colors
.
black
),
),
),
// TextButton(
// style: const ButtonStyle(
// backgroundColor: WidgetStatePropertyAll(Colors.amber),
// minimumSize: WidgetStatePropertyAll(Size.fromHeight(30))),
// onPressed: () {
// Navigator.push(
// context,
// MaterialPageRoute(
// builder: (context) => const SpeechToTextPage(),
// ));
// },
// child: const Text(
// '음성입력',
// style: TextStyle(color: Colors.black),
// ),
// ),
// const SizedBox(
// height: 10,
// ),
// TextButton(
// style: const ButtonStyle(
// backgroundColor: WidgetStatePropertyAll(Colors.amber),
// minimumSize: WidgetStatePropertyAll(Size.fromHeight(30))),
// onPressed: () {
// Navigator.push(
// context,
// MaterialPageRoute(
// builder: (context) => const TextToSpeechPage(),
// ));
// },
// child: const Text(
// '음성변환',
// style: TextStyle(color: Colors.black),
// ),
// ),
// const SizedBox(
// height: 10,
// ),
// TextButton(
// style: const ButtonStyle(
// backgroundColor: WidgetStatePropertyAll(Colors.amber),
// minimumSize: WidgetStatePropertyAll(Size.fromHeight(30))),
// onPressed: () {
// Navigator.push(
// context,
// MaterialPageRoute(
// builder: (context) => const GenerateNotificationPage(),
// ));
// },
// child: const Text(
// '알림입력',
// style: TextStyle(color: Colors.black),
// ),
// ),
// TextButton(
// style: const ButtonStyle(
// backgroundColor: WidgetStatePropertyAll(Colors.amber),
// minimumSize: WidgetStatePropertyAll(Size.fromHeight(30))),
// onPressed: () async {
// // bool talkInstalled = await isKakaoTalkInstalled();
// // if (talkInstalled) {
// try {
// OAuthToken token =
// await UserApi.instance.loginWithKakaoAccount();
// // TODO 서버에 토큰 올린 후, response 에 따라 회원가입 절차
// return;
// } catch (e) {
// print('카카오톡으로 로그인 실패 $e');
// // 사용자가 카카오톡 설치 후 디바이스 권한 요청 화면에서 로그인을 취소한 경우,
// // 의도적인 로그인 취소로 보고 카카오계정으로 로그인 시도 없이 로그인 취소로 처리 (예: 뒤로 가기)
// if (e is PlatformException && e.code == 'CANCELED') {
// return;
// }
// }
// // }
// // 카카오톡 계정이 없거나, 카카오톡 설치가 되지 않았다면 웹으로 로그인
// OAuthToken token = await UserApi.instance.loginWithKakaoAccount();
// // TODO 서버에 토큰 올린 후, response 에 따라 회원가입 절차
// },
// child: Text('카카오로그인', style: const TextStyle(color: Colors.black)),
// ),
const
SizedBox
(
height:
10
,
),
TextButton
(
style:
const
ButtonStyle
(
backgroundColor:
WidgetStatePropertyAll
(
Colors
.
amber
),
minimumSize:
WidgetStatePropertyAll
(
Size
.
fromHeight
(
30
))),
onPressed:
()
{
Navigator
.
push
(
context
,
MaterialPageRoute
(
builder:
(
context
)
=>
const
TextToSpeechPage
(),
));
},
child:
const
Text
(
'음성변환'
,
style:
TextStyle
(
color:
Colors
.
black
),
),
),
const
FireStoreTestPage
(),
const
SizedBox
(
height:
1
0
,
height:
8
0
,
),
TextButton
(
style:
const
ButtonStyle
(
backgroundColor:
WidgetStatePropertyAll
(
Colors
.
amber
),
minimumSize:
WidgetStatePropertyAll
(
Size
.
fromHeight
(
30
))),
],
),
floatingActionButton:
Row
(
crossAxisAlignment:
CrossAxisAlignment
.
end
,
mainAxisAlignment:
MainAxisAlignment
.
end
,
children:
[
// IconButton(onPressed: () {}, icon: Icon(Icons.add)),
// IconButton(onPressed: () {}, icon: Icon(Icons.mic)),
FloatingActionButton
(
tooltip:
'Increment'
,
child:
const
Icon
(
Icons
.
add
),
onPressed:
()
{
Navigator
.
push
(
context
,
MaterialPageRoute
(
builder:
(
context
)
=>
const
GenerateNotificationPage
(),
));
},
child:
const
Text
(
'알림입력'
,
style:
TextStyle
(
color:
Colors
.
black
),
),
),
TextButton
(
style:
const
ButtonStyle
(
backgroundColor:
WidgetStatePropertyAll
(
Colors
.
amber
),
minimumSize:
WidgetStatePropertyAll
(
Size
.
fromHeight
(
30
))),
onPressed:
()
async
{
// bool talkInstalled = await isKakaoTalkInstalled();
// if (talkInstalled) {
try
{
OAuthToken
token
=
await
UserApi
.
instance
.
loginWithKakaoAccount
();
// TODO 서버에 토큰 올린 후, response 에 따라 회원가입 절차
return
;
}
catch
(
e
)
{
print
(
'카카오톡으로 로그인 실패
$e
'
);
// 사용자가 카카오톡 설치 후 디바이스 권한 요청 화면에서 로그인을 취소한 경우,
// 의도적인 로그인 취소로 보고 카카오계정으로 로그인 시도 없이 로그인 취소로 처리 (예: 뒤로 가기)
if
(
e
is
PlatformException
&&
e
.
code
==
'CANCELED'
)
{
return
;
}
}
// }
// 카카오톡 계정이 없거나, 카카오톡 설치가 되지 않았다면 웹으로 로그인
OAuthToken
token
=
await
UserApi
.
instance
.
loginWithKakaoAccount
();
// TODO 서버에 토큰 올린 후, response 에 따라 회원가입 절차
Random
rd
=
Random
();
int
rdNum
=
rd
.
nextInt
(
10
);
int
callNum
=
rd
.
nextInt
(
20
);
int
passNum
=
rd
.
nextInt
(
15
);
int
minRan
=
rd
.
nextInt
(
30
);
DateTime
dt
=
DateTime
.
now
().
add
(
Duration
(
minutes:
minRan
));
// String rdStr = sample[rdNum];
var
uuid
=
const
Uuid
();
String
baljuGroupId
=
'baecha_group_00
$rdNum
'
;
store
.
collection
(
'baecha'
).
doc
(
uuid
.
v4
()).
set
({
'baljuGroupId'
:
baljuGroupId
,
'callCnt'
:
callNum
,
'passCnt'
:
passNum
,
'createDate'
:
dt
.
toIso8601String
(),
});
},
child:
Text
(
'카카오로그인'
,
style:
const
TextStyle
(
color:
Colors
.
black
)),
),
const
SizedBox
(
height:
1
0
,
width:
3
0
,
),
Center
(
// Center is a layout widget. It takes a single child and positions it
// in the middle of the parent.
child:
StreamBuilder
(
stream:
store
.
collection
(
'test'
).
doc
(
'chat'
).
snapshots
(),
builder:
(
context
,
snapshot
)
{
String
field
=
snapshot
.
data
?.
get
(
'msg'
)
??
''
;
return
Center
(
child:
Text
(
field
));
FloatingActionButton
(
tooltip:
'Modify'
,
child:
const
Icon
(
Icons
.
published_with_changes
),
onPressed:
()
async
{
// store.collection('baecha').doc().
Random
rd
=
Random
();
int
rdNum
=
rd
.
nextInt
(
20
);
int
rdNum2
=
rd
.
nextInt
(
30
);
// String rdStr = sample[rdNum];
QuerySnapshot
<
Map
<
String
,
dynamic
>>
firstDoc
=
await
store
.
collection
(
'baecha'
).
get
();
String
firstId
=
firstDoc
.
docs
[
firstDoc
.
docs
.
length
-
1
].
id
??
''
;
store
.
collection
(
'baecha'
).
doc
(
firstId
).
update
({
'callCnt'
:
rdNum
,
'passCnt'
:
rdNum2
});
},
)
)
)
,
],
),
floatingActionButton:
FloatingActionButton
(
onPressed:
()
{
Random
rd
=
Random
();
int
rdNum
=
rd
.
nextInt
(
6
);
String
rdStr
=
sample
[
rdNum
];
store
.
collection
(
'test'
).
doc
(
'chat'
).
set
({
"msg"
:
rdStr
});
},
tooltip:
'Increment'
,
child:
const
Icon
(
Icons
.
add
),
),
// This trailing comma makes auto-formatting nicer for build methods.
);
}
...
...
lib/speech_to_text_page.dart
View file @
3ffbc5c4
...
...
@@ -28,7 +28,7 @@ class _SpeechToTextPageState extends State<SpeechToTextPage> {
/// Each time to start a speech recognition session
void
_startListening
()
async
{
await
_speechToText
.
listen
(
onResult:
_onSpeechResult
);
await
_speechToText
.
listen
(
onResult:
_onSpeechResult
Listener
);
setState
(()
{});
}
...
...
@@ -43,7 +43,8 @@ class _SpeechToTextPageState extends State<SpeechToTextPage> {
/// This is the callback that the SpeechToText plugin calls when
/// the platform returns recognized words.
void
_onSpeechResult
(
SpeechRecognitionResult
result
)
{
void
_onSpeechResultListener
(
SpeechRecognitionResult
result
)
{
print
(
'isFinal:
${result.finalResult}
'
);
_lastWords
=
result
.
recognizedWords
;
setState
(()
{});
}
...
...
pubspec.lock
View file @
3ffbc5c4
...
...
@@ -761,10 +761,10 @@ packages:
dependency: "direct main"
description:
name: uuid
sha256:
"83d37c7ad7aaf9aa8e275490669535c8080377cfa7a7004c24dfac53afffaa90"
sha256:
a5be9ef6618a7ac1e964353ef476418026db906c4facdedaa299b7a2e71690ff
url: "https://pub.dev"
source: hosted
version: "4.
4.2
"
version: "4.
5.1
"
vector_math:
dependency: transitive
description:
...
...
@@ -777,10 +777,10 @@ packages:
dependency: transitive
description:
name: vm_service
sha256:
f652077d0bdf60abe4c1f6377448e8655008eef28f128bc023f7b5e8dfeb48fc
sha256:
"5c5f338a667b4c644744b661f309fb8080bb94b18a7e91ef1dbd343bed00ed6d"
url: "https://pub.dev"
source: hosted
version: "14.2.
4
"
version: "14.2.
5
"
web:
dependency: transitive
description:
...
...
pubspec.yaml
View file @
3ffbc5c4
...
...
@@ -44,6 +44,8 @@ dependencies:
firebase_messaging
:
^15.0.4
kakao_flutter_sdk_user
:
^1.9.5
# 카카오 로그인 API 패키지
uuid
:
^4.5.1
# inversion of control(service locator)
get_it
:
^7.7.0
...
...
@@ -52,8 +54,6 @@ dependencies:
pretty_dio_logger
:
^1.4.0
fluttertoast
:
^8.2.8
uuid
:
^4.4.2
# secure storage
flutter_secure_storage
:
^9.2.2
...
...
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