Skip to content

Commit

Permalink
Migrate to flutter 3.29 and dart 3.7 (#437)
Browse files Browse the repository at this point in the history
* chore: bump dart and flutter

* fix: specify count type

* chore: reformat connector_ui

* chore: reformat enmeshed

* chore: reformat connector_sdk

* chore: reformat enmeshed_runtime_bridge

* chore: reformat enmeshed_types

* chore: reformat renderers

* chore: reformat value_renderer

* feat: set page_width in analysis_options

* chore: disable rule
  • Loading branch information
jkoenig134 authored Feb 13, 2025
1 parent 18b6a34 commit 328b43d
Show file tree
Hide file tree
Showing 603 changed files with 7,948 additions and 11,711 deletions.
3 changes: 3 additions & 0 deletions analysis_options.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,6 @@ linter:
prefer_final_fields: true
unnecessary_parenthesis: true
always_declare_return_types: true

formatter:
page_width: 150
5 changes: 1 addition & 4 deletions apps/connector_ui/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,7 @@ class MainApp extends StatelessWidget {
darkTheme: ThemeData.dark(useMaterial3: true),
debugShowCheckedModeBanner: false,
initialRoute: '/login',
routes: {
'/login': (context) => const LoginScreen(),
'/main': (context) => const MainScreen(),
},
routes: {'/login': (context) => const LoginScreen(), '/main': (context) => const MainScreen()},
);
}
}
25 changes: 7 additions & 18 deletions apps/connector_ui/lib/screens/login_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -49,23 +49,11 @@ class _LoginScreenState extends State<LoginScreen> {
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
SharedPreferencesEnabledTextField(
label: 'Base URL',
controller: baseUrlController,
sharedPreferencesKey: 'baseurl',
),
SharedPreferencesEnabledTextField(label: 'Base URL', controller: baseUrlController, sharedPreferencesKey: 'baseurl'),
const SizedBox(height: 10),
SharedPreferencesEnabledTextField(
label: 'API Key',
controller: apiKeyController,
sharedPreferencesKey: 'apikey',
obscureText: true,
),
SharedPreferencesEnabledTextField(label: 'API Key', controller: apiKeyController, sharedPreferencesKey: 'apikey', obscureText: true),
const SizedBox(height: 10),
ElevatedButton(
onPressed: _loginEnabled ? login : null,
child: const Text('Login'),
),
ElevatedButton(onPressed: _loginEnabled ? login : null, child: const Text('Login')),
if (_loginProcessing || _errorMessage != null) const SizedBox(height: 10),
if (_loginProcessing) const CircularProgressIndicator(),
if (_errorMessage != null) Text(_errorMessage!),
Expand Down Expand Up @@ -94,9 +82,10 @@ class _LoginScreenState extends State<LoginScreen> {
});

