고원빈

[frontend] 2021-06-02

......@@ -97,3 +97,6 @@ appbar 관련 디자인은 추후 구현 예정
### 2021-05-30
+ Sqlite 생성
### 2021-06-01
+ datetime 형식 한국 시간으로 변경
\ No newline at end of file
......
SERVER_URL=http://192.168.154.240:4444/api/
\ No newline at end of file
SERVER_URL=http://192.168.0.3:4717/api/
\ No newline at end of file
......
......@@ -5,6 +5,7 @@ import 'package:flutter_dotenv/flutter_dotenv.dart';
Future main() async {
await DotEnv().load('.env');
runApp(MyApp());
}
......
......@@ -10,6 +10,7 @@ import 'models/Medicine.dart';
import 'package:Smart_Medicine_Box/src/screens/SettingPage.dart';
import 'Register/BottleList.dart';
import 'Register/SearchMedicine.dart';
import 'package:intl/date_symbol_data_local.dart';
class DashBoard extends StatefulWidget {
int pageNumber;
......@@ -34,7 +35,6 @@ class _DashBoardState extends State<DashBoard> {
Uri.encodeFull(DotEnv().env['SERVER_URL'] + 'bottle/hub/' + hubid),
headers: {"authorization": usertoken},
);
print(response.body);
if (_bottleList.length != 0) {
_bottleList.clear();
}
......@@ -83,7 +83,13 @@ class _DashBoardState extends State<DashBoard> {
Icons.settings,
color: Colors.black,
),
onPressed: () {},
onPressed: () {
Navigator.push(
context,
MaterialPageRoute(
builder: (BuildContext context) => SettingPage(),
));
},
)
],
),
......@@ -96,18 +102,6 @@ class _DashBoardState extends State<DashBoard> {
color: Colors.blue,
),
),
ListTile(
title: Text('Test 1'),
onTap: () {},
),
ListTile(
title: Text('Test 2'),
onTap: () {},
),
ListTile(
title: Text('Test 3'),
onTap: () {},
),
],
),
),
......@@ -167,7 +161,6 @@ Widget mainpage(BuildContext context) {
Future<Medicine> _getmedicine() async {
String usertoken = await UserSecureStorage.getUserToken();
String medicineid = await UserSecureStorage.getMedicineId();
print(medicineid);
http.Response medicineresponse = await http.get(
Uri.encodeFull(
......@@ -750,7 +743,7 @@ Widget outerInformationpage(BuildContext context) {
if (response.statusCode == 200) {
Map<String, dynamic> jsonData = jsonDecode(response.body);
print(jsonData);
_bottleinformation = Bottle.fromJson(jsonData);
}
return _bottleinformation;
......@@ -773,8 +766,6 @@ Widget outerInformationpage(BuildContext context) {
),
);
} else {
print(123412);
print(snapshot.data.dosage);
return Container(
height: size.height * 0.9,
margin: EdgeInsets.fromLTRB(0, 30, 0, 0),
......@@ -877,67 +868,6 @@ Widget outerInformationpage(BuildContext context) {
],
),
),
Container(
margin: EdgeInsets.fromLTRB(0, 0, 0, 0),
height: size.height * 0.20,
width: size.width,
child: Column(
children: <Widget>[
Flexible(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
Container(
padding: EdgeInsets.fromLTRB(5, 5, 5, 0),
width: size.width * 0.9,
height: size.height * 0.18,
decoration: BoxDecoration(
color: Color(0xff8E97FD),
borderRadius: BorderRadius.circular(10.0),
),
child: Column(
children: [
Container(
width: size.width,
height: size.height * 0.05,
child: Center(
child: Text(
'약 복용 시간',
textAlign: TextAlign.center,
textScaleFactor: 1.0,
style: TextStyle(
color: Colors.white,
fontSize: 28,
fontFamily: 'NotoSansKR',
fontWeight: FontWeight.w800),
),
),
),
Container(
width: size.width,
height: size.height * 0.12,
child: Center(
child: Text(
'15:57',
textAlign: TextAlign.center,
textScaleFactor: 1.0,
style: TextStyle(
color: Colors.white,
fontSize: 70,
fontFamily: 'NotoSansKR',
fontWeight: FontWeight.w800),
),
),
),
],
),
),
],
),
),
],
),
),
],
),
);
......
......@@ -50,7 +50,6 @@ class _BottleListState extends State<BottleList> {
_userbottleList = await provider.getAllBottle();
for (int i = 0; i < _userbottleList.length; i++) {
print(_userbottleList[i].bottleId);
print(12345678);
}
print(provider.getAllBottle());
......@@ -172,9 +171,7 @@ class _BottleListState extends State<BottleList> {
Icons.create_sharp,
color: Colors.black,
),
onPressed: () {
print("asdfg");
},
onPressed: () {},
),
),
],
......
......@@ -22,8 +22,7 @@ class _DetailMedicineState extends State<DetailMedicine> {
//약 등록
Future<String> patchMedcine() async {
String usertoken = await UserSecureStorage.getUserToken();
print(widget.searchMedicine.medicineId);
print(widget.bottleId);
http.Response response = await http.patch(
Uri.encodeFull(
DotEnv().env['SERVER_URL'] + 'bottle/' + widget.bottleId),
......@@ -35,7 +34,7 @@ class _DetailMedicineState extends State<DetailMedicine> {
'medicineId': widget.searchMedicine.medicineId,
'dosage': medicineDosageController.text
}));
print(response.body);
if (response.statusCode == 200) {
String usertoken = await UserSecureStorage.setMedicineId(
widget.searchMedicine.medicineId.toString());
......
......@@ -27,7 +27,7 @@ class _HubListState extends State<HubList> {
DotEnv().env['SERVER_URL'] + 'bottle/hub/' + hubid.toString()),
headers: {"authorization": usertoken},
);
print(response.body);
if (_bottleList.length != 0) {
_bottleList.clear();
}
......@@ -51,12 +51,24 @@ class _HubListState extends State<HubList> {
Widget build(BuildContext context) {
final Size size = MediaQuery.of(context).size;
return Scaffold(
appBar: AppBar(
backgroundColor: Colors.white,
leading: new Icon(Icons.medical_services_rounded,
color: Colors.black, size: 45.0),
title: Text(
'Smart Medicine Box',
style: TextStyle(
color: Colors.black,
fontSize: 23,
fontFamily: 'Noto',
fontWeight: FontWeight.bold),
),
),
body: Container(
height: size.height,
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
SizedBox(height: 70),
Container(
height: size.height * 0.1,
width: size.width,
......@@ -80,7 +92,10 @@ class _HubListState extends State<HubList> {
itemBuilder: (BuildContext context, int index) {
return Container(
padding: EdgeInsets.all(8.0),
decoration: BoxDecoration(border: Border.all()),
decoration: BoxDecoration(
border: Border.all(),
borderRadius: BorderRadius.all(Radius.circular(25.0)),
),
child: ListTile(
title: Text(
'HUB ID: ' + '${widget.hublist[index]}',
......
......@@ -21,7 +21,7 @@ class _RegisterBottleState extends State<RegisterBottle> {
Future<String> registerhub_Validate() async {
String usertoken = await UserSecureStorage.getUserToken();
String hubid = await UserSecureStorage.getHubId();
print(hubid);
http.Response bottleresponse = await http.post(
Uri.encodeFull(DotEnv().env['SERVER_URL'] + 'bottle'),
headers: {
......
......@@ -118,10 +118,8 @@ class _RegisterHubState extends State<RegisterHub> {
child: RaisedButton(
onPressed: () async {
String saveMessage = await registerhub_Validate();
print(saveMessage);
if (saveMessage == "허브 등록 완료") {
UserSecureStorage.setHubId(medicineHubIDController.text);
print(UserSecureStorage.getHubId());
Navigator.push(
context,
MaterialPageRoute(
......
......@@ -28,7 +28,6 @@ class _SignInPageState extends State<SignInPage> {
//Login 함수
Future<String> login(String _email, String _password) async {
print(Uri.encodeFull(DotEnv().env['SERVER_URL'] + 'auth/login'));
http.Response response = await http.post(
Uri.encodeFull(DotEnv().env['SERVER_URL'] + 'auth/login'),
headers: {"Content-Type": "application/json"},
......@@ -39,8 +38,6 @@ class _SignInPageState extends State<SignInPage> {
},
),
);
print(response.statusCode);
if (response.statusCode == 200) {
Map<String, dynamic> data = jsonDecode(response.body);
user = User.fromJson(data);
......@@ -56,15 +53,11 @@ class _SignInPageState extends State<SignInPage> {
//Get Hub List 함수
Future<String> getHubList() async {
String usertoken = await UserSecureStorage.getUserToken();
print(usertoken);
http.Response response = await http.get(
Uri.encodeFull(DotEnv().env['SERVER_URL'] + 'hub'),
headers: {"authorization": usertoken},
);
print(response.statusCode);
List<dynamic> values = new List<dynamic>();
print(1234125);
print(values);
if (_hublist.length != 0) {
_hublist.clear();
}
......@@ -117,6 +110,9 @@ class _SignInPageState extends State<SignInPage> {
fontFamily: 'Noto',
fontWeight: FontWeight.bold)),
),
SizedBox(
height: 40,
),
Padding(
padding: const EdgeInsets.fromLTRB(20, 0, 20, 0),
child: new Column(
......@@ -211,7 +207,6 @@ class _SignInPageState extends State<SignInPage> {
String saveMessage = await login(
emailController.text,
passwordController.text);
print(saveMessage);
if (emailController.text.isEmpty ||
passwordController.text.isEmpty) {
showDialog(
......@@ -236,8 +231,6 @@ class _SignInPageState extends State<SignInPage> {
UserSecureStorage.setUserToken(
user.token);
var result = await getHubList();
print("Result");
print(result);
if (result == "Not Found") {
Navigator.push(
context,
......@@ -249,7 +242,6 @@ class _SignInPageState extends State<SignInPage> {
} else if (result == "get완료") {
UserSecureStorage.setUserId(
user.userId);
print('getgetget');
Navigator.push(
context,
MaterialPageRoute(
......
......@@ -23,7 +23,6 @@ class _SignUpLocalState extends State<SignUpLocal> {
bool passwordValidationVisible = true;
Future<String> signup_Validate() async {
print(Uri.encodeFull(DotEnv().env['SERVER_URL'] + 'auth/register'));
http.Response response = await http.post(
Uri.encodeFull(DotEnv().env['SERVER_URL'] + 'auth/register'),
headers: {"Content-Type": "application/json"},
......@@ -35,8 +34,6 @@ class _SignUpLocalState extends State<SignUpLocal> {
},
),
);
print(response.statusCode);
if (response.statusCode == 201) {
return "정보 입력 완료";
} else {
......
import 'package:Smart_Medicine_Box/src/screens/SettingPage/HubModifyList.dart';
import 'package:flutter/material.dart';
import 'package:Smart_Medicine_Box/src/screens/DashBoard.dart';
import 'package:Smart_Medicine_Box/src/screens/SettingPage/Alarm.dart';
import 'package:Smart_Medicine_Box/src/screens/SettingPage/Bluetooth.dart';
import 'package:Smart_Medicine_Box/src/screens/SettingPage/DEVInformation.dart';
import 'package:Smart_Medicine_Box/src/screens/SettingPage/InformationModify.dart';
import '../screens/Register/HubList.dart';
class SettingPage extends StatefulWidget {
@override
......@@ -112,7 +113,7 @@ class _SettingPageState extends State<SettingPage> {
fontFamily: 'Noto',
fontWeight: FontWeight.bold),
),
color: Color(0xff8E97FD),
color: Color(0xff0B1E33),
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(50)),
),
......@@ -128,11 +129,12 @@ class _SettingPageState extends State<SettingPage> {
Navigator.push(
context,
MaterialPageRoute(
builder: (BuildContext context) => Bluetooth(),
builder: (BuildContext context) =>
HubModifyList(),
));
},
child: Text(
'블루투스 설정',
'허브 등록',
textScaleFactor: 1.0,
style: TextStyle(
color: Colors.white,
......@@ -140,7 +142,7 @@ class _SettingPageState extends State<SettingPage> {
fontFamily: 'Noto',
fontWeight: FontWeight.bold),
),
color: Color(0xff8E97FD),
color: Color(0xff0B1E33),
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(50)),
),
......@@ -169,7 +171,7 @@ class _SettingPageState extends State<SettingPage> {
fontFamily: 'Noto',
fontWeight: FontWeight.bold),
),
color: Color(0xff8E97FD),
color: Color(0xff0B1E33),
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(50)),
),
......@@ -198,7 +200,7 @@ class _SettingPageState extends State<SettingPage> {
fontFamily: 'Noto',
fontWeight: FontWeight.bold),
),
color: Color(0xff8E97FD),
color: Color(0xff0B1E33),
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(50)),
),
......@@ -228,11 +230,12 @@ class _SettingPageState extends State<SettingPage> {
})
},
items: [
BottomNavigationBarItem(icon: Icon(Icons.favorite), label: 'In'),
BottomNavigationBarItem(
icon: Icon(Icons.device_thermostat), label: 'In'),
BottomNavigationBarItem(icon: Icon(Icons.home), label: 'Home'),
BottomNavigationBarItem(
label: 'Out',
icon: Icon(Icons.favorite),
icon: Icon(Icons.access_time),
)
],
),
......
import 'package:flutter/material.dart';
import 'package:Smart_Medicine_Box/src/screens/SettingPage.dart';
import 'package:flutter_blue/flutter_blue.dart';
class Bluetooth extends StatefulWidget {
@override
_BluetoothState createState() => _BluetoothState();
}
FlutterBlue flutterBlue;
class _BluetoothState extends State<Bluetooth> {
@override
void initState() {
super.initState();
flutterBlue = FlutterBlue.instance;
}
void _startscan() {
flutterBlue.startScan(timeout: Duration(seconds: 12));
var subscription = flutterBlue.scanResults.listen((results) {
// do something with scan results
for (ScanResult r in results) {
print(
'Device Name : ${r.device.name} // Device ID : ${r.device.id} // Device rssi: ${r.rssi}');
}
});
}
Widget build(BuildContext context) {
Widget _buildItem(ScanResult s) {
return ListTile(
leading: Text(s.rssi.toString()),
title: Text(s.device.name),
subtitle: Text(s.device.id.id),
onTap: () =>
Navigator.of(context).push(MaterialPageRoute(builder: (context) {
return Device(device: s.device);
})),
);
}
Widget _buildList(List<ScanResult> scanResults) {
return Column(
children: scanResults.map((v) => _buildItem(v)).toList(),
);
}
return MaterialApp(
title: 'Welcome to Flutter',
home: Scaffold(
appBar: AppBar(
iconTheme: IconThemeData(color: Colors.black),
backgroundColor: Colors.white,
title: Text(
'Smart Medicine Box',
style: TextStyle(
color: Colors.black,
fontSize: 20,
fontFamily: 'Noto',
fontWeight: FontWeight.bold),
),
actions: [
IconButton(
icon: Icon(
Icons.settings,
color: Colors.black,
),
onPressed: () {
Navigator.push(
context,
MaterialPageRoute(
builder: (BuildContext context) => SettingPage(),
));
},
)
],
),
drawer: Drawer(
child: ListView(
children: [
DrawerHeader(
child: Text('Drawer Header'),
decoration: BoxDecoration(
color: Colors.blue,
),
),
ListTile(
title: Text('Test 1'),
onTap: () {},
),
ListTile(
title: Text('Test 2'),
onTap: () {},
),
ListTile(
title: Text('Test 3'),
onTap: () {},
),
],
),
),
body: SingleChildScrollView(
child: StreamBuilder<List<ScanResult>>(
stream: FlutterBlue.instance.scanResults,
initialData: [],
builder: (c, snapshot) {
return _buildList(snapshot.data);
}),
),
floatingActionButton: StreamBuilder<bool>(
stream: FlutterBlue.instance.isScanning,
initialData: false,
builder: (c, snapshot) {
if (snapshot.data) {
return FloatingActionButton(
child: Icon(Icons.stop),
onPressed: () => FlutterBlue.instance.stopScan(),
backgroundColor: Colors.red,
);
} else {
return FloatingActionButton(
child: Icon(Icons.search),
onPressed: () => FlutterBlue.instance
.startScan(timeout: Duration(seconds: 4)));
}
},
),
),
);
}
}
class Device extends StatefulWidget {
Device({Key key, this.device}) : super(key: key);
final BluetoothDevice device;
@override
_DeviceState createState() => _DeviceState();
}
class _DeviceState extends State<Device> {
void initState() {
super.initState();
widget.device.connect();
}
@override
void dispose() {
widget.device.disconnect();
super.dispose();
}
Widget _buildIconButton() {
return StreamBuilder<BluetoothDeviceState>(
stream: widget.device.state,
initialData: BluetoothDeviceState.connecting,
builder: (c, snapshot) {
if (snapshot.data != BluetoothDeviceState.connected)
return Icon(Icons.warning);
return IconButton(
icon: Icon(Icons.bluetooth_searching),
onPressed: () => widget.device.discoverServices(),
);
});
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text(widget.device.name),
actions: <Widget>[
_buildIconButton(),
],
),
body: Text('hello'),
);
}
}
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import '../../shared/colors.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:Smart_Medicine_Box/src/screens/SettingPage.dart';
class DEVInformation extends StatefulWidget {
@override
......@@ -10,16 +9,36 @@ class DEVInformation extends StatefulWidget {
class _DEVInformationState extends State<DEVInformation> {
Widget build(BuildContext context) {
return MaterialApp(
title: 'Welcome to Flutter',
home: Scaffold(
final Size size = MediaQuery.of(context).size;
return Scaffold(
appBar: AppBar(
title: Text('Welcome to Flutter'),
iconTheme: IconThemeData(color: Colors.black),
backgroundColor: Colors.white,
title: Text(
'Smart Medicine Box',
style: TextStyle(
color: Colors.black,
fontSize: 20,
fontFamily: 'Noto',
fontWeight: FontWeight.bold),
),
body: Center(
child: Text('개발자 정보 작업 구역'),
actions: [
IconButton(
icon: Icon(
Icons.settings,
color: Colors.black,
),
onPressed: () {
Navigator.push(
context,
MaterialPageRoute(
builder: (BuildContext context) => SettingPage(),
));
},
)
],
),
body: Text('1234'),
);
}
}
......
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'dart:convert';
import 'package:http/http.dart' as http;
import 'package:flutter_dotenv/flutter_dotenv.dart';
// Screen import
import '../models/Bottle.dart';
import '../../utils/user_secure_stoarge.dart';
class HubModifyList extends StatefulWidget {
List<int> hublist;
HubModifyList({Key key, this.hublist}) : super(key: key);
@override
_HubModifyListState createState() => _HubModifyListState();
}
class _HubModifyListState extends State<HubModifyList> {
List<int> _hublist = new List<int>();
//Get Hub List 함수
Future<String> getHubList() async {
String usertoken = await UserSecureStorage.getUserToken();
http.Response response = await http.get(
Uri.encodeFull(DotEnv().env['SERVER_URL'] + 'hub'),
headers: {"authorization": usertoken},
);
List<dynamic> values = new List<dynamic>();
if (_hublist.length != 0) {
_hublist.clear();
}
if (response.statusCode == 200) {
values = json.decode(response.body);
for (int i = 0; i < values.length; i++) {
_hublist.add(values[i]['hubId']);
}
print(_hublist);
return "get완료";
} else if (response.statusCode == 404) {
return "Not Found";
} else {
return "Error";
}
}
Widget build(BuildContext context) {
final Size size = MediaQuery.of(context).size;
return Scaffold(
appBar: AppBar(
backgroundColor: Colors.white,
leading: new Icon(Icons.medical_services_rounded,
color: Colors.black, size: 45.0),
title: Text(
'Smart Medicine Box',
style: TextStyle(
color: Colors.black,
fontSize: 23,
fontFamily: 'Noto',
fontWeight: FontWeight.bold),
),
),
body: FutureBuilder(
future: getHubList(),
builder: (BuildContext context, AsyncSnapshot snapshot) {
if (snapshot.hasData == false) {
return CircularProgressIndicator();
} else if (snapshot.hasError) {
return Padding(
padding: const EdgeInsets.all(8.0),
child: Text(
'Error: ${snapshot.error}',
style: TextStyle(fontSize: 15),
),
);
} else {
return Container(
height: size.height,
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
Container(
height: size.height * 0.1,
width: size.width,
child: Center(
child: Text(
'등록된 허브 리스트',
textScaleFactor: 1.0,
style: TextStyle(
fontSize: 28,
fontFamily: 'Noto',
fontWeight: FontWeight.bold),
),
),
decoration: BoxDecoration(border: Border.all()),
),
SizedBox(height: 30),
Expanded(
child: ListView.separated(
padding: const EdgeInsets.all(30),
itemCount:
_hublist.length == null ? 0 : _hublist.length,
itemBuilder: (BuildContext context, int index) {
return Container(
padding: EdgeInsets.all(8.0),
decoration: BoxDecoration(
border: Border.all(),
borderRadius:
BorderRadius.all(Radius.circular(25.0)),
),
child: ListTile(
title: Text(
'HUB ID: ' + '${_hublist[index]}',
style: TextStyle(
color: Colors.black,
fontSize: 20,
fontFamily: 'Noto',
fontWeight: FontWeight.bold),
),
trailing: Icon(Icons.highlight_remove),
onTap: () async {
print('삭제 할거임');
}),
);
},
separatorBuilder: (BuildContext contetx, int index) =>
const Divider(),
),
),
Container(
padding: EdgeInsets.fromLTRB(0, 20, 0, 20),
width: size.width * 0.8,
height: size.height * 0.13,
margin: EdgeInsets.only(bottom: 0),
child: FlatButton(
height: size.height * 0.07,
onPressed: () {},
child: Text(
'허브 추가',
textScaleFactor: 1.0,
style: TextStyle(
color: Colors.white,
fontSize: 24,
fontFamily: 'Noto',
fontWeight: FontWeight.bold),
),
color: Color(0xff0B1E33),
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(50)),
),
),
],
),
);
}
}),
);
}
}
......@@ -77,24 +77,18 @@ class CustomPicker extends CommonPickerModel {
DateTime finalTime() {
var leftindex;
print(indexs);
if (indexs == 1) {
if(this.currentLeftIndex() == 12){
if (this.currentLeftIndex() == 12) {
leftindex = 12;
} else {
leftindex = this.currentLeftIndex() + 12;
}
} else if (indexs == 0) {
if(this.currentLeftIndex() == 12){
if (this.currentLeftIndex() == 12) {
leftindex = 0;
} else {
leftindex = this.currentLeftIndex();
}
}
return currentTime.isUtc
......
......@@ -19,13 +19,12 @@ class Bottle {
this.dosage});
factory Bottle.fromJson(Map<String, dynamic> parsedJson) {
print(parsedJson['temparture']);
return Bottle(
bottleId: parsedJson['bottleId'],
temperature: parsedJson['temperature'].toString(),
humidity: parsedJson['humidity'].toString(),
balance: parsedJson['balance'].toString(),
recentOpen: DateTime.parse(parsedJson['recentOpen']),
recentOpen: DateTime.parse(parsedJson['recentOpen']).toLocal(),
medicineId: parsedJson['medicineId'],
hubId: parsedJson['hubId'],
dosage: parsedJson['dosage'],
......