import 'package:farmer_client/pages/main/widgets/main/index.dart';
import 'package:farmer_client/widgets/layout/BasicPage.dart';
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:get/get_rx/src/rx_types/rx_types.dart';

import '../../models/entities/Address.dart';
import '../../services/address.dart';

class Main extends BasicPage {
  Main({Key? key}) : super(key: key) {
    tabIndex = 3;
    naviTitle = '我的';
  }
  final addressListInfo = Rx<List<Address>>([]);
  final addressInfoContent = Rx<Address>(Address());




  @override
  void beforeShow() {
    // TODO: implement beforeShow
    super.beforeShow();
    getAddress().then((value) {
      List<Address> list = [];
      value['records'].forEach((item) {
        list.add(Address.fromJson(item));
      });
      addressListInfo(list);
      addressInfoContent(addressListInfo()[0]);
    });
  }

  @override
  Widget builder(BuildContext context) {
    return Obx(()=>MainPage( item: addressInfoContent(),));
  }
}