mirror of
				https://github.com/Nioux/AideDeJeu.git
				synced 2025-10-30 23:16:09 +00:00 
			
		
		
		
	Localisations
This commit is contained in:
		
							parent
							
								
									512adf99d8
								
							
						
					
					
						commit
						bc8bb68a28
					
				
					 15 changed files with 1002 additions and 73 deletions
				
			
		|  | @ -1,6 +1,7 @@ | |||
| import 'dart:io'; | ||||
| 
 | ||||
| import 'package:aidedejeu_flutter/models/items.dart'; | ||||
| import 'package:flutter/cupertino.dart'; | ||||
| import 'package:flutter/services.dart'; | ||||
| import 'package:path/path.dart'; | ||||
| import 'package:sqflite/sqflite.dart'; | ||||
|  | @ -40,7 +41,7 @@ Future<Database> getDatabaseInstance() async { | |||
|   return await openDatabase(path, readOnly: true); | ||||
| } | ||||
| 
 | ||||
| Future<Item> getItemWithId(String id) async { | ||||
| Future<Item> getItemWithId(BuildContext context, String id) async { | ||||
|   print("getItemWithId " + id); | ||||
|   final db = await database; | ||||
|   var response = await db.query( | ||||
|  | @ -51,10 +52,10 @@ Future<Item> getItemWithId(String id) async { | |||
|   if (response.isEmpty) { | ||||
|     print("Id not found"); | ||||
|   } | ||||
|   return response.isNotEmpty ? itemFromMap(response.first) : null; | ||||
|   return response.isNotEmpty ? itemFromMap(context, response.first) : null; | ||||
| } | ||||
| 
 | ||||
| Future<Item> loadChildrenItems(Item item, List<Filter> filters) async { | ||||
| Future<Item> loadChildrenItems(BuildContext context, Item item, List<Filter> filters) async { | ||||
|   print("getChildrenItems " + (item?.itemType ?? "")); | ||||
|   if (item.itemType.endsWith("Items")) { | ||||
|     String itemType = | ||||
|  | @ -86,13 +87,13 @@ Future<Item> loadChildrenItems(Item item, List<Filter> filters) async { | |||
|       print("Children not found"); | ||||
|     } | ||||
|     item.children = response.isNotEmpty | ||||
|         ? itemsFromMapList(response) | ||||
|         ? itemsFromMapList(context, response) | ||||
|         : null; | ||||
|   } | ||||
|   return item; | ||||
| } | ||||
| 
 | ||||
| Future<List<RaceItem>> loadRaces() async { | ||||
| Future<List<RaceItem>> loadRaces(BuildContext context) async { | ||||
|   final db = await database; | ||||
|   var response = await db.query( | ||||
|       "Items", | ||||
|  | @ -100,12 +101,12 @@ Future<List<RaceItem>> loadRaces() async { | |||
|       orderBy: "NormalizedName" | ||||
|   ); | ||||
|   if (response.isNotEmpty) { | ||||
|     return itemsFromMapList(response); | ||||
|     return itemsFromMapList(context, response); | ||||
|   } | ||||
|   return null; | ||||
| } | ||||
| 
 | ||||
| Future<List<SubRaceItem>> loadSubRaces(RaceItem race) async { | ||||
| Future<List<SubRaceItem>> loadSubRaces(BuildContext context, RaceItem race) async { | ||||
|   final db = await database; | ||||
|   var response = await db.query( | ||||
|       "Items", | ||||
|  | @ -114,12 +115,12 @@ Future<List<SubRaceItem>> loadSubRaces(RaceItem race) async { | |||
|       orderBy: "NormalizedName" | ||||
|   ); | ||||
|   if (response.isNotEmpty) { | ||||
|     return itemsFromMapList(response); | ||||
|     return itemsFromMapList(context, response); | ||||
|   } | ||||
|   return null; | ||||
| } | ||||
| 
 | ||||
| Future<List<T>> loadTypedItems<T extends Item>({String itemType, Item item = null}) async { | ||||
| Future<List<T>> loadTypedItems<T extends Item>(BuildContext context, {String itemType, Item item = null}) async { | ||||
|   final db = await database; | ||||
|   var response = await db.query( | ||||
|       "Items", | ||||
|  | @ -128,16 +129,16 @@ Future<List<T>> loadTypedItems<T extends Item>({String itemType, Item item = nul | |||
|       orderBy: "NormalizedName" | ||||
|   ); | ||||
|   if (response.isNotEmpty) { | ||||
|     return itemsFromMapList(response); | ||||
|     return itemsFromMapList(context, response); | ||||
|   } | ||||
|   return null; | ||||
| } | ||||
| 
 | ||||
| Future<List<BackgroundItem>> loadBackgrounds() async { | ||||
|   return loadTypedItems<BackgroundItem>(itemType: "BackgroundItem"); | ||||
| Future<List<BackgroundItem>> loadBackgrounds(BuildContext context) async { | ||||
|   return loadTypedItems<BackgroundItem>(context, itemType: "BackgroundItem"); | ||||
| } | ||||
| 
 | ||||
| Future<List<SubBackgroundItem>> loadSubBackgrounds(Item item) async { | ||||
|   return loadTypedItems<SubBackgroundItem>(itemType: "SubBackgroundItem", item: item); | ||||
| Future<List<SubBackgroundItem>> loadSubBackgrounds(BuildContext context, Item item) async { | ||||
|   return loadTypedItems<SubBackgroundItem>(context, itemType: "SubBackgroundItem", item: item); | ||||
| } | ||||
| 
 | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Yan Maniez
						Yan Maniez