
import 'package:flutter/material.dart';
import 'package:provider/provider.dart';
import 'package:twong/models/index.dart';
import 'package:twong/providers/message.dart';
import 'package:twong/widgets/app_bar.dart';

class MessageDetailsPage extends StatefulWidget {
  final num id;
  MessageDetailsPage(this.id);

  @override
  State<StatefulWidget> createState() {
    return _MessageDetailsState();
  }
}

class _MessageDetailsState extends State<MessageDetailsPage> {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: DAppBar("消息详情"),
      body: SafeArea(
        child: Consumer<MessageModel>(
          builder: (context, model, child) => _buildMessage(model.data),
        ),
      ),
    );
  }

  Widget _buildMessage(List<Message> list) {
    final data = list[widget.id];
    return Container(
      child: Column(children: [
        Text(data.subject),
        Text(data.body),
      ]),
    );
  }
}