-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor(lib-interfaces): refactor some widgets ds-12
- Loading branch information
Showing
9 changed files
with
225 additions
and
184 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,10 @@ | ||
export "widgets/app_about_list_tile.dart"; | ||
export "widgets/common_network_image.dart"; | ||
export "widgets/custom_camera.dart"; | ||
export "widgets/email_text_field.dart"; | ||
export "widgets/image_from_x_file.dart"; | ||
export "widgets/list_tile/app_about_list_tile.dart"; | ||
export "widgets/list_tile/locale_list_tile.dart"; | ||
export "widgets/list_tile/theme_list_tile.dart"; | ||
export "widgets/media/common_network_image.dart"; | ||
export "widgets/media/custom_camera.dart"; | ||
export "widgets/media/image_from_x_file.dart"; | ||
export "widgets/password_text_field.dart"; | ||
export "widgets/sized_error_widget.dart"; | ||
export "widgets/story_card.dart"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
47 changes: 47 additions & 0 deletions
47
lib/interfaces/libs/widgets/list_tile/locale_list_tile.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
import "package:flutter/material.dart"; | ||
import "package:provider/provider.dart"; | ||
|
||
import "package:dicoding_story_fl/interfaces/libs/l10n.dart"; | ||
import "package:dicoding_story_fl/interfaces/libs/providers.dart"; | ||
|
||
class LocaleListTile extends StatelessWidget { | ||
const LocaleListTile({super.key}); | ||
|
||
@override | ||
Widget build(BuildContext context) { | ||
final appL10n = AppL10n.of(context)!; | ||
|
||
return ListTile( | ||
leading: const Icon(Icons.language_outlined), | ||
title: Text(appL10n.language), | ||
trailing: Builder(builder: (context) { | ||
final localeProvider = context.watch<LocaleProvider>(); | ||
|
||
String localeString(String localeString) { | ||
return switch (localeString) { | ||
"en" => "English", | ||
"id" => "Bahasa Indonesia", | ||
_ => appL10n.flThemeMode(ThemeMode.system.name), | ||
}; | ||
} | ||
|
||
return DropdownButton<Locale?>( | ||
value: localeProvider.value, | ||
onChanged: (value) => localeProvider.value = value, | ||
items: [ | ||
DropdownMenuItem( | ||
value: null, | ||
child: Text(localeString("system")), | ||
), | ||
...AppL10n.supportedLocales.map((e) { | ||
return DropdownMenuItem( | ||
value: e, | ||
child: Text(localeString("$e")), | ||
); | ||
}) | ||
], | ||
); | ||
}), | ||
); | ||
} | ||
} |
47 changes: 47 additions & 0 deletions
47
lib/interfaces/libs/widgets/list_tile/theme_list_tile.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
import "package:flutter/material.dart"; | ||
import "package:provider/provider.dart"; | ||
|
||
import "package:dicoding_story_fl/interfaces/libs/l10n.dart"; | ||
import "package:dicoding_story_fl/interfaces/libs/providers.dart"; | ||
|
||
class ThemeListTile extends StatelessWidget { | ||
const ThemeListTile({super.key}); | ||
|
||
@override | ||
Widget build(BuildContext context) { | ||
final appL10n = AppL10n.of(context)!; | ||
|
||
return ListTile( | ||
leading: const Icon(Icons.color_lens_outlined), | ||
title: Text(appL10n.appTheme), | ||
trailing: Builder(builder: (context) { | ||
final themeModeProvider = context.watch<ThemeModeProvider>(); | ||
|
||
final icons = ThemeMode.values.map((e) { | ||
return switch (e) { | ||
ThemeMode.system => Icons.settings_outlined, | ||
ThemeMode.light => Icons.light_mode_outlined, | ||
ThemeMode.dark => Icons.dark_mode_outlined, | ||
}; | ||
}).toList(); | ||
|
||
return DropdownButton<ThemeMode>( | ||
value: themeModeProvider.value, | ||
items: ThemeMode.values.map((e) { | ||
return DropdownMenuItem<ThemeMode>( | ||
value: e, | ||
child: Row( | ||
children: [ | ||
Icon(icons[e.index]), | ||
const SizedBox(width: 8.0), | ||
Text(appL10n.flThemeMode(e.name)), | ||
], | ||
), | ||
); | ||
}).toList(), | ||
onChanged: (value) => themeModeProvider.value = value!, | ||
); | ||
}), | ||
); | ||
} | ||
} |
File renamed without changes.
Oops, something went wrong.