Skip to content

Commit

Permalink
factorize open avatar to function. Open avatar viewer set to contain
Browse files Browse the repository at this point in the history
  • Loading branch information
odrevet committed May 31, 2019
1 parent d550a5c commit acb7d1f
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 48 deletions.
32 changes: 16 additions & 16 deletions lib/account.dart
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,21 @@ class Account {
String avatar;
}

openAvatarViewerDialog(context, image){
Navigator.of(context).push(MaterialPageRoute<Null>(
builder: (BuildContext context) {
return Container(
decoration: BoxDecoration(
image: DecorationImage(
image: image,
fit: BoxFit.contain,
),
),
);
},
fullscreenDialog: true));
}

String extractAccountId(str) {
final idRegex = RegExp(r'/account/(\d+).html');
var match = idRegex.firstMatch(str);
Expand Down Expand Up @@ -142,21 +157,6 @@ class AccountPageWidget extends StatelessWidget {
);
}

_openAvatarViewerDialog(context, image){
Navigator.of(context).push(MaterialPageRoute<Null>(
builder: (BuildContext context) {
return Container(
decoration: BoxDecoration(
image: DecorationImage(
image: image,
fit: BoxFit.cover,
),
),
);
},
fullscreenDialog: true));
}

Widget _buildView(BuildContext context, Account account) {
final url = baseUri + account.avatar;
final image = NetworkImage(url);
Expand All @@ -179,7 +179,7 @@ class AccountPageWidget extends StatelessWidget {
Expanded(
child: InkWell(
onTap: () {
_openAvatarViewerDialog(context, image);
openAvatarViewerDialog(context, image);
},
child: Image.network(url))),
Expanded(
Expand Down
17 changes: 1 addition & 16 deletions lib/manageAccount.dart
Original file line number Diff line number Diff line change
Expand Up @@ -33,21 +33,6 @@ class ManageAccountPageWidget extends StatelessWidget {
);
}

_openAvatarViewerDialog(context, image){
Navigator.of(context).push(MaterialPageRoute<Null>(
builder: (BuildContext context) {
return Container(
decoration: BoxDecoration(
image: DecorationImage(
image: image,
fit: BoxFit.cover,
),
),
);
},
fullscreenDialog: true));
}

Widget _buildView(BuildContext context, Account account) {
final url = baseUri + account.avatar;
final image = NetworkImage(url);
Expand All @@ -65,7 +50,7 @@ class ManageAccountPageWidget extends StatelessWidget {
Expanded(
child: InkWell(
onTap: () {
_openAvatarViewerDialog(context, image);
openAvatarViewerDialog(context, image);
},
child: Image.network(url))),
Expanded(
Expand Down
17 changes: 1 addition & 16 deletions lib/trombidoscope.dart
Original file line number Diff line number Diff line change
Expand Up @@ -83,21 +83,6 @@ class _TrombidoscopeWidgetState extends State<TrombidoscopeWidget> {
);
}

_openAvatarViewerDialog(context, image){
Navigator.of(context).push(MaterialPageRoute<Null>(
builder: (BuildContext context) {
return Container(
decoration: BoxDecoration(
image: DecorationImage(
image: image,
fit: BoxFit.cover,
),
),
);
},
fullscreenDialog: true));
}

Widget _buildView(
BuildContext context, Map<String, AccountLink> accountLinks) {
var rows = <GestureDetector>[];
Expand All @@ -114,7 +99,7 @@ class _TrombidoscopeWidgetState extends State<TrombidoscopeWidget> {
account: fetchAccount(accountLink.id))));
},
onLongPress: () {
_openAvatarViewerDialog(context, NetworkImage(url));
openAvatarViewerDialog(context, NetworkImage(url));
},
child: Container(
child: Text(accountLink.name, style: _font),
Expand Down

0 comments on commit acb7d1f

Please sign in to comment.