track_page.dart 4.0 KB

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