How to used Flutter write CUI alarm APP with DeepSeek

Publish Time: Author: Site Editor Visit: 29

import 'package:flutter/material.dart';

void main() => runApp(MyApp());

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: '保温层报警系统',
      theme: ThemeData(
        primarySwatch: Colors.blue,
        visualDensity: VisualDensity.adaptivePlatformDensity,
      ),
      home: AlarmDetailPage(),
    );
  }
}

class AlarmDetailPage extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: const Text('腐蚀报警详情'),
        backgroundColor: Colors.orange[800],
      ),
      body: SingleChildScrollView(
        padding: const EdgeInsets.all(16),
        child: Column(
          crossAxisAlignment: CrossAxisAlignment.start,
          children: [
            _buildAlertSection(),
            const SizedBox(height: 20),
            _buildLocationSection(),
            const SizedBox(height: 20),
            _buildCorrosionSection(),
            const SizedBox(height: 20),
            _buildActionSection(),
          ],
        ),
      ),
    );
  }

  Widget _buildAlertSection() {
    return Card(
      elevation: 4,
      child: Padding(
        padding: const EdgeInsets.all(16),
        child: Column(
          crossAxisAlignment: CrossAxisAlignment.start,
          children: [
            Row(
              children: [
                Icon(Icons.warning_amber, color: Colors.red),
                const SizedBox(width: 8),
                Text(
                  '报警信息[1]',
                  style: TextStyle(
                    fontSize: 20,
                    fontWeight: FontWeight.bold,
                    color: Colors.red,
                  ),
                ),
              ],
            ),
            const SizedBox(height: 12),
            _buildInfoRow('报警时间', '2024-12-23 10:23:50'),
            _buildInfoRow('设备编号', 'ER电阻探头03'),
            _buildInfoRow('片区位置', '003片区/弯头004'),
          ],
        ),
      ),
    );
  }

  Widget _buildLocationSection() {
    return Card(
      elevation: 4,
      child: Padding(
        padding: const EdgeInsets.all(16),
        child: Column(
          crossAxisAlignment: CrossAxisAlignment.start,
          children: [
            Text('设备位置', style: _sectionTitleStyle()),
            const SizedBox(height: 10),
            Text('浙江 » 温州 » 瓯海 » 新桥111 » X棣楼', style: _contentStyle()),
            Text('燃油燃烧装置', style: _contentStyle().copyWith(color: Colors.grey[600])),
          ],
        ),
      ),
    );
  }

  Widget _buildCorrosionSection() {
    return Card(
      elevation: 4,
      child: Padding(
        padding: const EdgeInsets.all(16),
        child: Column(
          crossAxisAlignment: CrossAxisAlignment.start,
          children: [
            Text('腐蚀状态', style: _sectionTitleStyle()),
            const SizedBox(height: 12),
            _buildStatusIndicator('腐蚀等级', '微腐蚀', Colors.green),
            _buildInfoRow('金属损耗', '2.2 密尔'),
            const SizedBox(height: 10),
            Text('处理建议', style: _subTitleStyle()),
            _buildBulletPoint('建议吹干保温层及钝化剂'),
            _buildBulletPoint('开保温层检修设备状态'),
            _buildBulletPoint('检查钝化剂吹干状况'),
          ],
        ),
      ),
    );
  }

  Widget _buildActionSection() {
    return Card(
      elevation: 4,
      child: Padding(
        padding: const EdgeInsets.all(16),
        child: Column(
          crossAxisAlignment: CrossAxisAlignment.start,
          children: [
            Text('操作指令', style: _sectionTitleStyle()),
            const SizedBox(height: 12),
            _buildActionButton('检查设备状态', Icons.build_circle),
            _buildActionButton('查看泄漏量', Icons.leak_add),
            _buildActionButton('查看腐蚀率说明', Icons.description),
          ],
        ),
      ),
    );
  }

  // Helper widgets
  Widget _buildInfoRow(String title, String value) {
    return Padding(
      padding: const EdgeInsets.symmetric(vertical: 4),
      child: Row(
        mainAxisAlignment: MainAxisAlignment.spaceBetween,
        children: [
          Text(title, style: _contentStyle()),
          Text(value, style: _contentStyle().copyWith(fontWeight: FontWeight.bold)),
        ],
      ),
    );
  }

  Widget _buildStatusIndicator(String title, String status, Color color) {
    return Row(
      children: [
        Container(
          width: 12,
          height: 12,
          decoration: BoxDecoration(
            color: color,
            shape: BoxShape.circle,
          ),
        ),
        const SizedBox(width: 8),
        Text('$title: $status', 
            style: _contentStyle().copyWith(color: color)),
      ],
    );
  }

  Widget _buildBulletPoint(String text) {
    return Padding(
      padding: const EdgeInsets.symmetric(vertical: 4),
      child: Row(
        crossAxisAlignment: CrossAxisAlignment.start,
        children: [
          const Text('• ', style: TextStyle(fontSize: 16)),
          Expanded(child: Text(text, style: _contentStyle())),
        ],
      ),
    );
  }

  Widget _buildActionButton(String text, IconData icon) {
    return Padding(
      padding: const EdgeInsets.symmetric(vertical: 6),
      child: ElevatedButton.icon(
        icon: Icon(icon, size: 20),
        label: Text(text),
        style: ElevatedButton.styleFrom(
          minimumSize: const Size(double.infinity, 40),
          backgroundColor: Colors.blue[800],
          foregroundColor: Colors.white,
        ),
        onPressed: () {},
      ),
    );
  }

  // Text styles
  TextStyle _sectionTitleStyle() {
    return const TextStyle(
      fontSize: 18,
      fontWeight: FontWeight.bold,
      color: Colors.black87,
    );
  }

  TextStyle _subTitleStyle() {
    return TextStyle(
      fontSize: 16,
      fontWeight: FontWeight.w500,
      color: Colors.grey[700],
    );
  }

  TextStyle _contentStyle() {
    return const TextStyle(
      fontSize: 16,
      color: Colors.black54,
    );
  }
}

Recommend Products