Skip to content

Commit

Permalink
add: improved import
Browse files Browse the repository at this point in the history
  • Loading branch information
harljo committed Apr 10, 2024
1 parent e161362 commit 545cbc2
Show file tree
Hide file tree
Showing 3 changed files with 64 additions and 79 deletions.
119 changes: 57 additions & 62 deletions lib/subscriptions/_import.dart
Original file line number Diff line number Diff line change
Expand Up @@ -86,13 +86,10 @@ class _SubscriptionImportScreenState extends State<SubscriptionImportScreen> {

@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
return AlertDialog(
title: Text(L10n.of(context).import_subscriptions),
),
body: Container(
margin: const EdgeInsets.all(16),
child: Column(
content: Column(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Padding(
Expand All @@ -112,7 +109,7 @@ class _SubscriptionImportScreenState extends State<SubscriptionImportScreen> {
padding: const EdgeInsets.only(bottom: 16),
child: TextFormField(
decoration: InputDecoration(
border: const UnderlineInputBorder(),
border: const OutlineInputBorder(),
hintText: L10n.of(context).enter_your_twitter_username,
helperText: L10n.of(context).your_profile_must_be_public_otherwise_the_import_will_not_work,
prefixText: '@',
Expand All @@ -127,66 +124,64 @@ class _SubscriptionImportScreenState extends State<SubscriptionImportScreen> {
},
),
),
Expanded(
child: Center(
child: StreamBuilder(
stream: _streamController?.stream,
builder: (context, snapshot) {
var error = snapshot.error;
if (error != null) {
return FullPageErrorWidget(
error: snapshot.error,
stackTrace: snapshot.stackTrace,
prefix: L10n.of(context).unable_to_import,
);
}

switch (snapshot.connectionState) {
case ConnectionState.none:
case ConnectionState.waiting:
return Container();
case ConnectionState.active:
return Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
const Padding(
padding: EdgeInsets.all(16),
child: CircularProgressIndicator(),
Center(
child: StreamBuilder(
stream: _streamController?.stream,
builder: (context, snapshot) {
var error = snapshot.error;
if (error != null) {
return FullPageErrorWidget(
error: snapshot.error,
stackTrace: snapshot.stackTrace,
prefix: L10n.of(context).unable_to_import,
);
}

switch (snapshot.connectionState) {
case ConnectionState.none:
case ConnectionState.waiting:
return Container();
case ConnectionState.active:
return Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
const Padding(
padding: EdgeInsets.all(16),
child: CircularProgressIndicator(),
),
Text(
L10n.of(context).imported_snapshot_data_users_so_far(
snapshot.data.toString(),
),
Text(
L10n.of(context).imported_snapshot_data_users_so_far(
snapshot.data.toString(),
),
)
],
);
default:
return Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
const Padding(
padding: EdgeInsets.all(16),
child: Icon(Icons.check_circle, size: 36, color: Colors.green),
)
],
);
default:
return Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
const Padding(
padding: EdgeInsets.all(16),
child: Icon(Icons.check_circle, size: 36, color: Colors.green),
),
Text(
L10n.of(context).finished_with_snapshotData_users(
snapshot.data.toString(),
),
Text(
L10n.of(context).finished_with_snapshotData_users(
snapshot.data.toString(),
),
)
],
);
}
},
),
)
],
);
}
},
),
),
],
),
),
floatingActionButton: FloatingActionButton(
child: const Icon(Icons.cloud_download),
onPressed: () async => await importSubscriptions(),
),
);
actions: [
TextButton(
child: Text(L10n.of(context).import_from_twitter),
onPressed: () async => await importSubscriptions(),
),
]);
}
}
10 changes: 0 additions & 10 deletions lib/subscriptions/_list.dart
Original file line number Diff line number Diff line change
Expand Up @@ -49,16 +49,6 @@ class _SubscriptionUsersState extends State<SubscriptionUsers> {
color: Theme.of(context).hintColor,
)),
),
Container(
margin: const EdgeInsets.symmetric(vertical: 8),
child: ElevatedButton(
child: Text(L10n.of(context).import_from_twitter),
onPressed: () => showModalBottomSheet(
context: context,
builder: (context) => const SubscriptionImportScreen(),
),
),
)
]));
}

Expand Down
14 changes: 7 additions & 7 deletions lib/subscriptions/subscriptions.dart
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,6 @@ class SubscriptionsScreen extends StatelessWidget {
appBar: AppBar(
title: Text(L10n.current.subscriptions),
actions: [
IconButton(
icon: const Icon(Icons.cloud_download),
onPressed: () => showModalBottomSheet(
context: context,
builder: (context) => const SubscriptionImportScreen(),
),
),
IconButton(
icon: const Icon(Icons.refresh),
onPressed: () => context.read<SubscriptionsModel>().refreshSubscriptionData(),
Expand Down Expand Up @@ -65,6 +58,13 @@ class SubscriptionsScreen extends StatelessWidget {
)
],
),
floatingActionButton: FloatingActionButton(
child: const Icon(Icons.cloud_download),
onPressed: () => showDialog(
context: context,
builder: (context) => const SubscriptionImportScreen(),
),
),
);
}
}

0 comments on commit 545cbc2

Please sign in to comment.