74 lines
1.8 KiB
Dart
74 lines
1.8 KiB
Dart
import 'package:flutter/material.dart';
|
|
|
|
import 'package:pweb/pages/settings/profile/account/name/line.dart';
|
|
|
|
|
|
class AccountNameViewText extends StatelessWidget {
|
|
const AccountNameViewText({
|
|
super.key,
|
|
required this.hintText,
|
|
required this.inputWidth,
|
|
required this.firstName,
|
|
required this.lastName,
|
|
});
|
|
|
|
final String hintText;
|
|
final double inputWidth;
|
|
final String firstName;
|
|
final String lastName;
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
final theme = Theme.of(context);
|
|
final trimmedFirstName = firstName.trim();
|
|
final trimmedLastName = lastName.trim();
|
|
final hasFirstName = trimmedFirstName.isNotEmpty;
|
|
final hasLastName = trimmedLastName.isNotEmpty;
|
|
|
|
final firstLineStyle = theme.textTheme.headlineMedium?.copyWith(
|
|
fontWeight: FontWeight.bold,
|
|
);
|
|
final secondLineStyle = theme.textTheme.headlineMedium?.copyWith(
|
|
fontWeight: FontWeight.bold,
|
|
);
|
|
|
|
if (!hasFirstName && !hasLastName) {
|
|
return SizedBox(
|
|
width: inputWidth,
|
|
child: AccountNameSingleLineText(
|
|
text: hintText,
|
|
style: firstLineStyle,
|
|
),
|
|
);
|
|
}
|
|
|
|
if (!hasFirstName || !hasLastName) {
|
|
final singleLineName = hasFirstName ? trimmedFirstName : trimmedLastName;
|
|
return SizedBox(
|
|
width: inputWidth,
|
|
child: AccountNameSingleLineText(
|
|
text: singleLineName,
|
|
style: firstLineStyle,
|
|
),
|
|
);
|
|
}
|
|
|
|
return SizedBox(
|
|
width: inputWidth,
|
|
child: Column(
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
children: [
|
|
AccountNameSingleLineText(
|
|
text: trimmedFirstName,
|
|
style: firstLineStyle,
|
|
),
|
|
AccountNameSingleLineText(
|
|
text: trimmedLastName,
|
|
style: secondLineStyle,
|
|
),
|
|
],
|
|
),
|
|
);
|
|
}
|
|
}
|