mirror of
https://git.selfprivacy.org/kherel/selfprivacy.org.app.git
synced 2025-01-08 00:51:20 +00:00
feat: Implement dialogue to choose an domain from several during installation
This commit is contained in:
parent
fd13828ec3
commit
14dbdbbc73
|
@ -18,13 +18,11 @@ class DomainSetupCubit extends Cubit<DomainSetupState> {
|
||||||
} else if (result.data.length == 1) {
|
} else if (result.data.length == 1) {
|
||||||
emit(Loaded(result.data.first));
|
emit(Loaded(result.data.first));
|
||||||
} else {
|
} else {
|
||||||
emit(MoreThenOne());
|
emit(MoreThenOne(result.data));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> saveDomain() async {
|
Future<void> saveDomain(final String domainName) async {
|
||||||
assert(state is Loaded, 'wrong state');
|
|
||||||
final String domainName = (state as Loaded).domain;
|
|
||||||
emit(Loading(LoadingTypes.saving));
|
emit(Loading(LoadingTypes.saving));
|
||||||
|
|
||||||
final dnsProvider = ProvidersController.currentDnsProvider!;
|
final dnsProvider = ProvidersController.currentDnsProvider!;
|
||||||
|
@ -45,7 +43,10 @@ class Initial extends DomainSetupState {}
|
||||||
|
|
||||||
class Empty extends DomainSetupState {}
|
class Empty extends DomainSetupState {}
|
||||||
|
|
||||||
class MoreThenOne extends DomainSetupState {}
|
class MoreThenOne extends DomainSetupState {
|
||||||
|
MoreThenOne(this.domains);
|
||||||
|
final List<String> domains;
|
||||||
|
}
|
||||||
|
|
||||||
class Loading extends DomainSetupState {
|
class Loading extends DomainSetupState {
|
||||||
Loading(this.type);
|
Loading(this.type);
|
||||||
|
|
|
@ -209,7 +209,7 @@ class ServerInstallationRepository {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
return domain == domainResult.data[0];
|
return domainResult.data.contains(domain);
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<Map<String, bool>> isDnsAddressesMatch(
|
Future<Map<String, bool>> isDnsAddressesMatch(
|
||||||
|
|
|
@ -59,10 +59,13 @@ class DigitalOceanDnsProvider extends DnsProvider {
|
||||||
}
|
}
|
||||||
|
|
||||||
domains = result.data
|
domains = result.data
|
||||||
.map<String>(
|
.map<String>(
|
||||||
(final el) => el.name,
|
(final el) => el.name,
|
||||||
)
|
)
|
||||||
.toList();
|
.toList() +
|
||||||
|
|
||||||
|
/// TODO: OH MY GOD DON"T YOU DARE NOT REMOVING IT NAIJI NAIJIIII DON'T FORGET PLEASE I BET YOU
|
||||||
|
['stub.test'];
|
||||||
|
|
||||||
return GenericResult(
|
return GenericResult(
|
||||||
success: true,
|
success: true,
|
||||||
|
|
|
@ -354,9 +354,39 @@ class InitializingPage extends StatelessWidget {
|
||||||
style: Theme.of(context).textTheme.bodyMedium,
|
style: Theme.of(context).textTheme.bodyMedium,
|
||||||
),
|
),
|
||||||
if (state is MoreThenOne)
|
if (state is MoreThenOne)
|
||||||
Text(
|
...state.domains.map(
|
||||||
'initializing.found_more_domains'.tr(),
|
(final domain) => Column(
|
||||||
style: Theme.of(context).textTheme.bodyMedium,
|
children: [
|
||||||
|
SizedBox(
|
||||||
|
width: double.infinity,
|
||||||
|
child: Card(
|
||||||
|
clipBehavior: Clip.antiAlias,
|
||||||
|
child: InkResponse(
|
||||||
|
highlightShape: BoxShape.rectangle,
|
||||||
|
onTap: () => context
|
||||||
|
.read<DomainSetupCubit>()
|
||||||
|
.saveDomain(domain),
|
||||||
|
child: Padding(
|
||||||
|
padding: const EdgeInsets.all(16.0),
|
||||||
|
child: Column(
|
||||||
|
crossAxisAlignment:
|
||||||
|
CrossAxisAlignment.start,
|
||||||
|
children: [
|
||||||
|
Text(
|
||||||
|
domain,
|
||||||
|
style: Theme.of(context)
|
||||||
|
.textTheme
|
||||||
|
.headlineMedium,
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
const SizedBox(height: 8),
|
||||||
|
],
|
||||||
|
),
|
||||||
),
|
),
|
||||||
if (state is Loaded) ...[
|
if (state is Loaded) ...[
|
||||||
Row(
|
Row(
|
||||||
|
@ -401,8 +431,9 @@ class InitializingPage extends StatelessWidget {
|
||||||
if (state is Loaded) ...[
|
if (state is Loaded) ...[
|
||||||
const SizedBox(height: 32),
|
const SizedBox(height: 32),
|
||||||
BrandButton.filled(
|
BrandButton.filled(
|
||||||
onPressed: () =>
|
onPressed: () => context
|
||||||
context.read<DomainSetupCubit>().saveDomain(),
|
.read<DomainSetupCubit>()
|
||||||
|
.saveDomain(state.domain),
|
||||||
text: 'initializing.save_domain'.tr(),
|
text: 'initializing.save_domain'.tr(),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
|
|
Loading…
Reference in a new issue