mirror of
https://git.selfprivacy.org/kherel/selfprivacy.org.app.git
synced 2025-01-07 00:24:18 +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) {
|
||||
emit(Loaded(result.data.first));
|
||||
} else {
|
||||
emit(MoreThenOne());
|
||||
emit(MoreThenOne(result.data));
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> saveDomain() async {
|
||||
assert(state is Loaded, 'wrong state');
|
||||
final String domainName = (state as Loaded).domain;
|
||||
Future<void> saveDomain(final String domainName) async {
|
||||
emit(Loading(LoadingTypes.saving));
|
||||
|
||||
final dnsProvider = ProvidersController.currentDnsProvider!;
|
||||
|
@ -45,7 +43,10 @@ class Initial 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 {
|
||||
Loading(this.type);
|
||||
|
|
|
@ -209,7 +209,7 @@ class ServerInstallationRepository {
|
|||
return false;
|
||||
}
|
||||
|
||||
return domain == domainResult.data[0];
|
||||
return domainResult.data.contains(domain);
|
||||
}
|
||||
|
||||
Future<Map<String, bool>> isDnsAddressesMatch(
|
||||
|
|
|
@ -59,10 +59,13 @@ class DigitalOceanDnsProvider extends DnsProvider {
|
|||
}
|
||||
|
||||
domains = result.data
|
||||
.map<String>(
|
||||
(final el) => el.name,
|
||||
)
|
||||
.toList();
|
||||
.map<String>(
|
||||
(final el) => el.name,
|
||||
)
|
||||
.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(
|
||||
success: true,
|
||||
|
|
|
@ -354,9 +354,39 @@ class InitializingPage extends StatelessWidget {
|
|||
style: Theme.of(context).textTheme.bodyMedium,
|
||||
),
|
||||
if (state is MoreThenOne)
|
||||
Text(
|
||||
'initializing.found_more_domains'.tr(),
|
||||
style: Theme.of(context).textTheme.bodyMedium,
|
||||
...state.domains.map(
|
||||
(final domain) => Column(
|
||||
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) ...[
|
||||
Row(
|
||||
|
@ -401,8 +431,9 @@ class InitializingPage extends StatelessWidget {
|
|||
if (state is Loaded) ...[
|
||||
const SizedBox(height: 32),
|
||||
BrandButton.filled(
|
||||
onPressed: () =>
|
||||
context.read<DomainSetupCubit>().saveDomain(),
|
||||
onPressed: () => context
|
||||
.read<DomainSetupCubit>()
|
||||
.saveDomain(state.domain),
|
||||
text: 'initializing.save_domain'.tr(),
|
||||
),
|
||||
],
|
||||
|
|
Loading…
Reference in a new issue