device.dart 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. import 'package:flutter/material.dart';
  2. import 'package:vnote_device_plugin/models/device.dart';
  3. class DeviceCard extends StatefulWidget {
  4. final DeviceInfo? data;
  5. const DeviceCard({super.key, required this.data});
  6. @override
  7. State<StatefulWidget> createState() => _DeviceCardState();
  8. }
  9. class _DeviceCardState extends State<DeviceCard> {
  10. @override
  11. Widget build(BuildContext context) {
  12. final data = widget.data;
  13. return Card(
  14. elevation: 4,
  15. shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(16)),
  16. child: Container(
  17. width: 360,
  18. height: 160,
  19. padding: const EdgeInsets.symmetric(horizontal: 24, vertical: 16),
  20. child: Column(
  21. crossAxisAlignment: CrossAxisAlignment.start,
  22. children: [
  23. _InfoItem(label: "产品名称", content: data?.productName),
  24. _InfoItem(label: "产品型号", content: data?.model),
  25. _InfoItem(label: "蓝牙名称", content: data?.bleName),
  26. _InfoItem(label: "蓝牙地址", content: data?.mac),
  27. ],
  28. ),
  29. ),
  30. );
  31. }
  32. }
  33. class _InfoItem extends StatelessWidget {
  34. final String label;
  35. final String? content;
  36. const _InfoItem({super.key, required this.label, this.content});
  37. @override
  38. Widget build(BuildContext context) {
  39. return Container(
  40. alignment: Alignment.centerLeft,
  41. height: 32,
  42. child: Row(
  43. children: [
  44. Text(
  45. "$label:",
  46. style: const TextStyle(fontSize: 18, color: Colors.black54),
  47. ),
  48. const SizedBox(width: 16),
  49. Text(
  50. content ?? "",
  51. style: const TextStyle(fontSize: 18),
  52. ),
  53. ],
  54. ),
  55. );
  56. }
  57. }