react-native-football-formation 1.0.4 → 1.0.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -6,6 +6,12 @@ A highly customizable React Native component for displaying football/soccer team
6
6
  ![TypeScript](https://img.shields.io/badge/TypeScript-5.0-blue)
7
7
  ![License](https://img.shields.io/badge/license-MIT-green)
8
8
 
9
+ ## Demo
10
+
11
+ <p align="center">
12
+ <img src="formation-demo.png" alt="Football Formation Demo" width="400" />
13
+ </p>
14
+
9
15
  ## Features
10
16
 
11
17
  ✅ **24 Supported Formations** - All major tactical formations (4-3-3, 4-2-3-1, 3-5-2, etc.)
@@ -81,6 +87,63 @@ export default function FormationScreen() {
81
87
  }
82
88
  ```
83
89
 
90
+ ### Complete Player Object Example
91
+
92
+ Here's a complete player object showing all available fields and stats:
93
+
94
+ ```tsx
95
+ const teamLineup = {
96
+ players: [
97
+ // Example 1: Player with all stats
98
+ {
99
+ playerId: "5il4uc7d941ndwjl0qu97y7dh",
100
+ matchName: "Marcelo Grohe",
101
+ shirtNumber: 43,
102
+ rating: "7.2",
103
+ position: "Goalkeeper",
104
+ positionSide: "Centre",
105
+ formationPlace: "1",
106
+ stats: [
107
+ { type: "totalSubOff", value: "1" },
108
+ { type: "goals", value: 1 },
109
+ { type: "yellowCard", value: "1" },
110
+ { type: "redCard", value: "1" },
111
+ { type: "goalAssist", value: "0" },
112
+ { type: "ownGoals", value: "1" }
113
+ ]
114
+ },
115
+ // Example 2: Player with stats array containing null values
116
+ {
117
+ playerId: "abc123",
118
+ matchName: "Lionel Messi",
119
+ shirtNumber: 10,
120
+ rating: "9.5",
121
+ position: "Forward",
122
+ positionSide: "Right",
123
+ formationPlace: "10",
124
+ stats: [
125
+ { type: "goals", value: 2 },
126
+ null,
127
+ { type: "goalAssist", value: "1" },
128
+ null,
129
+ { type: "yellowCard", value: "0" }
130
+ ]
131
+ },
132
+ // ... 9 more players with formationPlace "2" to "9", "11"
133
+ ],
134
+ formationUsed: "433" // or "4-3-3"
135
+ };
136
+
137
+ <FormationField
138
+ lineup={teamLineup}
139
+ getPlayerPhotoUrl={(playerId) =>
140
+ `https://example.com/players/${playerId}.png`
141
+ }
142
+ />
143
+ ```
144
+
145
+ **Note:** The `stats` array can contain both `PlayerStats` objects and `null` values. Null values are safely ignored.
146
+
84
147
  ### With Custom Theme
85
148
 
86
149
  ```tsx
@@ -89,6 +152,7 @@ export default function FormationScreen() {
89
152
  theme={{
90
153
  colors: {
91
154
  primary: '#FF0000',
155
+ playerName: '#FFFFFF',
92
156
  success: '#00FF00',
93
157
  warning: '#FFAA00',
94
158
  },
@@ -166,11 +230,11 @@ interface Player {
166
230
  matchName: string;
167
231
  shirtNumber: number;
168
232
  formationPlace?: string; // "1" to "11"
169
- stats: PlayerStats[] | null[];
233
+ stats: (PlayerStats | null)[]; // Array can contain PlayerStats objects or null values
170
234
  }
171
235
 
172
236
  interface PlayerStats {
173
- type: string; // "goals", "yellowCard", "redCard", "goalAssist", etc.
237
+ type: 'goals' | 'yellowCard' | 'redCard' | 'goalAssist' | 'totalSubOff' | 'ownGoals';
174
238
  value: string | number;
175
239
  }
176
240
  ```
@@ -184,6 +248,7 @@ interface FormationTheme {
184
248
  blue: string;
185
249
  white: string;
186
250
  text: string;
251
+ playerName: string;
187
252
  border: string;
188
253
  warning: string;
189
254
  success: string;
@@ -322,27 +387,47 @@ The component supports 24 different tactical formations:
322
387
 
323
388
  ## Player Statistics
324
389
 
325
- The component automatically displays player statistics when available:
390
+ The component automatically displays player statistics when available. The `stats` array can contain `PlayerStats` objects or `null` values.
391
+
392
+ ### Supported Stat Types
326
393
 
327
- - **Goals** - Football icon with count
328
- - 👟 **Assists** - Kicker icon
329
- - 🟨 **Yellow Card** - Yellow card indicator
330
- - 🟥 **Red Card** - Red card indicator
331
- - 🔄 **Substitution** - Substitution icon
332
- - ⚽🔴 **Own Goals** - Own goal icon with count
394
+ | Stat Type | Display | Description |
395
+ |-----------|---------|-------------|
396
+ | `goals` | Football icon + count | Number of goals scored |
397
+ | `goalAssist` | 👟 Kicker icon | Number of assists provided |
398
+ | `yellowCard` | 🟨 Yellow card | Yellow card received |
399
+ | `redCard` | 🟥 Red card | Red card received |
400
+ | `totalSubOff` | 🔄 Substitution icon | Player was substituted off |
401
+ | `ownGoals` | ⚽🔴 Own goal icon + count | Number of own goals |
333
402
 
334
- Statistics are extracted from the `stats` array in the player data:
403
+ ### Example Player Stats
404
+
405
+ The `stats` array can contain both stat objects and `null` values:
335
406
 
336
407
  ```typescript
337
408
  {
409
+ playerId: '1',
410
+ matchName: 'Cristiano Ronaldo',
411
+ shirtNumber: 7,
412
+ formationPlace: '9',
338
413
  stats: [
339
- { type: 'goals', value: '2' },
340
- { type: 'yellowCard', value: '1' },
341
- { type: 'goalAssist', value: '1' },
414
+ { type: 'goals', value: 1 }, // Scored 1 goal
415
+ { type: 'yellowCard', value: '1' }, // Received yellow card
416
+ { type: 'goalAssist', value: '0' }, // No assists (won't display)
417
+ { type: 'redCard', value: '1' }, // Received red card
418
+ { type: 'totalSubOff', value: '1' }, // Was substituted
419
+ { type: 'ownGoals', value: '1' }, // Scored own goal
420
+ null, // Null values are safely handled
342
421
  ]
343
422
  }
344
423
  ```
345
424
 
425
+ **Note:**
426
+ - Values can be either `string` or `number` types
427
+ - Stats with a value of `'0'` or `0` won't be displayed
428
+ - The `stats` array safely handles `null` entries
429
+ - If `stats` is empty or all values are `null`, no stats will be displayed
430
+
346
431
  ## Utilities
347
432
 
348
433
  The package exports utility functions for advanced use cases:
@@ -380,6 +465,8 @@ The package is written in TypeScript and includes full type definitions. Import
380
465
  import type {
381
466
  TeamLineup,
382
467
  Player,
468
+ PlayerStats,
469
+ PlayerStatType,
383
470
  LineupFormationPlayer,
384
471
  FormationTheme,
385
472
  FormationFieldProps,
@@ -1 +1 @@
1
- {"version":3,"file":"FormationField.d.ts","sourceRoot":"","sources":["../../src/components/FormationField.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAkB,MAAM,OAAO,CAAC;AAUvC,OAAO,EAAE,mBAAmB,EAAE,MAAM,UAAU,CAAC;;AA2K/C,wBAA0C"}
1
+ {"version":3,"file":"FormationField.d.ts","sourceRoot":"","sources":["../../src/components/FormationField.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAkB,MAAM,OAAO,CAAC;AAUvC,OAAO,EAAE,mBAAmB,EAAE,MAAM,UAAU,CAAC;;AA4K/C,wBAA0C"}
@@ -48,10 +48,11 @@ const FormationField = ({ lineup, width = screenWidth + 10, height = 395, theme:
48
48
  const lineupTransformed = (0, react_1.useMemo)(() => {
49
49
  if (!lineup)
50
50
  return [];
51
- const formation = lineup?.formationUsed?.split('').join('-') || '4-3-3';
52
- return (0, utils_1.transformLineupByFormationPlace)(lineup, formation, getPlayerPhotoUrl);
51
+ // Normalize formation: remove dashes then add them back properly
52
+ const normalizedFormation = lineup?.formationUsed?.replace(/-/g, '').split('').join('-') || '4-3-3';
53
+ return (0, utils_1.transformLineupByFormationPlace)(lineup, normalizedFormation, getPlayerPhotoUrl);
53
54
  }, [lineup, getPlayerPhotoUrl]);
54
- const formationDisplay = lineup?.formationUsed?.split('').join('-') || '4-3-3';
55
+ const formationDisplay = lineup?.formationUsed?.replace(/-/g, '').split('').join('-') || '4-3-3';
55
56
  return (<react_native_1.ImageBackground source={fieldImage} style={[
56
57
  styles.footballField,
57
58
  {
@@ -102,6 +102,7 @@ const PlayerCard = ({ player, fieldWidth, fieldHeight, theme, onPress, style, na
102
102
  }}>
103
103
  {Number(player?.ownGoals) > 1 && (<react_native_1.View style={[
104
104
  react_native_1.I18nManager.isRTL ? { paddingRight: 2 } : { paddingLeft: 2 },
105
+ { justifyContent: 'center' }
105
106
  ]}>
106
107
  <react_native_1.Text style={[
107
108
  styles.goalsText,
@@ -247,7 +248,7 @@ const PlayerCard = ({ player, fieldWidth, fieldHeight, theme, onPress, style, na
247
248
  styles.playerName,
248
249
  {
249
250
  fontSize: theme.typography.playerNameSize,
250
- color: theme.colors.text,
251
+ color: theme.colors.playerName,
251
252
  fontFamily: theme.typography.fontFamily,
252
253
  },
253
254
  nameStyle,
@@ -317,7 +318,6 @@ const styles = react_native_1.StyleSheet.create({
317
318
  },
318
319
  goalsText: {
319
320
  includeFontPadding: false,
320
- lineHeight: 13.8,
321
321
  },
322
322
  footballIcon: {},
323
323
  yellowCardWrapper: {
@@ -1 +1 @@
1
- {"version":3,"file":"defaultTheme.d.ts","sourceRoot":"","sources":["../../src/theme/defaultTheme.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAE1C;;;GAGG;AACH,eAAO,MAAM,YAAY,EAAE,cAsC1B,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,UAAU,GACrB,cAAc,OAAO,CAAC,cAAc,CAAC,KACpC,cAqBF,CAAC"}
1
+ {"version":3,"file":"defaultTheme.d.ts","sourceRoot":"","sources":["../../src/theme/defaultTheme.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAE1C;;;GAGG;AACH,eAAO,MAAM,YAAY,EAAE,cAuC1B,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,UAAU,GACrB,cAAc,OAAO,CAAC,cAAc,CAAC,KACpC,cAqBF,CAAC"}
@@ -11,6 +11,7 @@ exports.defaultTheme = {
11
11
  blue: '#2194FF',
12
12
  white: '#ffffff',
13
13
  text: '#13151F',
14
+ playerName: '#ffffff',
14
15
  border: '#96CBCB',
15
16
  warning: '#FFA500',
16
17
  success: '#34C759',
@@ -1,6 +1,10 @@
1
1
  /**
2
2
  * Type definitions for React Native Football Formation component
3
3
  */
4
+ /**
5
+ * Supported player statistics types
6
+ */
7
+ export type PlayerStatType = 'goals' | 'yellowCard' | 'redCard' | 'goalAssist' | 'totalSubOff' | 'ownGoals';
4
8
  export interface PlayerStats {
5
9
  type: string;
6
10
  value: string | number;
@@ -14,7 +18,7 @@ export interface Player {
14
18
  positionSide?: string;
15
19
  formationPosition?: string;
16
20
  formationPlace?: string;
17
- stats: PlayerStats[] | null[];
21
+ stats: (PlayerStats | null)[];
18
22
  }
19
23
  export interface TeamLineup {
20
24
  players: Player[];
@@ -1 +1 @@
1
- {"version":3,"file":"formation.types.d.ts","sourceRoot":"","sources":["../../src/types/formation.types.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,MAAM,WAAW,WAAW;IAC1B,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,GAAG,MAAM,CAAC;CACxB;AAED,MAAM,WAAW,MAAM;IACrB,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;IACjB,SAAS,EAAE,MAAM,CAAC;IAClB,WAAW,EAAE,MAAM,CAAC;IACpB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,KAAK,EAAE,WAAW,EAAE,GAAG,IAAI,EAAE,CAAC;CAC/B;AAED,MAAM,WAAW,UAAU;IACzB,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,aAAa,EAAE,MAAM,CAAC;CACvB;AAED,MAAM,WAAW,qBAAqB;IACpC,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;IACjB,SAAS,EAAE,MAAM,CAAC;IAClB,WAAW,EAAE,MAAM,CAAC;IACpB,QAAQ,EAAE,OAAO,CAAC;IAClB,YAAY,EAAE,OAAO,CAAC;IACtB,YAAY,EAAE,OAAO,CAAC;IACtB,SAAS,EAAE,OAAO,CAAC;IACnB,SAAS,EAAE,OAAO,CAAC;IACnB,QAAQ,EAAE,MAAM,CAAC;IACjB,YAAY,EAAE,OAAO,CAAC;IACtB,KAAK,EAAE,MAAM,CAAC;IACd,cAAc,EAAE,MAAM,CAAC;IACvB,KAAK,EAAE,MAAM,CAAC;IACd,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IACnB,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;CACpB;AAED;;GAEG;AACH,MAAM,MAAM,aAAa,GACrB,OAAO,GACP,WAAW,GACX,OAAO,GACP,OAAO,GACP,SAAS,GACT,SAAS,GACT,SAAS,GACT,SAAS,GACT,OAAO,GACP,OAAO,GACP,OAAO,GACP,OAAO,GACP,SAAS,GACT,SAAS,GACT,SAAS,GACT,SAAS,GACT,SAAS,GACT,QAAQ,GACR,SAAS,GACT,SAAS,GACT,SAAS,GACT,SAAS,GACT,SAAS,CAAC;AAEd;;GAEG;AACH,MAAM,WAAW,eAAe;IAC9B,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;CACX;AAED;;GAEG;AACH,MAAM,MAAM,oBAAoB,GAAG;IACjC,CAAC,GAAG,EAAE,MAAM,GAAG,eAAe,CAAC;CAChC,CAAC"}
1
+ {"version":3,"file":"formation.types.d.ts","sourceRoot":"","sources":["../../src/types/formation.types.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH;;GAEG;AACH,MAAM,MAAM,cAAc,GACtB,OAAO,GACP,YAAY,GACZ,SAAS,GACT,YAAY,GACZ,aAAa,GACb,UAAU,CAAC;AAEf,MAAM,WAAW,WAAW;IAC1B,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,GAAG,MAAM,CAAC;CACxB;AAED,MAAM,WAAW,MAAM;IACrB,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;IACjB,SAAS,EAAE,MAAM,CAAC;IAClB,WAAW,EAAE,MAAM,CAAC;IACpB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,KAAK,EAAE,CA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FormationThemeColors {
6
6
  blue: string;
7
7
  white: string;
8
8
  text: string;
9
+ playerName?: string;
9
10
  border: string;
10
11
  warning: string;
11
12
  success: string;
@@ -1 +1 @@
1
- {"version":3,"file":"theme.types.d.ts","sourceRoot":"","sources":["../../src/types/theme.types.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,MAAM,WAAW,oBAAoB;IACnC,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,MAAM,CAAC;IACjB,cAAc,EAAE,MAAM,CAAC;CACxB;AAED,MAAM,WAAW,qBAAqB;IACpC,eAAe,EAAE,MAAM,CAAC;IACxB,gBAAgB,EAAE,MAAM,CAAC;IACzB,eAAe,EAAE,MAAM,CAAC;IACxB,gBAAgB,EAAE,MAAM,CAAC;IACzB,QAAQ,EAAE,MAAM,CAAC;IACjB,aAAa,EAAE,MAAM,CAAC;IACtB,WAAW,EAAE,MAAM,CAAC;CACrB;AAED,MAAM,WAAW,wBAAwB;IACvC,cAAc,EAAE,MAAM,CAAC;IACvB,aAAa,EAAE,MAAM,CAAC;IACtB,gBAAgB,EAAE,MAAM,CAAC;IACzB,aAAa,EAAE,MAAM,CAAC;IACtB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB;AAED,MAAM,WAAW,0BAA0B;IACzC,WAAW,EAAE,MAAM,CAAC;IACpB,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,MAAM,CAAC;CACd;AAED,MAAM,WAAW,cAAc;IAC7B,MAAM,EAAE,oBAAoB,CAAC;IAC7B,OAAO,EAAE,qBAAqB,CAAC;IAC/B,UAAU,EAA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rC,YAAY,EAAE,0BAA0B,CAAC;CAC1C"}
Binary file
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-football-formation",
3
- "version": "1.0.4",
3
+ "version": "1.0.7",
4
4
  "description": "A highly customizable React Native component for displaying football/soccer team formations with player positions and match statistics",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -12,7 +12,8 @@
12
12
  "dist",
13
13
  "src",
14
14
  "README.md",
15
- "LICENSE"
15
+ "LICENSE",
16
+ "formation-demo.png"
16
17
  ],
17
18
  "scripts": {
18
19
  "build": "tsc && npm run copy-assets",
@@ -44,11 +44,12 @@ const FormationField: React.FC<FormationFieldProps> = ({
44
44
  const lineupTransformed = useMemo(() => {
45
45
  if (!lineup) return [];
46
46
 
47
- const formation = lineup?.formationUsed?.split('').join('-') || '4-3-3';
48
- return transformLineupByFormationPlace(lineup, formation, getPlayerPhotoUrl);
47
+ // Normalize formation: remove dashes then add them back properly
48
+ const normalizedFormation = lineup?.formationUsed?.replace(/-/g, '').split('').join('-') || '4-3-3';
49
+ return transformLineupByFormationPlace(lineup, normalizedFormation, getPlayerPhotoUrl);
49
50
  }, [lineup, getPlayerPhotoUrl]);
50
51
 
51
- const formationDisplay = lineup?.formationUsed?.split('').join('-') || '4-3-3';
52
+ const formationDisplay = lineup?.formationUsed?.replace(/-/g, '').split('').join('-') || '4-3-3';
52
53
 
53
54
  return (
54
55
  <ImageBackground
@@ -143,6 +143,7 @@ const PlayerCard: React.FC<PlayerCardProps> = ({
143
143
  <View
144
144
  style={[
145
145
  I18nManager.isRTL ? { paddingRight: 2 } : { paddingLeft: 2 },
146
+ {justifyContent: 'center'}
146
147
  ]}>
147
148
  <Text
148
149
  style={[
@@ -327,7 +328,7 @@ const PlayerCard: React.FC<PlayerCardProps> = ({
327
328
  styles.playerName,
328
329
  {
329
330
  fontSize: theme.typography.playerNameSize,
330
- color: theme.colors.text,
331
+ color: theme.colors.playerName,
331
332
  fontFamily: theme.typography.fontFamily,
332
333
  },
333
334
  nameStyle,
@@ -403,7 +404,6 @@ const styles = StyleSheet.create({
403
404
  },
404
405
  goalsText: {
405
406
  includeFontPadding: false,
406
- lineHeight: 13.8,
407
407
  },
408
408
  footballIcon: {},
409
409
  yellowCardWrapper: {
@@ -10,6 +10,7 @@ export const defaultTheme: FormationTheme = {
10
10
  blue: '#2194FF',
11
11
  white: '#ffffff',
12
12
  text: '#13151F',
13
+ playerName: '#ffffff',
13
14
  border: '#96CBCB',
14
15
  warning: '#FFA500',
15
16
  success: '#34C759',
@@ -2,8 +2,19 @@
2
2
  * Type definitions for React Native Football Formation component
3
3
  */
4
4
 
5
+ /**
6
+ * Supported player statistics types
7
+ */
8
+ export type PlayerStatType =
9
+ | 'goals'
10
+ | 'yellowCard'
11
+ | 'redCard'
12
+ | 'goalAssist'
13
+ | 'totalSubOff'
14
+ | 'ownGoals';
15
+
5
16
  export interface PlayerStats {
6
- type: string;
17
+ type: string; // Accepts any string, but PlayerStatType provides supported values
7
18
  value: string | number;
8
19
  }
9
20
 
@@ -16,7 +27,7 @@ export interface Player {
16
27
  positionSide?: string;
17
28
  formationPosition?: string;
18
29
  formationPlace?: string;
19
- stats: PlayerStats[] | null[];
30
+ stats: (PlayerStats | null)[]; // Array can contain PlayerStats objects or null values
20
31
  }
21
32
 
22
33
  export interface TeamLineup {
@@ -7,6 +7,7 @@ export interface FormationThemeColors {
7
7
  blue: string;
8
8
  white: string;
9
9
  text: string;
10
+ playerName?: string;
10
11
  border: string;
11
12
  warning: string;
12
13
  success: string;