Showing
4 changed files
with
115 additions
and
10 deletions
... | @@ -39,7 +39,7 @@ android { | ... | @@ -39,7 +39,7 @@ android { |
39 | defaultConfig { | 39 | defaultConfig { |
40 | // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html). | 40 | // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html). |
41 | applicationId "com.example.Smart_Medicine_Box" | 41 | applicationId "com.example.Smart_Medicine_Box" |
42 | - minSdkVersion 16 | 42 | + minSdkVersion 19 |
43 | targetSdkVersion 29 | 43 | targetSdkVersion 29 |
44 | versionCode flutterVersionCode.toInteger() | 44 | versionCode flutterVersionCode.toInteger() |
45 | versionName flutterVersionName | 45 | versionName flutterVersionName | ... | ... |
... | @@ -238,7 +238,7 @@ Widget ineerInformationpage(BuildContext context) { | ... | @@ -238,7 +238,7 @@ Widget ineerInformationpage(BuildContext context) { |
238 | children: <Widget>[ | 238 | children: <Widget>[ |
239 | Container( | 239 | Container( |
240 | width: size.width * 0.43, | 240 | width: size.width * 0.43, |
241 | - height: size.width * 0.43, | 241 | + height: size.width * 0.45, |
242 | margin: const EdgeInsets.all(5.0), | 242 | margin: const EdgeInsets.all(5.0), |
243 | padding: const EdgeInsets.fromLTRB(10, 5, 10, 10), | 243 | padding: const EdgeInsets.fromLTRB(10, 5, 10, 10), |
244 | decoration: BoxDecoration( | 244 | decoration: BoxDecoration( |
... | @@ -265,7 +265,7 @@ Widget ineerInformationpage(BuildContext context) { | ... | @@ -265,7 +265,7 @@ Widget ineerInformationpage(BuildContext context) { |
265 | ), | 265 | ), |
266 | Container( | 266 | Container( |
267 | width: size.width, | 267 | width: size.width, |
268 | - height: size.height * 0.14, | 268 | + height: size.height * 0.145, |
269 | child: Center( | 269 | child: Center( |
270 | child: Row( | 270 | child: Row( |
271 | mainAxisAlignment: MainAxisAlignment.center, | 271 | mainAxisAlignment: MainAxisAlignment.center, |
... | @@ -276,7 +276,7 @@ Widget ineerInformationpage(BuildContext context) { | ... | @@ -276,7 +276,7 @@ Widget ineerInformationpage(BuildContext context) { |
276 | textScaleFactor: 1.0, | 276 | textScaleFactor: 1.0, |
277 | style: TextStyle( | 277 | style: TextStyle( |
278 | color: Colors.white, | 278 | color: Colors.white, |
279 | - fontSize: 80, | 279 | + fontSize: 76, |
280 | fontFamily: 'NotoSansKR', | 280 | fontFamily: 'NotoSansKR', |
281 | fontWeight: FontWeight.w800), | 281 | fontWeight: FontWeight.w800), |
282 | ), | 282 | ), |
... | @@ -299,7 +299,7 @@ Widget ineerInformationpage(BuildContext context) { | ... | @@ -299,7 +299,7 @@ Widget ineerInformationpage(BuildContext context) { |
299 | ), | 299 | ), |
300 | Container( | 300 | Container( |
301 | width: size.width * 0.43, | 301 | width: size.width * 0.43, |
302 | - height: size.width * 0.43, | 302 | + height: size.width * 0.45, |
303 | margin: const EdgeInsets.all(5.0), | 303 | margin: const EdgeInsets.all(5.0), |
304 | padding: const EdgeInsets.fromLTRB(10, 5, 10, 10), | 304 | padding: const EdgeInsets.fromLTRB(10, 5, 10, 10), |
305 | decoration: BoxDecoration( | 305 | decoration: BoxDecoration( |
... | @@ -377,7 +377,7 @@ Widget ineerInformationpage(BuildContext context) { | ... | @@ -377,7 +377,7 @@ Widget ineerInformationpage(BuildContext context) { |
377 | children: <Widget>[ | 377 | children: <Widget>[ |
378 | Container( | 378 | Container( |
379 | width: size.width * 0.43, | 379 | width: size.width * 0.43, |
380 | - height: size.width * 0.43, | 380 | + height: size.width * 0.45, |
381 | margin: const EdgeInsets.all(5.0), | 381 | margin: const EdgeInsets.all(5.0), |
382 | padding: const EdgeInsets.fromLTRB(10, 5, 10, 10), | 382 | padding: const EdgeInsets.fromLTRB(10, 5, 10, 10), |
383 | decoration: BoxDecoration( | 383 | decoration: BoxDecoration( |
... | @@ -438,7 +438,7 @@ Widget ineerInformationpage(BuildContext context) { | ... | @@ -438,7 +438,7 @@ Widget ineerInformationpage(BuildContext context) { |
438 | ), | 438 | ), |
439 | Container( | 439 | Container( |
440 | width: size.width * 0.43, | 440 | width: size.width * 0.43, |
441 | - height: size.width * 0.43, | 441 | + height: size.width * 0.45, |
442 | margin: const EdgeInsets.all(5.0), | 442 | margin: const EdgeInsets.all(5.0), |
443 | padding: const EdgeInsets.fromLTRB(10, 5, 10, 10), | 443 | padding: const EdgeInsets.fromLTRB(10, 5, 10, 10), |
444 | decoration: BoxDecoration( | 444 | decoration: BoxDecoration( | ... | ... |
... | @@ -161,7 +161,7 @@ class _SettingPageState extends State<SettingPage> { | ... | @@ -161,7 +161,7 @@ class _SettingPageState extends State<SettingPage> { |
161 | )); | 161 | )); |
162 | }, | 162 | }, |
163 | child: Text( | 163 | child: Text( |
164 | - '약 정보 수정', | 164 | + '회원 정보 수정', |
165 | textScaleFactor: 1.0, | 165 | textScaleFactor: 1.0, |
166 | style: TextStyle( | 166 | style: TextStyle( |
167 | color: Colors.white, | 167 | color: Colors.white, | ... | ... |
... | @@ -10,7 +10,42 @@ class Bluetooth extends StatefulWidget { | ... | @@ -10,7 +10,42 @@ class Bluetooth extends StatefulWidget { |
10 | FlutterBlue flutterBlue; | 10 | FlutterBlue flutterBlue; |
11 | 11 | ||
12 | class _BluetoothState extends State<Bluetooth> { | 12 | class _BluetoothState extends State<Bluetooth> { |
13 | + @override | ||
14 | + void initState() { | ||
15 | + super.initState(); | ||
16 | + flutterBlue = FlutterBlue.instance; | ||
17 | + } | ||
18 | + | ||
19 | + void _startscan() { | ||
20 | + flutterBlue.startScan(timeout: Duration(seconds: 12)); | ||
21 | + var subscription = flutterBlue.scanResults.listen((results) { | ||
22 | + // do something with scan results | ||
23 | + for (ScanResult r in results) { | ||
24 | + print( | ||
25 | + 'Device Name : ${r.device.name} // Device ID : ${r.device.id} // Device rssi: ${r.rssi}'); | ||
26 | + } | ||
27 | + }); | ||
28 | + } | ||
29 | + | ||
13 | Widget build(BuildContext context) { | 30 | Widget build(BuildContext context) { |
31 | + Widget _buildItem(ScanResult s) { | ||
32 | + return ListTile( | ||
33 | + leading: Text(s.rssi.toString()), | ||
34 | + title: Text(s.device.name), | ||
35 | + subtitle: Text(s.device.id.id), | ||
36 | + onTap: () => | ||
37 | + Navigator.of(context).push(MaterialPageRoute(builder: (context) { | ||
38 | + return Device(device: s.device); | ||
39 | + })), | ||
40 | + ); | ||
41 | + } | ||
42 | + | ||
43 | + Widget _buildList(List<ScanResult> scanResults) { | ||
44 | + return Column( | ||
45 | + children: scanResults.map((v) => _buildItem(v)).toList(), | ||
46 | + ); | ||
47 | + } | ||
48 | + | ||
14 | return MaterialApp( | 49 | return MaterialApp( |
15 | title: 'Welcome to Flutter', | 50 | title: 'Welcome to Flutter', |
16 | home: Scaffold( | 51 | home: Scaffold( |
... | @@ -65,10 +100,80 @@ class _BluetoothState extends State<Bluetooth> { | ... | @@ -65,10 +100,80 @@ class _BluetoothState extends State<Bluetooth> { |
65 | ], | 100 | ], |
66 | ), | 101 | ), |
67 | ), | 102 | ), |
68 | - body: Center( | 103 | + body: SingleChildScrollView( |
69 | - child: Text('약병 내부 페이지 작업 영역'), | 104 | + child: StreamBuilder<List<ScanResult>>( |
105 | + stream: FlutterBlue.instance.scanResults, | ||
106 | + initialData: [], | ||
107 | + builder: (c, snapshot) { | ||
108 | + return _buildList(snapshot.data); | ||
109 | + }), | ||
70 | ), | 110 | ), |
111 | + floatingActionButton: StreamBuilder<bool>( | ||
112 | + stream: FlutterBlue.instance.isScanning, | ||
113 | + initialData: false, | ||
114 | + builder: (c, snapshot) { | ||
115 | + if (snapshot.data) { | ||
116 | + return FloatingActionButton( | ||
117 | + child: Icon(Icons.stop), | ||
118 | + onPressed: () => FlutterBlue.instance.stopScan(), | ||
119 | + backgroundColor: Colors.red, | ||
120 | + ); | ||
121 | + } else { | ||
122 | + return FloatingActionButton( | ||
123 | + child: Icon(Icons.search), | ||
124 | + onPressed: () => FlutterBlue.instance | ||
125 | + .startScan(timeout: Duration(seconds: 4))); | ||
126 | + } | ||
127 | + }, | ||
128 | + ), | ||
129 | + ), | ||
130 | + ); | ||
131 | + } | ||
132 | +} | ||
133 | + | ||
134 | +class Device extends StatefulWidget { | ||
135 | + Device({Key key, this.device}) : super(key: key); | ||
136 | + final BluetoothDevice device; | ||
137 | + @override | ||
138 | + _DeviceState createState() => _DeviceState(); | ||
139 | +} | ||
140 | + | ||
141 | +class _DeviceState extends State<Device> { | ||
142 | + void initState() { | ||
143 | + super.initState(); | ||
144 | + widget.device.connect(); | ||
145 | + } | ||
146 | + | ||
147 | + @override | ||
148 | + void dispose() { | ||
149 | + widget.device.disconnect(); | ||
150 | + super.dispose(); | ||
151 | + } | ||
152 | + | ||
153 | + Widget _buildIconButton() { | ||
154 | + return StreamBuilder<BluetoothDeviceState>( | ||
155 | + stream: widget.device.state, | ||
156 | + initialData: BluetoothDeviceState.connecting, | ||
157 | + builder: (c, snapshot) { | ||
158 | + if (snapshot.data != BluetoothDeviceState.connected) | ||
159 | + return Icon(Icons.warning); | ||
160 | + return IconButton( | ||
161 | + icon: Icon(Icons.bluetooth_searching), | ||
162 | + onPressed: () => widget.device.discoverServices(), | ||
163 | + ); | ||
164 | + }); | ||
165 | + } | ||
166 | + | ||
167 | + @override | ||
168 | + Widget build(BuildContext context) { | ||
169 | + return Scaffold( | ||
170 | + appBar: AppBar( | ||
171 | + title: Text(widget.device.name), | ||
172 | + actions: <Widget>[ | ||
173 | + _buildIconButton(), | ||
174 | + ], | ||
71 | ), | 175 | ), |
176 | + body: Text('hello'), | ||
72 | ); | 177 | ); |
73 | } | 178 | } |
74 | } | 179 | } | ... | ... |
-
Please register or login to post a comment