Moved the AccountName widgets to pull providers from context
This commit is contained in:
@@ -1,18 +1,16 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import 'package:provider/provider.dart';
|
||||
|
||||
import 'package:pweb/providers/account_name.dart';
|
||||
|
||||
|
||||
class AccountNameActions extends StatelessWidget {
|
||||
const AccountNameActions({
|
||||
super.key,
|
||||
required this.state,
|
||||
});
|
||||
|
||||
final AccountNameState state;
|
||||
const AccountNameActions({super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final state = context.watch<AccountNameState>();
|
||||
final theme = Theme.of(context);
|
||||
|
||||
if (state.isEditing) {
|
||||
|
||||
@@ -54,10 +54,10 @@ class _AccountNameBody extends StatelessWidget {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final state = context.watch<AccountNameState>();
|
||||
final provider = context.watch<AccountProvider>();
|
||||
final theme = Theme.of(context);
|
||||
|
||||
return Consumer2<AccountNameState, AccountProvider>(
|
||||
builder: (context, state, provider, _) {
|
||||
final currentName = provider.account?.name ?? state.initialName;
|
||||
state.syncName(currentName);
|
||||
|
||||
@@ -68,13 +68,12 @@ class _AccountNameBody extends StatelessWidget {
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
AccountNameText(
|
||||
state: state,
|
||||
hintText: hintText,
|
||||
inputWidth: _AccountNameConstants.inputWidth,
|
||||
borderWidth: _AccountNameConstants.borderWidth,
|
||||
),
|
||||
const SizedBox(width: _AccountNameConstants.spacing),
|
||||
AccountNameActions(state: state),
|
||||
const AccountNameActions(),
|
||||
],
|
||||
),
|
||||
const SizedBox(height: _AccountNameConstants.errorSpacing),
|
||||
@@ -87,7 +86,5 @@ class _AccountNameBody extends StatelessWidget {
|
||||
),
|
||||
],
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,24 +1,25 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import 'package:provider/provider.dart';
|
||||
|
||||
import 'package:pweb/providers/account_name.dart';
|
||||
|
||||
|
||||
class AccountNameText extends StatelessWidget {
|
||||
const AccountNameText({
|
||||
super.key,
|
||||
required this.state,
|
||||
required this.hintText,
|
||||
required this.inputWidth,
|
||||
required this.borderWidth,
|
||||
});
|
||||
|
||||
final AccountNameState state;
|
||||
final String hintText;
|
||||
final double inputWidth;
|
||||
final double borderWidth;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final state = context.watch<AccountNameState>();
|
||||
final theme = Theme.of(context);
|
||||
|
||||
if (state.isEditing) {
|
||||
|
||||
Reference in New Issue
Block a user