Refactor FileExplorer and HomePage to use dynamic orgId instead of hardcoded values
This commit is contained in:
@@ -163,37 +163,52 @@ class _HomePageState extends State<HomePage> with TickerProviderStateMixin {
|
||||
Widget _buildOrgRow(BuildContext context) {
|
||||
return BlocBuilder<OrganizationBloc, OrganizationState>(
|
||||
builder: (context, state) {
|
||||
List<Organization> orgs = [];
|
||||
Organization? selectedOrg;
|
||||
bool isLoading = false;
|
||||
|
||||
if (state is OrganizationLoaded) {
|
||||
final orgs = state.organizations;
|
||||
return Column(
|
||||
children: [
|
||||
Row(
|
||||
children: [
|
||||
...orgs.map(
|
||||
(org) => Row(
|
||||
children: [
|
||||
_buildOrgButton(
|
||||
org,
|
||||
org.id == state.selectedOrg?.id,
|
||||
() {
|
||||
context.read<OrganizationBloc>().add(
|
||||
SelectOrganization(org.id),
|
||||
);
|
||||
},
|
||||
),
|
||||
const SizedBox(width: 16),
|
||||
],
|
||||
),
|
||||
),
|
||||
_buildAddButton(() => _showCreateOrgDialog(context)),
|
||||
],
|
||||
),
|
||||
const Divider(height: 1),
|
||||
],
|
||||
);
|
||||
} else {
|
||||
return const SizedBox.shrink();
|
||||
orgs = state.organizations;
|
||||
selectedOrg = state.selectedOrg;
|
||||
isLoading = state.isLoading;
|
||||
} else if (state is OrganizationLoading) {
|
||||
isLoading = true;
|
||||
}
|
||||
|
||||
return Column(
|
||||
children: [
|
||||
Row(
|
||||
children: [
|
||||
...orgs.map(
|
||||
(org) => Row(
|
||||
children: [
|
||||
_buildOrgButton(org, org.id == selectedOrg?.id, () {
|
||||
context.read<OrganizationBloc>().add(
|
||||
SelectOrganization(org.id),
|
||||
);
|
||||
}),
|
||||
const SizedBox(width: 16),
|
||||
],
|
||||
),
|
||||
),
|
||||
if (isLoading)
|
||||
SizedBox(
|
||||
width: 20,
|
||||
height: 20,
|
||||
child: CircularProgressIndicator(
|
||||
strokeWidth: 2,
|
||||
valueColor: AlwaysStoppedAnimation<Color>(
|
||||
AppTheme.accentColor,
|
||||
),
|
||||
),
|
||||
)
|
||||
else
|
||||
_buildAddButton(() => _showCreateOrgDialog(context)),
|
||||
],
|
||||
),
|
||||
const Divider(height: 1),
|
||||
],
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user