import 'package:flutter/material.dart';

import 'package:provider/provider.dart';

import 'package:pweb/controllers/auth/account_name.dart';
import 'package:pweb/pages/settings/profile/account/name/editing.dart';
import 'package:pweb/pages/settings/profile/account/name/text_view.dart';


class AccountNameText extends StatelessWidget {
  const AccountNameText({
    super.key,
    required this.hintText,
    required this.lastNameHint,
    required this.inputWidth,
    required this.borderWidth,
  });

  final String hintText;
  final String lastNameHint;
  final double inputWidth;
  final double borderWidth;

  @override
  Widget build(BuildContext context) {
    final state = context.watch<AccountNameController>();

    if (state.isEditing) {
      return AccountNameEditingFields(
        hintText: hintText,
        lastNameHint: lastNameHint,
        borderWidth: borderWidth,
        inputWidth: inputWidth,
        state: state,
      );
    }

    return AccountNameViewText(
      hintText: hintText,
      inputWidth: inputWidth,
      firstName: state.currentFirstName,
      lastName: state.currentLastName,
    );
  }
}
