@ -172,7 +172,7 @@ struct SelectablePlayerListView: View {
}
. scrollDismissesKeyboard ( . immediately )
. navigationBarBackButtonHidden ( searchViewModel . allowMultipleSelection )
. toolbarBackground ( . visible , for : . bottomBar )
// . t o o l b a r B a c k g r o u n d ( . v i s i b l e , f o r : . b o t t o m B a r )
// . t o o l b a r R o l e ( s e a r c h V i e w M o d e l . a l l o w M u l t i p l e S e l e c t i o n ? . n a v i g a t i o n S t a c k : . e d i t o r )
. interactiveDismissDisabled ( searchViewModel . selectedPlayers . isEmpty = = false )
. navigationTitle ( searchViewModel . label ( forDataSet : searchViewModel . dataSet ) )
@ -358,13 +358,109 @@ struct MySearchView: View {
@ ViewBuilder
var playersView : some View {
let showProgression = true
let showFemaleInMaleAssimilation = searchViewModel . showFemaleInMaleAssimilation
if searchViewModel . allowMultipleSelection {
List ( selection : $ searchViewModel . selectedPlayers ) {
if searchViewModel . filterSelectionEnabled {
let array = Array ( searchViewModel . selectedPlayers )
Section {
ForEach ( array ) { player in
ImportedPlayerView ( player : player , showFemaleInMaleAssimilation : searchViewModel . showFemaleInMaleAssimilation , showProgression : true )
let index : Int ? = nil
VStack ( alignment : . leading ) {
HStack {
if player . isAnonymous ( ) {
Text ( " Joueur Anonyme " )
} else {
Text ( player . getLastName ( ) . capitalized )
Text ( player . getFirstName ( ) . capitalized )
}
if index = = nil {
Text ( player . male ? " ♂︎ " : " ♀︎ " )
}
Spacer ( )
if let index {
HStack ( alignment : . top , spacing : 0 ) {
Text ( index . formatted ( ) )
. foregroundStyle ( . secondary )
. font ( . title3 )
Text ( index . ordinalFormattedSuffix ( ) )
. foregroundStyle ( . secondary )
. font ( . caption )
}
}
}
. font ( . title3 )
. lineLimit ( 1 )
HStack {
HStack ( alignment : . top , spacing : 0 ) {
Text ( player . formattedRank ( ) ) . italic ( player . isAssimilated )
. font ( . title3 )
. background {
if player . isNotFromCurrentDate ( ) {
UnderlineView ( )
}
}
if let rank = player . getRank ( ) {
Text ( rank . ordinalFormattedSuffix ( ) ) . italic ( player . isAssimilated )
. font ( . caption )
}
}
if showProgression , player . getProgression ( ) != 0 {
HStack ( alignment : . top , spacing : 2 ) {
Text ( " ( " )
Text ( player . getProgression ( ) . formatted ( . number . sign ( strategy : . always ( ) ) ) )
. foregroundStyle ( player . getProgressionColor ( progression : player . getProgression ( ) ) )
Text ( " ) " )
} . font ( . title3 )
}
if let pts = player . getPoints ( ) , pts > 0 {
HStack ( alignment : . lastTextBaseline , spacing : 0 ) {
Text ( pts . formatted ( ) ) . font ( . title3 )
Text ( " pts " ) . font ( . caption )
}
}
if let tournamentPlayed = player . tournamentPlayed , tournamentPlayed > 0 {
HStack ( alignment : . lastTextBaseline , spacing : 0 ) {
Text ( tournamentPlayed . formatted ( ) ) . font ( . title3 )
Text ( " tournoi " + tournamentPlayed . pluralSuffix ) . font ( . caption )
}
}
}
. lineLimit ( 1 )
if showFemaleInMaleAssimilation , let assimilatedAsMaleRank = player . getAssimilatedAsMaleRank ( ) {
HStack ( alignment : . top , spacing : 2 ) {
Text ( " ( " )
Text ( assimilatedAsMaleRank . formatted ( ) )
VStack ( alignment : . leading , spacing : 0 ) {
Text ( " équivalence " )
Text ( " messieurs " )
}
. font ( . caption )
Text ( " ) " ) . font ( . title3 )
}
}
HStack {
Text ( player . formattedLicense ( ) )
if let computedAge = player . computedAge {
Text ( computedAge . formatted ( ) + " ans " )
}
}
. font ( . caption )
if let clubName = player . clubName {
Text ( clubName )
. font ( . caption )
}
if let ligueName = player . ligueName {
Text ( ligueName )
. font ( . caption )
}
}
}
. onDelete { indexSet in
for index in indexSet {
@ -379,7 +475,102 @@ struct MySearchView: View {
} else {
Section {
ForEach ( players , id : \ . self ) { player in
ImportedPlayerView ( player : player , index : nil , showFemaleInMaleAssimilation : searchViewModel . showFemaleInMaleAssimilation , showProgression : true )
let index : Int ? = nil
VStack ( alignment : . leading ) {
HStack {
if player . isAnonymous ( ) {
Text ( " Joueur Anonyme " )
} else {
Text ( player . getLastName ( ) . capitalized )
Text ( player . getFirstName ( ) . capitalized )
}
if index = = nil {
Text ( player . male ? " ♂︎ " : " ♀︎ " )
}
Spacer ( )
if let index {
HStack ( alignment : . top , spacing : 0 ) {
Text ( index . formatted ( ) )
. foregroundStyle ( . secondary )
. font ( . title3 )
Text ( index . ordinalFormattedSuffix ( ) )
. foregroundStyle ( . secondary )
. font ( . caption )
}
}
}
. font ( . title3 )
. lineLimit ( 1 )
HStack {
HStack ( alignment : . top , spacing : 0 ) {
Text ( player . formattedRank ( ) ) . italic ( player . isAssimilated )
. font ( . title3 )
. background {
if player . isNotFromCurrentDate ( ) {
UnderlineView ( )
}
}
if let rank = player . getRank ( ) {
Text ( rank . ordinalFormattedSuffix ( ) ) . italic ( player . isAssimilated )
. font ( . caption )
}
}
if showProgression , player . getProgression ( ) != 0 {
HStack ( alignment : . top , spacing : 2 ) {
Text ( " ( " )
Text ( player . getProgression ( ) . formatted ( . number . sign ( strategy : . always ( ) ) ) )
. foregroundStyle ( player . getProgressionColor ( progression : player . getProgression ( ) ) )
Text ( " ) " )
} . font ( . title3 )
}
if let pts = player . getPoints ( ) , pts > 0 {
HStack ( alignment : . lastTextBaseline , spacing : 0 ) {
Text ( pts . formatted ( ) ) . font ( . title3 )
Text ( " pts " ) . font ( . caption )
}
}
if let tournamentPlayed = player . tournamentPlayed , tournamentPlayed > 0 {
HStack ( alignment : . lastTextBaseline , spacing : 0 ) {
Text ( tournamentPlayed . formatted ( ) ) . font ( . title3 )
Text ( " tournoi " + tournamentPlayed . pluralSuffix ) . font ( . caption )
}
}
}
. lineLimit ( 1 )
if showFemaleInMaleAssimilation , let assimilatedAsMaleRank = player . getAssimilatedAsMaleRank ( ) {
HStack ( alignment : . top , spacing : 2 ) {
Text ( " ( " )
Text ( assimilatedAsMaleRank . formatted ( ) )
VStack ( alignment : . leading , spacing : 0 ) {
Text ( " équivalence " )
Text ( " messieurs " )
}
. font ( . caption )
Text ( " ) " ) . font ( . title3 )
}
}
HStack {
Text ( player . formattedLicense ( ) )
if let computedAge = player . computedAge {
Text ( computedAge . formatted ( ) + " ans " )
}
}
. font ( . caption )
if let clubName = player . clubName {
Text ( clubName )
. font ( . caption )
}
if let ligueName = player . ligueName {
Text ( ligueName )
. font ( . caption )
}
}
}
} header : {
if players . isEmpty = = false {
@ -395,10 +586,105 @@ struct MySearchView: View {
if searchViewModel . allowSingleSelection {
Section {
ForEach ( players ) { player in
let index : Int ? = nil
Button {
searchViewModel . selectedPlayers . insert ( player )
} label : {
ImportedPlayerView ( player : player , showFemaleInMaleAssimilation : searchViewModel . showFemaleInMaleAssimilation , showProgression : true )
VStack ( alignment : . leading ) {
HStack {
if player . isAnonymous ( ) {
Text ( " Joueur Anonyme " )
} else {
Text ( player . getLastName ( ) . capitalized )
Text ( player . getFirstName ( ) . capitalized )
}
if index = = nil {
Text ( player . male ? " ♂︎ " : " ♀︎ " )
}
Spacer ( )
if let index {
HStack ( alignment : . top , spacing : 0 ) {
Text ( index . formatted ( ) )
. foregroundStyle ( . secondary )
. font ( . title3 )
Text ( index . ordinalFormattedSuffix ( ) )
. foregroundStyle ( . secondary )
. font ( . caption )
}
}
}
. font ( . title3 )
. lineLimit ( 1 )
HStack {
HStack ( alignment : . top , spacing : 0 ) {
Text ( player . formattedRank ( ) ) . italic ( player . isAssimilated )
. font ( . title3 )
. background {
if player . isNotFromCurrentDate ( ) {
UnderlineView ( )
}
}
if let rank = player . getRank ( ) {
Text ( rank . ordinalFormattedSuffix ( ) ) . italic ( player . isAssimilated )
. font ( . caption )
}
}
if showProgression , player . getProgression ( ) != 0 {
HStack ( alignment : . top , spacing : 2 ) {
Text ( " ( " )
Text ( player . getProgression ( ) . formatted ( . number . sign ( strategy : . always ( ) ) ) )
. foregroundStyle ( player . getProgressionColor ( progression : player . getProgression ( ) ) )
Text ( " ) " )
} . font ( . title3 )
}
if let pts = player . getPoints ( ) , pts > 0 {
HStack ( alignment : . lastTextBaseline , spacing : 0 ) {
Text ( pts . formatted ( ) ) . font ( . title3 )
Text ( " pts " ) . font ( . caption )
}
}
if let tournamentPlayed = player . tournamentPlayed , tournamentPlayed > 0 {
HStack ( alignment : . lastTextBaseline , spacing : 0 ) {
Text ( tournamentPlayed . formatted ( ) ) . font ( . title3 )
Text ( " tournoi " + tournamentPlayed . pluralSuffix ) . font ( . caption )
}
}
}
. lineLimit ( 1 )
if showFemaleInMaleAssimilation , let assimilatedAsMaleRank = player . getAssimilatedAsMaleRank ( ) {
HStack ( alignment : . top , spacing : 2 ) {
Text ( " ( " )
Text ( assimilatedAsMaleRank . formatted ( ) )
VStack ( alignment : . leading , spacing : 0 ) {
Text ( " équivalence " )
Text ( " messieurs " )
}
. font ( . caption )
Text ( " ) " ) . font ( . title3 )
}
}
HStack {
Text ( player . formattedLicense ( ) )
if let computedAge = player . computedAge {
Text ( computedAge . formatted ( ) + " ans " )
}
}
. font ( . caption )
if let clubName = player . clubName {
Text ( clubName )
. font ( . caption )
}
if let ligueName = player . ligueName {
Text ( ligueName )
. font ( . caption )
}
}
}
. buttonStyle ( . plain )
}
@ -410,9 +696,104 @@ struct MySearchView: View {
. id ( UUID ( ) )
} else {
Section {
ForEach ( players . indices , id : \ . self ) { index in
let player = players [ index ]
ImportedPlayerView ( player : player , index : searchViewModel . showIndex ( ) ? ( index + 1 ) : nil , showFemaleInMaleAssimilation : searchViewModel . showFemaleInMaleAssimilation , showProgression : true )
ForEach ( players . indices , id : \ . self ) { playerIndex in
let player = players [ playerIndex ]
let index : Int ? = searchViewModel . showIndex ( ) ? ( playerIndex + 1 ) : nil
VStack ( alignment : . leading ) {
HStack {
if player . isAnonymous ( ) {
Text ( " Joueur Anonyme " )
} else {
Text ( player . getLastName ( ) . capitalized )
Text ( player . getFirstName ( ) . capitalized )
}
if index = = nil {
Text ( player . male ? " ♂︎ " : " ♀︎ " )
}
Spacer ( )
if let index {
HStack ( alignment : . top , spacing : 0 ) {
Text ( index . formatted ( ) )
. foregroundStyle ( . secondary )
. font ( . title3 )
Text ( index . ordinalFormattedSuffix ( ) )
. foregroundStyle ( . secondary )
. font ( . caption )
}
}
}
. font ( . title3 )
. lineLimit ( 1 )
HStack {
HStack ( alignment : . top , spacing : 0 ) {
Text ( player . formattedRank ( ) ) . italic ( player . isAssimilated )
. font ( . title3 )
. background {
if player . isNotFromCurrentDate ( ) {
UnderlineView ( )
}
}
if let rank = player . getRank ( ) {
Text ( rank . ordinalFormattedSuffix ( ) ) . italic ( player . isAssimilated )
. font ( . caption )
}
}
if showProgression , player . getProgression ( ) != 0 {
HStack ( alignment : . top , spacing : 2 ) {
Text ( " ( " )
Text ( player . getProgression ( ) . formatted ( . number . sign ( strategy : . always ( ) ) ) )
. foregroundStyle ( player . getProgressionColor ( progression : player . getProgression ( ) ) )
Text ( " ) " )
} . font ( . title3 )
}
if let pts = player . getPoints ( ) , pts > 0 {
HStack ( alignment : . lastTextBaseline , spacing : 0 ) {
Text ( pts . formatted ( ) ) . font ( . title3 )
Text ( " pts " ) . font ( . caption )
}
}
if let tournamentPlayed = player . tournamentPlayed , tournamentPlayed > 0 {
HStack ( alignment : . lastTextBaseline , spacing : 0 ) {
Text ( tournamentPlayed . formatted ( ) ) . font ( . title3 )
Text ( " tournoi " + tournamentPlayed . pluralSuffix ) . font ( . caption )
}
}
}
. lineLimit ( 1 )
if showFemaleInMaleAssimilation , let assimilatedAsMaleRank = player . getAssimilatedAsMaleRank ( ) {
HStack ( alignment : . top , spacing : 2 ) {
Text ( " ( " )
Text ( assimilatedAsMaleRank . formatted ( ) )
VStack ( alignment : . leading , spacing : 0 ) {
Text ( " équivalence " )
Text ( " messieurs " )
}
. font ( . caption )
Text ( " ) " ) . font ( . title3 )
}
}
HStack {
Text ( player . formattedLicense ( ) )
if let computedAge = player . computedAge {
Text ( computedAge . formatted ( ) + " ans " )
}
}
. font ( . caption )
if let clubName = player . clubName {
Text ( clubName )
. font ( . caption )
}
if let ligueName = player . ligueName {
Text ( ligueName )
. font ( . caption )
}
}
}
} header : {
if players . isEmpty = = false {
@ -423,19 +804,205 @@ struct MySearchView: View {
}
} else {
Section {
ForEach ( players . indices , id : \ . self ) { index in
let player = players [ index ]
ForEach ( players . indices , id : \ . self ) { playerIndex in
let player = players [ playerIndex ]
let index : Int ? = searchViewModel . showIndex ( ) ? ( playerIndex + 1 ) : nil
if searchViewModel . allowSingleSelection {
Button {
searchViewModel . selectedPlayers . insert ( player )
} label : {
ImportedPlayerView ( player : player , index : searchViewModel . showIndex ( ) ? ( index + 1 ) : nil , showFemaleInMaleAssimilation : searchViewModel . showFemaleInMaleAssimilation , showProgression : true )
. contentShape ( Rectangle ( ) )
VStack ( alignment : . leading ) {
HStack {
if player . isAnonymous ( ) {
Text ( " Joueur Anonyme " )
} else {
Text ( player . getLastName ( ) . capitalized )
Text ( player . getFirstName ( ) . capitalized )
}
if index = = nil {
Text ( player . male ? " ♂︎ " : " ♀︎ " )
}
Spacer ( )
if let index {
HStack ( alignment : . top , spacing : 0 ) {
Text ( index . formatted ( ) )
. foregroundStyle ( . secondary )
. font ( . title3 )
Text ( index . ordinalFormattedSuffix ( ) )
. foregroundStyle ( . secondary )
. font ( . caption )
}
}
}
. font ( . title3 )
. lineLimit ( 1 )
HStack {
HStack ( alignment : . top , spacing : 0 ) {
Text ( player . formattedRank ( ) ) . italic ( player . isAssimilated )
. font ( . title3 )
. background {
if player . isNotFromCurrentDate ( ) {
UnderlineView ( )
}
}
if let rank = player . getRank ( ) {
Text ( rank . ordinalFormattedSuffix ( ) ) . italic ( player . isAssimilated )
. font ( . caption )
}
}
if showProgression , player . getProgression ( ) != 0 {
HStack ( alignment : . top , spacing : 2 ) {
Text ( " ( " )
Text ( player . getProgression ( ) . formatted ( . number . sign ( strategy : . always ( ) ) ) )
. foregroundStyle ( player . getProgressionColor ( progression : player . getProgression ( ) ) )
Text ( " ) " )
} . font ( . title3 )
}
if let pts = player . getPoints ( ) , pts > 0 {
HStack ( alignment : . lastTextBaseline , spacing : 0 ) {
Text ( pts . formatted ( ) ) . font ( . title3 )
Text ( " pts " ) . font ( . caption )
}
}
if let tournamentPlayed = player . tournamentPlayed , tournamentPlayed > 0 {
HStack ( alignment : . lastTextBaseline , spacing : 0 ) {
Text ( tournamentPlayed . formatted ( ) ) . font ( . title3 )
Text ( " tournoi " + tournamentPlayed . pluralSuffix ) . font ( . caption )
}
}
}
. lineLimit ( 1 )
if showFemaleInMaleAssimilation , let assimilatedAsMaleRank = player . getAssimilatedAsMaleRank ( ) {
HStack ( alignment : . top , spacing : 2 ) {
Text ( " ( " )
Text ( assimilatedAsMaleRank . formatted ( ) )
VStack ( alignment : . leading , spacing : 0 ) {
Text ( " équivalence " )
Text ( " messieurs " )
}
. font ( . caption )
Text ( " ) " ) . font ( . title3 )
}
}
HStack {
Text ( player . formattedLicense ( ) )
if let computedAge = player . computedAge {
Text ( computedAge . formatted ( ) + " ans " )
}
}
. font ( . caption )
if let clubName = player . clubName {
Text ( clubName )
. font ( . caption )
}
if let ligueName = player . ligueName {
Text ( ligueName )
. font ( . caption )
}
}
}
. frame ( maxWidth : . infinity )
. buttonStyle ( . plain )
} else {
ImportedPlayerView ( player : player , index : searchViewModel . showIndex ( ) ? ( index + 1 ) : nil , showFemaleInMaleAssimilation : searchViewModel . showFemaleInMaleAssimilation , showProgression : true )
VStack ( alignment : . leading ) {
HStack {
if player . isAnonymous ( ) {
Text ( " Joueur Anonyme " )
} else {
Text ( player . getLastName ( ) . capitalized )
Text ( player . getFirstName ( ) . capitalized )
}
if index = = nil {
Text ( player . male ? " ♂︎ " : " ♀︎ " )
}
Spacer ( )
if let index {
HStack ( alignment : . top , spacing : 0 ) {
Text ( index . formatted ( ) )
. foregroundStyle ( . secondary )
. font ( . title3 )
Text ( index . ordinalFormattedSuffix ( ) )
. foregroundStyle ( . secondary )
. font ( . caption )
}
}
}
. font ( . title3 )
. lineLimit ( 1 )
HStack {
HStack ( alignment : . top , spacing : 0 ) {
Text ( player . formattedRank ( ) ) . italic ( player . isAssimilated )
. font ( . title3 )
. background {
if player . isNotFromCurrentDate ( ) {
UnderlineView ( )
}
}
if let rank = player . getRank ( ) {
Text ( rank . ordinalFormattedSuffix ( ) ) . italic ( player . isAssimilated )
. font ( . caption )
}
}
if showProgression , player . getProgression ( ) != 0 {
HStack ( alignment : . top , spacing : 2 ) {
Text ( " ( " )
Text ( player . getProgression ( ) . formatted ( . number . sign ( strategy : . always ( ) ) ) )
. foregroundStyle ( player . getProgressionColor ( progression : player . getProgression ( ) ) )
Text ( " ) " )
} . font ( . title3 )
}
if let pts = player . getPoints ( ) , pts > 0 {
HStack ( alignment : . lastTextBaseline , spacing : 0 ) {
Text ( pts . formatted ( ) ) . font ( . title3 )
Text ( " pts " ) . font ( . caption )
}
}
if let tournamentPlayed = player . tournamentPlayed , tournamentPlayed > 0 {
HStack ( alignment : . lastTextBaseline , spacing : 0 ) {
Text ( tournamentPlayed . formatted ( ) ) . font ( . title3 )
Text ( " tournoi " + tournamentPlayed . pluralSuffix ) . font ( . caption )
}
}
}
. lineLimit ( 1 )
if showFemaleInMaleAssimilation , let assimilatedAsMaleRank = player . getAssimilatedAsMaleRank ( ) {
HStack ( alignment : . top , spacing : 2 ) {
Text ( " ( " )
Text ( assimilatedAsMaleRank . formatted ( ) )
VStack ( alignment : . leading , spacing : 0 ) {
Text ( " équivalence " )
Text ( " messieurs " )
}
. font ( . caption )
Text ( " ) " ) . font ( . title3 )
}
}
HStack {
Text ( player . formattedLicense ( ) )
if let computedAge = player . computedAge {
Text ( computedAge . formatted ( ) + " ans " )
}
}
. font ( . caption )
if let clubName = player . clubName {
Text ( clubName )
. font ( . caption )
}
if let ligueName = player . ligueName {
Text ( ligueName )
. font ( . caption )
}
}
}
}
} header : {