Skip to content
This repository has been archived by the owner on Sep 20, 2024. It is now read-only.

Commit

Permalink
ux(ThemePage): Show documentation notice when selecting
Browse files Browse the repository at this point in the history
  • Loading branch information
iakdis committed Mar 3, 2023
1 parent f565c93 commit 01745af
Show file tree
Hide file tree
Showing 3 changed files with 58 additions and 54 deletions.
2 changes: 1 addition & 1 deletion assets/l10n/app_de.arb
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@
"theme": { "type": "String" }
}
},
"rememberToVisitDocs": "'\n\nDenke daran, die Dokumentation im Themen-Repository zu besuchen, um Details zur Implementierung der richtigen Konfigurationen zu erfahren.",
"rememberToVisitDocs": "Denke daran, die Dokumentation im Themen-Repository zu besuchen, um Details zur Implementierung der richtigen Konfigurationen zu erfahren.",
"welcomeToBuhoCMS": "Willkommen bei BuhoCMS",
"welcomeToBuhoCMS_Description": "BuhoCMS ist ein lokales Content Management System für Hugo.\nErstelle oder öffne eine Webseite, installiere ein Thema, und beginne damit, neue Artikel zu erstellen.\n\nUm fortzufahren, erstelle oder öffne eine Hugo Seite.",
"hugoSiteSelected": "Ausgewählte Hugo Webseite: {path}",
Expand Down
2 changes: 1 addition & 1 deletion assets/l10n/app_en.arb
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@
"theme": { "type": "String" }
}
},
"rememberToVisitDocs": "'\n\nRemember to visit the documentation in the themes repository for details on implementing the correct configurations.",
"rememberToVisitDocs": "Remember to visit the documentation in the themes repository for details on implementing the correct configurations.",
"welcomeToBuhoCMS": "Welcome to BuhoCMS",
"welcomeToBuhoCMS_Description": "BuhoCMS is a local Content Management System for Hugo.\nCreate or open a website, install a theme, and start creating new posts.\n\nTo proceed, create or open a Hugo website.",
"hugoSiteSelected": "Hugo website selected: {path}",
Expand Down
108 changes: 56 additions & 52 deletions lib/src/pages/onboarding/theme_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ class ThemePage extends StatefulWidget {

class _ThemePageState extends State<ThemePage> {
TextStyle style = const TextStyle(fontSize: 20, fontWeight: FontWeight.bold);
TextStyle smallerStyle = const TextStyle(fontSize: 16);

int currentStep = 0;
bool canContinue = false;
Expand Down Expand Up @@ -156,60 +157,66 @@ class _ThemePageState extends State<ThemePage> {
}

Widget _selectTheme() {
return Column(
children: [
Text(AppLocalizations.of(context)!.selectATheme, style: style),
const SizedBox(height: 32),
FutureBuilder(
future: HugoThemes.findAllThemes(),
builder: (context, snapshot) {
if (snapshot.connectionState == ConnectionState.waiting) {
return const CircularProgressIndicator();
}
return Padding(
padding: const EdgeInsets.symmetric(horizontal: 32),
child: Column(
children: [
Text(AppLocalizations.of(context)!.selectATheme, style: style),
const SizedBox(height: 32),
SelectableText(AppLocalizations.of(context)!.rememberToVisitDocs,
style: smallerStyle),
const SizedBox(height: 32),
FutureBuilder(
future: HugoThemes.findAllThemes(),
builder: (context, snapshot) {
if (snapshot.connectionState == ConnectionState.waiting) {
return const CircularProgressIndicator();
}

var value = Preferences.getHugoTheme();
var buttonList = <DropdownMenuItem<String>>[];
buttonList.add(DropdownMenuItem(
value: '', child: Text(AppLocalizations.of(context)!.none)));
if (snapshot.hasData) {
if (snapshot.data!.isNotEmpty) {
buttonList.addAll(snapshot.data!.map((element) {
return DropdownMenuItem(
value: element.path,
child:
Text(element.path.split(Platform.pathSeparator).last),
);
}).toList());
} else {
var value = Preferences.getHugoTheme();
var buttonList = <DropdownMenuItem<String>>[];
buttonList.add(DropdownMenuItem(
value: '', child: Text(AppLocalizations.of(context)!.none)));
if (snapshot.hasData) {
if (snapshot.data!.isNotEmpty) {
buttonList.addAll(snapshot.data!.map((element) {
return DropdownMenuItem(
value: element.path,
child:
Text(element.path.split(Platform.pathSeparator).last),
);
}).toList());
} else {
value = '';
Preferences.setHugoTheme('');
}
}
var themeExists = false;
for (var i = 0; i < buttonList.length; i++) {
if (buttonList[i].value == value) themeExists = true;
}
if (themeExists == false) {
value = '';
Preferences.setHugoTheme('');
}
}
var themeExists = false;
for (var i = 0; i < buttonList.length; i++) {
if (buttonList[i].value == value) themeExists = true;
}
if (themeExists == false) {
value = '';
Preferences.setHugoTheme('');
}

return DropdownButton(
value: value,
items: buttonList,
onChanged: (option) async {
await Preferences.setHugoTheme(option ?? themeName);
_updateConfig();
setState(() {});
if (mounted) {
Provider.of<NavigationProvider>(context, listen: false)
.notifyAllListeners();
}
},
);
},
),
],
return DropdownButton(
value: value,
items: buttonList,
onChanged: (option) async {
await Preferences.setHugoTheme(option ?? themeName);
_updateConfig();
setState(() {});
if (mounted) {
Provider.of<NavigationProvider>(context, listen: false)
.notifyAllListeners();
}
},
);
},
),
],
),
);
}

Expand Down Expand Up @@ -376,9 +383,6 @@ class _ThemePageState extends State<ThemePage> {
text: AppLocalizations.of(context)!.nowSelectTheme(
'"${themeName.split(Platform.pathSeparator).last}"'),
),
TextSpan(
text: AppLocalizations.of(context)!
.rememberToVisitDocs),
])),
],
),
Expand Down

0 comments on commit 01745af

Please sign in to comment.