fix(block2): clearer market states — 'can't reach servers' (retry) vs 'set your area'
Feedback: the market sometimes looked 'disabled'. Now the offline/empty states are distinct and honest: - No working relay (defaults exist, so it's a reachability issue) → 'Can't reach the community servers right now' + a Retry. - Online but no area set → 'Set your area' prompt (you'd otherwise see a bare 'nothing nearby'). - Area set + nothing found → the existing empty state. i18n en/es/pt; offline tests updated; analyzer clean.
This commit is contained in:
parent
5f87ad2d56
commit
cfba85b9d9
9 changed files with 86 additions and 8 deletions
|
|
@ -42,6 +42,7 @@ class MarketScreen extends StatefulWidget {
|
|||
class _MarketScreenState extends State<MarketScreen> {
|
||||
OffersCubit? _cubit;
|
||||
bool _loading = true;
|
||||
bool _hasArea = false;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
|
|
@ -64,6 +65,7 @@ class _MarketScreenState extends State<MarketScreen> {
|
|||
final previous = _cubit;
|
||||
setState(() {
|
||||
_cubit = cubit;
|
||||
_hasArea = area.isNotEmpty;
|
||||
_loading = false;
|
||||
});
|
||||
await previous?.close();
|
||||
|
|
@ -171,6 +173,8 @@ class _MarketScreenState extends State<MarketScreen> {
|
|||
value: cubit,
|
||||
child: MarketBody(
|
||||
onConfigure: _openConfig,
|
||||
onRetry: _init,
|
||||
hasArea: _hasArea,
|
||||
selfPubkey: widget.social.publicKeyHex,
|
||||
),
|
||||
),
|
||||
|
|
@ -181,12 +185,20 @@ class _MarketScreenState extends State<MarketScreen> {
|
|||
class MarketBody extends StatelessWidget {
|
||||
const MarketBody({
|
||||
required this.onConfigure,
|
||||
this.onRetry,
|
||||
this.hasArea = true,
|
||||
this.selfPubkey,
|
||||
super.key,
|
||||
});
|
||||
|
||||
final VoidCallback onConfigure;
|
||||
|
||||
/// Re-opens the connection (for the "can't reach servers" retry).
|
||||
final VoidCallback? onRetry;
|
||||
|
||||
/// Whether the user has set their coarse area yet.
|
||||
final bool hasArea;
|
||||
|
||||
/// This user's own pubkey, so we don't offer to message our own listings.
|
||||
final String? selfPubkey;
|
||||
|
||||
|
|
@ -196,10 +208,21 @@ class MarketBody extends StatelessWidget {
|
|||
return BlocBuilder<OffersCubit, OffersState>(
|
||||
builder: (context, state) {
|
||||
if (!context.read<OffersCubit>().isOnline) {
|
||||
// Default community servers exist, so "offline" means unreachable —
|
||||
// offer a retry rather than "set up sharing".
|
||||
return _EmptyState(
|
||||
icon: Icons.wifi_tethering_off_outlined,
|
||||
title: t.market.notSetUp,
|
||||
body: t.market.notSetUpBody,
|
||||
title: t.market.cantReach,
|
||||
body: t.market.cantReachBody,
|
||||
actionLabel: onRetry != null ? t.market.retry : null,
|
||||
onAction: onRetry,
|
||||
);
|
||||
}
|
||||
if (!hasArea) {
|
||||
return _EmptyState(
|
||||
icon: Icons.place_outlined,
|
||||
title: t.market.setArea,
|
||||
body: t.market.setAreaBody,
|
||||
actionLabel: t.market.setUp,
|
||||
onAction: onConfigure,
|
||||
);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue