Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
ginkgo
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
vjrj
ginkgo
Commits
1f6b8ce8
Commit
1f6b8ce8
authored
5 months ago
by
vjrj
Browse files
Options
Downloads
Patches
Plain Diff
Add BasicAvatar and IpfsImage widgets
parent
5a78d9b2
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
lib/ui/basic_avatar.dart
+17
-0
17 additions, 0 deletions
lib/ui/basic_avatar.dart
lib/ui/ipfs_image.dart
+71
-0
71 additions, 0 deletions
lib/ui/ipfs_image.dart
lib/ui/ui_helpers.dart
+6
-36
6 additions, 36 deletions
lib/ui/ui_helpers.dart
with
94 additions
and
36 deletions
lib/ui/basic_avatar.dart
0 → 100644
+
17
−
0
View file @
1f6b8ce8
import
'package:flutter/material.dart'
;
import
'ui_helpers.dart'
;
import
'widgets/first_screen/circular_icon.dart'
;
class
BasicAvatar
extends
StatelessWidget
{
const
BasicAvatar
(
{
super
.
key
,
this
.
color
=
defAvatarColor
,
this
.
bgColor
=
defAvatarBgColor
});
final
Color
color
;
final
Color
bgColor
;
@override
Widget
build
(
BuildContext
context
)
{
return
CircularIcon
(
iconData:
Icons
.
person
,
backgroundColor:
color
,
iconColor:
bgColor
);
}
}
This diff is collapsed.
Click to expand it.
lib/ui/ipfs_image.dart
0 → 100644
+
71
−
0
View file @
1f6b8ce8
import
'package:flutter/material.dart'
;
import
'../data/models/node.dart'
;
import
'../data/models/node_manager.dart'
;
import
'../data/models/node_type.dart'
;
import
'basic_avatar.dart'
;
class
IpfsImage
extends
StatefulWidget
{
const
IpfsImage
({
super
.
key
,
required
this
.
path
,
});
final
String
path
;
@override
State
<
IpfsImage
>
createState
()
=
>
_IpfsImageState
();
}
class
_IpfsImageState
extends
State
<
IpfsImage
>
{
late
String
_currentUrl
;
late
List
<
Node
>
_ipfsNodes
;
int
_currentNodeIndex
=
0
;
@override
void
initState
()
{
super
.
initState
();
_ipfsNodes
=
NodeManager
()
.
nodesWorkingList
(
NodeType
.
ipfsGateway
);
_updateUrl
();
}
// Actualiza la URL al nodo actual
void
_updateUrl
()
{
if
(
_currentNodeIndex
<
_ipfsNodes
.
length
)
{
final
String
baseUrl
=
_ipfsNodes
[
_currentNodeIndex
]
.
url
;
setState
(()
{
_currentUrl
=
'
$baseUrl
/ipfs/
${widget.path}
'
;
});
}
else
{
setState
(()
{
_currentUrl
=
''
;
});
}
}
void
_switchToNextUrl
()
{
if
(
_currentNodeIndex
<
_ipfsNodes
.
length
)
{
NodeManager
()
.
increaseNodeErrors
(
NodeType
.
ipfsGateway
,
_ipfsNodes
[
_currentNodeIndex
]);
_currentNodeIndex
++
;
_updateUrl
();
}
}
@override
Widget
build
(
BuildContext
context
)
{
return
_currentUrl
.
isNotEmpty
?
Image
.
network
(
_currentUrl
,
fit:
BoxFit
.
cover
,
errorBuilder:
(
BuildContext
context
,
Object
error
,
StackTrace
?
stackTrace
)
{
WidgetsBinding
.
instance
.
addPostFrameCallback
((
_
)
{
_switchToNextUrl
();
});
return
const
BasicAvatar
();
},
)
:
const
BasicAvatar
();
}
}
This diff is collapsed.
Click to expand it.
lib/ui/ui_helpers.dart
+
6
−
36
View file @
1f6b8ce8
...
@@ -8,8 +8,6 @@ import 'package:flutter/foundation.dart';
...
@@ -8,8 +8,6 @@ import 'package:flutter/foundation.dart';
import
'package:flutter/material.dart'
;
import
'package:flutter/material.dart'
;
import
'package:flutter_bloc/flutter_bloc.dart'
;
import
'package:flutter_bloc/flutter_bloc.dart'
;
import
'package:flutter_slidable/flutter_slidable.dart'
;
import
'package:flutter_slidable/flutter_slidable.dart'
;
import
'package:hive_flutter/hive_flutter.dart'
;
import
'package:hydrated_bloc/hydrated_bloc.dart'
;
import
'package:latlong2/latlong.dart'
;
import
'package:latlong2/latlong.dart'
;
import
'package:path_provider/path_provider.dart'
;
import
'package:path_provider/path_provider.dart'
;
import
'package:permission_handler/permission_handler.dart'
;
import
'package:permission_handler/permission_handler.dart'
;
...
@@ -23,15 +21,15 @@ import '../data/models/cesium_card.dart';
...
@@ -23,15 +21,15 @@ import '../data/models/cesium_card.dart';
import
'../data/models/contact.dart'
;
import
'../data/models/contact.dart'
;
import
'../data/models/contact_cubit.dart'
;
import
'../data/models/contact_cubit.dart'
;
import
'../data/models/multi_wallet_transaction_cubit.dart'
;
import
'../data/models/multi_wallet_transaction_cubit.dart'
;
import
'../data/models/node_manager.dart'
;
import
'../data/models/theme_cubit.dart'
;
import
'../data/models/theme_cubit.dart'
;
import
'../g1/api.dart'
;
import
'../g1/api.dart'
;
import
'../g1/currency.dart'
;
import
'../g1/currency.dart'
;
import
'../g1/g1_helper.dart'
;
import
'../g1/g1_helper.dart'
;
import
'../shared_prefs_helper.dart'
;
import
'../shared_prefs_helper.dart'
;
import
'basic_avatar.dart'
;
import
'contacts_cache.dart'
;
import
'contacts_cache.dart'
;
import
'ipfs_image.dart'
;
import
'logger.dart'
;
import
'logger.dart'
;
import
'widgets/first_screen/circular_icon.dart'
;
Future
<
dynamic
>
showAlertDialog
(
Future
<
dynamic
>
showAlertDialog
(
BuildContext
context
,
String
title
,
String
message
)
{
BuildContext
context
,
String
title
,
String
message
)
{
...
@@ -90,10 +88,9 @@ Widget avatar(Contact c,
...
@@ -90,10 +88,9 @@ Widget avatar(Contact c,
return
CircleAvatar
(
return
CircleAvatar
(
radius:
avatarSize
,
radius:
avatarSize
,
child:
ClipOval
(
child:
ClipOval
(
child:
Image
.
network
(
child:
IpfsImage
(
path:
c
.
avatarCid
!
),
NodeManager
()
.
ipfsUrl
(
c
.
avatarCid
!
),
// fit: BoxFit.cover,
fit:
BoxFit
.
cover
,
),
)),
);
);
}
}
return
c
.
avatar
!=
null
&&
c
.
avatar
!.
isNotEmpty
return
c
.
avatar
!=
null
&&
c
.
avatar
!.
isNotEmpty
...
@@ -104,8 +101,7 @@ Widget avatar(Contact c,
...
@@ -104,8 +101,7 @@ Widget avatar(Contact c,
c
.
avatar
!
,
c
.
avatar
!
,
fit:
BoxFit
.
cover
,
fit:
BoxFit
.
cover
,
)))
)))
:
CircularIcon
(
:
const
BasicAvatar
();
iconData:
Icons
.
person
,
backgroundColor:
color
,
iconColor:
bgColor
);
}
}
String
humanizeFromToPubKey
(
String
publicAddress
,
String
address
)
{
String
humanizeFromToPubKey
(
String
publicAddress
,
String
address
)
{
...
@@ -710,32 +706,6 @@ const String g1nkgoUserNameSuffix = ' ❥';
...
@@ -710,32 +706,6 @@ const String g1nkgoUserNameSuffix = ' ❥';
const
String
protectedUserNameSuffix
=
' 🔒'
;
const
String
protectedUserNameSuffix
=
' 🔒'
;
const
double
cardAspectRatio
=
1.58
;
const
double
cardAspectRatio
=
1.58
;
Future
<
void
>
hydratedInit
()
async
{
await
Hive
.
initFlutter
();
// Reset hive old keys
if
(
kIsWeb
)
{
final
Box
<
dynamic
>
box
=
await
Hive
.
openBox
(
'hydrated_box'
,
path:
HydratedStorage
.
webStorageDirectory
.
path
);
final
List
<
dynamic
>
keysToDelete
=
box
.
keys
.
where
((
dynamic
key
)
=
>
'
$key
'
.
startsWith
(
'minified'
))
.
toList
();
box
.
deleteAll
(
keysToDelete
);
// This should we done after init
// await HydratedBloc.storage.clear();
box
.
close
();
}
if
(
kIsWeb
)
{
HydratedBloc
.
storage
=
await
HydratedStorage
.
build
(
storageDirectory:
HydratedStorage
.
webStorageDirectory
);
}
else
{
final
Directory
tmpDir
=
await
getTemporaryDirectory
();
Hive
.
init
(
tmpDir
.
toString
());
HydratedBloc
.
storage
=
await
HydratedStorage
.
build
(
storageDirectory:
tmpDir
);
}
}
String
buildTxNotifTitle
(
String
?
from
)
{
String
buildTxNotifTitle
(
String
?
from
)
{
final
String
title
=
from
!=
null
final
String
title
=
from
!=
null
?
tr
(
'notification_new_payment_title'
)
?
tr
(
'notification_new_payment_title'
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment