import 'package:flutter/material.dart';

import 'package:provider/provider.dart';

import 'package:pweb/pages/settings/profile/account/name/editing.dart';
import 'package:pweb/pages/settings/profile/account/name/view.dart';
import 'package:pweb/providers/account_name.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<AccountNameState>();

    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,
    );
  }
}
