track_page.dart 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  1. import 'package:flutter/material.dart';
  2. import 'package:flutter_tracker/utils/app_util.dart';
  3. import 'package:flutter_tracker/views/contact_card.dart';
  4. class TrackPage extends StatefulWidget {
  5. const TrackPage({Key key}) : super(key: key);
  6. @override
  7. _TrackPageState createState() => _TrackPageState();
  8. }
  9. class _TrackPageState extends State<TrackPage> {
  10. String testText = '';
  11. List<dynamic> contactTraces = [];
  12. List<dynamic> contactTimes = [];
  13. List<dynamic> contactLocations = [];
  14. @override
  15. Widget build(BuildContext context) {
  16. return Column(
  17. children: <Widget>[
  18. Expanded(
  19. child: Padding(
  20. padding: EdgeInsets.only(
  21. left: 25.0,
  22. right: 25.0,
  23. bottom: 10.0,
  24. top: 30.0,
  25. ),
  26. child: Container(
  27. height: 50.0,
  28. width: double.infinity,
  29. decoration: BoxDecoration(
  30. color: Colors.deepPurple[500],
  31. borderRadius: BorderRadius.circular(20.0),
  32. boxShadow: const [
  33. BoxShadow(
  34. color: Colors.black,
  35. blurRadius: 4.0,
  36. spreadRadius: 0.0,
  37. offset: Offset(2.0, 2.0), // shadow direction: bottom right
  38. )
  39. ],
  40. ),
  41. child: Row(
  42. children: const <Widget>[
  43. Expanded(
  44. child: Image(
  45. image: AssetImage('assets/images/corona.png'),
  46. ),
  47. ),
  48. Expanded(
  49. flex: 2,
  50. child: Text(
  51. '附近用户',
  52. textAlign: TextAlign.left,
  53. style: TextStyle(
  54. fontSize: 21.0,
  55. color: Colors.white,
  56. fontWeight: FontWeight.w500,
  57. ),
  58. ),
  59. )
  60. ],
  61. ),
  62. ),
  63. ),
  64. ),
  65. Padding(
  66. padding: EdgeInsets.only(bottom: 200.0),
  67. child: RaisedButton(
  68. shape: RoundedRectangleBorder(
  69. borderRadius: BorderRadius.circular(20.0)),
  70. elevation: 5.0,
  71. color: Colors.deepPurple[400],
  72. onPressed: () async {
  73. startTrack();
  74. },
  75. child: const Text(
  76. '开始追踪',
  77. style: TextStyle(
  78. fontSize: 20.0,
  79. fontWeight: FontWeight.bold,
  80. color: Colors.white,
  81. ),
  82. ),
  83. ),
  84. ),
  85. Expanded(
  86. flex: 2,
  87. child: Padding(
  88. padding: const EdgeInsets.symmetric(horizontal: 25.0),
  89. child: ListView.builder(
  90. itemBuilder: (context, index) {
  91. return ContactCard(
  92. imagePath: 'assets/images/head.jpg',
  93. email: contactTraces[index],
  94. infection: 'Not-Infected',
  95. contactUsername: contactTraces[index],
  96. contactTime: contactTimes[index],
  97. contactLocation: contactLocations[index],
  98. );
  99. },
  100. itemCount: contactTraces.length,
  101. ),
  102. ),
  103. ),
  104. ],
  105. );
  106. }
  107. void startTrack() async {
  108. // try {
  109. // bool a = await Nearby().startAdvertising(
  110. // loggedInUser.email,
  111. // strategy,
  112. // onConnectionInitiated: null,
  113. // onConnectionResult: (id, status) {
  114. // print(status);
  115. // },
  116. // onDisconnected: (id) {
  117. // print('Disconnected $id');
  118. // },
  119. // );
  120. //
  121. // print('ADVERTISING ${a.toString()}');
  122. // } catch (e) {
  123. // print(e);
  124. // }
  125. discovery();
  126. AppUtil.buildToast("正在搜索附近的人...");
  127. AppUtil.buildToast("追踪用户状态中...");
  128. }
  129. void discovery() {}
  130. }