Skip to content

Commit fd2d1c4

Browse files
committed
Merge branch 'master' into cl/merge-v1.13.0-into-f-droid
2 parents b3dcfba + 712bbd6 commit fd2d1c4

File tree

10 files changed

+75
-29
lines changed

10 files changed

+75
-29
lines changed
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,21 @@
11
import 'package:flutter/material.dart';
2-
import 'package:flutter_mobx/flutter_mobx.dart';
32
import 'package:flutter_svg/svg.dart';
4-
import 'package:provider/provider.dart';
53

6-
import 'package:encointer_wallet/config/consts.dart';
74
import 'package:encointer_wallet/theme/theme.dart';
8-
import 'package:encointer_wallet/store/app.dart';
95

10-
class CommunityIconObserver extends StatelessWidget {
11-
const CommunityIconObserver({super.key, double? radius}) : radius = radius ?? 10;
6+
class CommunityCircleAvatar extends StatelessWidget {
7+
const CommunityCircleAvatar(this.icon, {super.key, double? radius}) : radius = radius ?? 10;
8+
9+
final SvgPicture icon;
1210

1311
final double radius;
1412

1513
@override
1614
Widget build(BuildContext context) {
17-
final store = context.watch<AppStore>();
1815
return CircleAvatar(
1916
backgroundColor: context.colorScheme.background,
2017
radius: radius,
21-
child: Observer(
22-
builder: (_) {
23-
if (store.encointer.community != null && store.encointer.community!.assetsCid != null) {
24-
if (store.encointer.community!.communityIcon != null) {
25-
return SvgPicture.string(store.encointer.community!.communityIcon!);
26-
} else {
27-
return SvgPicture.asset(fallBackCommunityIcon);
28-
}
29-
} else {
30-
return SvgPicture.asset(fallBackCommunityIcon);
31-
}
32-
},
33-
),
18+
child: icon,
3419
);
3520
}
3621
}

app/lib/page-encointer/common/community_chooser_panel.dart

+13-3
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import 'package:encointer_wallet/common/components/address_icon.dart';
66
import 'package:encointer_wallet/common/components/logo/community_icon.dart';
77
import 'package:encointer_wallet/store/app.dart';
88
import 'package:encointer_wallet/utils/format.dart';
9+
import 'package:flutter_svg/svg.dart';
910

1011
/// the CombinedCommunityAndAccountAvatar should be wrapped in an InkWell to provide the callback on a click
1112
class CombinedCommunityAndAccountAvatar extends StatefulWidget {
@@ -42,7 +43,10 @@ class _CombinedCommunityAndAccountAvatarState extends State<CombinedCommunityAnd
4243
shape: RoundedRectangleBorder(
4344
borderRadius: BorderRadius.circular(widget.communityAvatarSize),
4445
),
45-
child: CommunityAvatar(avatarSize: widget.communityAvatarSize),
46+
child: CommunityAvatar(
47+
widget.store.encointer.communityIconOrDefault,
48+
avatarSize: widget.communityAvatarSize,
49+
),
4650
),
4751
Positioned(
4852
bottom: 0,
@@ -72,7 +76,13 @@ class _CombinedCommunityAndAccountAvatarState extends State<CombinedCommunityAnd
7276
}
7377

7478
class CommunityAvatar extends StatelessWidget {
75-
const CommunityAvatar({super.key, this.avatarSize = 120});
79+
const CommunityAvatar(
80+
this.icon, {
81+
super.key,
82+
this.avatarSize = 120,
83+
});
84+
85+
final SvgPicture icon;
7686

7787
final double avatarSize;
7888

@@ -81,7 +91,7 @@ class CommunityAvatar extends StatelessWidget {
8191
return SizedBox(
8292
width: avatarSize,
8393
height: avatarSize,
84-
child: const CommunityIconObserver(),
94+
child: CommunityCircleAvatar(icon),
8595
);
8696
}
8797
}

app/lib/page-encointer/meetup/ceremony_step3_finish.dart

+4-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,10 @@ class CeremonyStep3Finish extends StatelessWidget {
4141
children: [
4242
const CeremonyProgressBar(progress: 3),
4343
const SizedBox(height: 48),
44-
const CommunityAvatar(avatarSize: 96),
44+
CommunityAvatar(
45+
store.encointer.communityIconOrDefault,
46+
avatarSize: 96,
47+
),
4548
Center(
4649
child: Text(
4750
l10n.thankYou,

app/lib/page/assets/announcement/widgets/announcement_card.dart

+7-1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import 'package:encointer_wallet/page/assets/announcement/logic/announcement_car
99
import 'package:encointer_wallet/models/announcement/announcement.dart';
1010
import 'package:encointer_wallet/config/consts.dart';
1111
import 'package:encointer_wallet/common/components/logo/community_icon.dart';
12+
import 'package:encointer_wallet/store/app.dart';
1213
import 'package:encointer_wallet/gen/assets.gen.dart';
1314
import 'package:encointer_wallet/theme/theme.dart';
1415

@@ -19,6 +20,8 @@ class AnnouncementCard extends StatelessWidget {
1920

2021
@override
2122
Widget build(BuildContext context) {
23+
final store = context.read<AppStore>();
24+
2225
final local = Localizations.localeOf(context);
2326
final cardStore = context.watch<AnnouncementCardStore>();
2427
return Padding(
@@ -39,7 +42,10 @@ class AnnouncementCard extends StatelessWidget {
3942
radius: 8,
4043
backgroundImage: Assets.images.public.app.provider(),
4144
)
42-
: const CommunityIconObserver(radius: 8),
45+
: CommunityCircleAvatar(
46+
store.encointer.communityIconOrDefault,
47+
radius: 8,
48+
),
4349
),
4450
title: Align(
4551
alignment: Alignment.centerRight,

app/lib/page/profile/account/account_manage_page.dart

+7-2
Original file line numberDiff line numberDiff line change
@@ -104,12 +104,17 @@ class _AccountManagePageState extends State<AccountManagePage> {
104104

105105
final community = _appStore.encointer.communityStores?[cidFmt];
106106

107-
if (community == null) {
107+
if (community == null || community.applyDemurrage == null) {
108108
// Never happened, but we want to be defensive here to prevent a red screen.
109109
Log.e('[AccountManagePage] Communities is null, even though we have a balance entry for it. Fatal app error.');
110110
return Container();
111111
}
112112

113+
if ((community.applyDemurrage!(entry) ?? 0) <= 0.0001 && cidFmt != _appStore.encointer.chosenCid!.toFmtString()) {
114+
Log.p("[AccountManagePage] Don't display community with 0 balance");
115+
return Container();
116+
}
117+
113118
final isBootstrapper = _appStore.encointer.community!.bootstrappers != null &&
114119
_appStore.encointer.community!.bootstrappers!.contains(address);
115120

@@ -120,7 +125,7 @@ class _AccountManagePageState extends State<AccountManagePage> {
120125
leading: CommunityIcon(
121126
store: _appStore,
122127
isBootstrapper: isBootstrapper,
123-
icon: const CommunityIconObserver(),
128+
icon: CommunityCircleAvatar(community.icon),
124129
),
125130
title: Text(community.name!, style: h3),
126131
subtitle: Text(community.symbol!, style: h3),

app/lib/store/encointer/encointer.dart

+11
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import 'dart:async';
22

3+
import 'package:flutter_svg/svg.dart';
34
import 'package:json_annotation/json_annotation.dart';
45
import 'package:mobx/mobx.dart';
56

@@ -15,6 +16,7 @@ import 'package:encointer_wallet/store/encointer/sub_stores/bazaar_store/bazaar_
1516
import 'package:encointer_wallet/store/encointer/sub_stores/community_store/community_account_store/community_account_store.dart';
1617
import 'package:encointer_wallet/store/encointer/sub_stores/community_store/community_store.dart';
1718
import 'package:encointer_wallet/store/encointer/sub_stores/encointer_account_store/encointer_account_store.dart';
19+
import 'package:encointer_wallet/config/consts.dart';
1820

1921
part 'encointer.g.dart';
2022

@@ -176,6 +178,15 @@ abstract class _EncointerStore with Store {
176178
return applyDemurrage(communityBalanceEntry);
177179
}
178180

181+
@computed
182+
SvgPicture get communityIconOrDefault {
183+
if (community != null) {
184+
return community!.icon;
185+
} else {
186+
return SvgPicture.asset(fallBackCommunityIcon);
187+
}
188+
}
189+
179190
double? applyDemurrage(BalanceEntry? entry) {
180191
if (_rootStore.chain.latestHeaderNumber != null &&
181192
entry != null &&

app/lib/store/encointer/encointer.g.dart

+7
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

app/lib/store/encointer/sub_stores/community_store/community_store.dart

+13
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
import 'dart:async';
22
import 'dart:convert';
33

4+
import 'package:encointer_wallet/config/consts.dart';
5+
import 'package:flutter_svg/svg.dart';
46
import 'package:json_annotation/json_annotation.dart';
57
import 'package:mobx/mobx.dart';
68

@@ -79,13 +81,24 @@ abstract class _CommunityStore with Store {
7981
@observable
8082
String? communityIcon;
8183

84+
@computed
85+
SvgPicture get icon {
86+
if (communityIcon != null) {
87+
return SvgPicture.string(communityIcon!);
88+
} else {
89+
return SvgPicture.asset(fallBackCommunityIcon);
90+
}
91+
}
92+
8293
double? Function(BalanceEntry)? get applyDemurrage => _applyDemurrage;
8394

8495
@action
8596
Future<String?> getCommunityIcon() async {
8697
try {
8798
if (assetsCid != null) {
99+
Log.e('[getCommunityIcon] get icon with cid: $assetsCid');
88100
final maybeIcon = await webApi.ipfsApi.getCommunityIcon(assetsCid!);
101+
Log.e('[getCommunityIcon]: got icon: $maybeIcon');
89102
if (maybeIcon != null) communityIcon = maybeIcon;
90103
}
91104
} catch (e) {

app/lib/store/encointer/sub_stores/community_store/community_store.g.dart

+7-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

app/pubspec.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ description: EncointerWallet made with Flutter.
1414

1515
# bump version already while working on new release, bumping build number at the same time
1616
# bump build number even more, if needed to clarify what's deployed
17-
version: 1.13.0+880
17+
version: 1.13.1+881
1818

1919
publish_to: none
2020

0 commit comments

Comments
 (0)