if (identityInfoResult.hasError) {
final errorMessage = identityInfoResult.error.code == 'error.connector.unauthorized'
? 'Login failed: Invalid API key'
: 'Login failed: ${identityInfoResult.error.code}';
final errorMessage =
identityInfoResult.error.code == 'error.connector.unauthorized'
? 'Login failed: Invalid API key'
: 'Login failed: ${identityInfoResult.error.code}';
setState(() {
_errorMessage = errorMessage;
});
Expand Down
139 changes: 59 additions & 80 deletions apps/connector_ui/lib/screens/main_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -41,51 +41,51 @@ class _MainScreenState extends State<MainScreen> {
),
body: Center(
child: ListView.builder(
itemBuilder: (context, index) => ExpansionTile(
leading: relationships[index].status == RelationshipStatus.Active
? const Icon(
Icons.check_circle,
color: Colors.lightGreen,
)
: null,
title: FutureBuilder(
future: renderRelationship(relationships[index]),
builder: (context, snapshot) => snapshot.hasData ? Text(snapshot.data.toString()) : Text(relationships[index].peer),
),
children: [
Text('ID: ${relationships[index].id}'),
Text('Peer: ${relationships[index].peer}'),
Text('Status: ${relationships[index].status.name}'),
Padding(
padding: const EdgeInsets.all(8.0),
child: ExpansionTile(
title: const Text('Attributes'),
children: [
FutureBuilder(
future: client.relationships.getAttributesForRelationship(relationships[index].id),
builder: (context, snapshot) => snapshot.hasData
? Column(children: snapshot.data!.data.map((e) => Text(e.content.toString())).toList())
: const Text('Loading...'),
),
],
itemBuilder:
(context, index) => ExpansionTile(
leading: relationships[index].status == RelationshipStatus.Active ? const Icon(Icons.check_circle, color: Colors.lightGreen) : null,
title: FutureBuilder(
future: renderRelationship(relationships[index]),
builder: (context, snapshot) => snapshot.hasData ? Text(snapshot.data.toString()) : Text(relationships[index].peer),
),
),
Padding(
padding: const EdgeInsets.all(8.0),
child: ExpansionTile(
title: const Text('Messages'),
children: [
FutureBuilder(
future: client.messages.getMessages({'participant': relationships[index].peer}),
builder: (context, snapshot) => snapshot.hasData
? Column(children: snapshot.data!.data.map((e) => Text(e.content.toString())).toList())
: const Text('Loading...'),
children: [
Text('ID: ${relationships[index].id}'),
Text('Peer: ${relationships[index].peer}'),
Text('Status: ${relationships[index].status.name}'),
Padding(
padding: const EdgeInsets.all(8.0),
child: ExpansionTile(
title: const Text('Attributes'),
children: [
FutureBuilder(
future: client.relationships.getAttributesForRelationship(relationships[index].id),
builder:
(context, snapshot) =>
snapshot.hasData
? Column(children: snapshot.data!.data.map((e) => Text(e.content.toString())).toList())
: const Text('Loading...'),
),
],
),
],
),
),
Padding(
padding: const EdgeInsets.all(8.0),
child: ExpansionTile(
title: const Text('Messages'),
children: [
FutureBuilder(
future: client.messages.getMessages({'participant': relationships[index].peer}),
builder:
(context, snapshot) =>
snapshot.hasData
? Column(children: snapshot.data!.data.map((e) => Text(e.content.toString())).toList())
: const Text('Loading...'),
),
],
),
),
],
),
],
),
itemCount: relationships.length,
),
),
Expand All @@ -98,11 +98,7 @@ class _MainScreenState extends State<MainScreen> {
final identityInfo = identityInfoResponse.data;

if (mounted) {
return showDialog<void>(
context: context,
barrierDismissible: false,
builder: (BuildContext context) => _InfoDialog(client, identityInfo),
);
return showDialog<void>(context: context, barrierDismissible: false, builder: (BuildContext context) => _InfoDialog(client, identityInfo));
}
}

Expand Down Expand Up @@ -133,25 +129,22 @@ class _MainScreenState extends State<MainScreen> {
final response = await client.relationships.getAttributesForRelationship(relationship.id);
final relationshipAttributes = response.data.where((a) => a.content.owner == relationship.peer);

final displayName = relationshipAttributes
.where(
(a) => a.content is IdentityAttribute && (a.content as IdentityAttribute).value is DisplayNameAttributeValue,
)
.firstOrNull;
final displayName =
relationshipAttributes
.where((a) => a.content is IdentityAttribute && (a.content as IdentityAttribute).value is DisplayNameAttributeValue)
.firstOrNull;
if (displayName != null) {
return '${relationship.peer} (${((displayName.content as IdentityAttribute).value as DisplayNameAttributeValue).value})';
}

final surname = relationshipAttributes
.where(
(a) => a.content is IdentityAttribute && (a.content as IdentityAttribute).value is SurnameAttributeValue,
)
.firstOrNull;
final givenName = relationshipAttributes
.where(
(a) => a.content is IdentityAttribute && (a.content as IdentityAttribute).value is GivenNameAttributeValue,
)
.firstOrNull;
final surname =
relationshipAttributes
.where((a) => a.content is IdentityAttribute && (a.content as IdentityAttribute).value is SurnameAttributeValue)
.firstOrNull;
final givenName =
relationshipAttributes
.where((a) => a.content is IdentityAttribute && (a.content as IdentityAttribute).value is GivenNameAttributeValue)
.firstOrNull;
if (surname != null || givenName != null) {
final name =
'${((surname!.content as IdentityAttribute).value as SurnameAttributeValue).value} ${((givenName!.content as IdentityAttribute).value as GivenNameAttributeValue).value}'
Expand Down Expand Up @@ -181,42 +174,28 @@ class _InfoDialog extends StatelessWidget {
const Text('Connector BaseURL: ', style: TextStyle(fontWeight: FontWeight.bold)),
const Spacer(),
Text(client.baseUrl),
IconButton(
icon: const Icon(Icons.copy),
onPressed: () => Clipboard.setData(ClipboardData(text: client.baseUrl)),
),
IconButton(icon: const Icon(Icons.copy), onPressed: () => Clipboard.setData(ClipboardData(text: client.baseUrl))),
],
),
Row(
children: [
const Text('Connector Address: ', style: TextStyle(fontWeight: FontWeight.bold)),
const Spacer(),
Text(identityInfo.address),
IconButton(
icon: const Icon(Icons.copy),
onPressed: () => Clipboard.setData(ClipboardData(text: identityInfo.address)),
),
IconButton(icon: const Icon(Icons.copy), onPressed: () => Clipboard.setData(ClipboardData(text: identityInfo.address))),
],
),
Row(
children: [
const Text('Connector Public Key: ', style: TextStyle(fontWeight: FontWeight.bold)),
const Spacer(),
Expanded(child: Text(identityInfo.publicKey, overflow: TextOverflow.ellipsis)),
IconButton(
icon: const Icon(Icons.copy),
onPressed: () => Clipboard.setData(ClipboardData(text: identityInfo.publicKey)),
),
IconButton(icon: const Icon(Icons.copy), onPressed: () => Clipboard.setData(ClipboardData(text: identityInfo.publicKey))),
],
),
],
),
actions: <Widget>[
TextButton(
child: const Text('Close'),
onPressed: () => Navigator.of(context).pop(),
),
],
actions: <Widget>[TextButton(child: const Text('Close'), onPressed: () => Navigator.of(context).pop())],
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,7 @@ class _SharedPreferencesEnabledTextFieldState extends State<SharedPreferencesEna
enabled: _enabled,
),
),
IconButton(
icon: Icon(_enabled ? Icons.lock_open : Icons.lock),
onPressed: toggle,
),
IconButton(icon: Icon(_enabled ? Icons.lock_open : Icons.lock), onPressed: toggle),
],
);
}
Expand Down
Loading

0 comments on commit 328b43d

Please sign in to comment.